#!/usr/bin/env bash
#
# Copyright (c) 2007-2010 VMware, Inc.  All rights reserved.
#
# This script is intended to allow users who have just installed
# or upgraded their OSPs to bounce the network and bring up the new
# versions of the networking modules (we do not do this automatically
# on installation, to prevent any loss of networking in running
# applications).
#
# The steps to do this manually are simple enough, but vary a bit
# depending on the platform; this script was desired to make it easy
# to instruct users on how to bring up the new network drivers without
# having to reboot.
#
# See bug #350608.

LIBDIR=/usr/lib/vmware-tools

. $LIBDIR/install/vmware-open-vm-tools-common/services.sh source
. $LIBDIR/install/vmware-open-vm-tools-common/functions             # Overrides module loading functions.

net_script=`find_first_exists /etc/init.d/network /etc/init.d/networking`

if [ -z "$net_script" ]; then
   echo "$0: Could not find the appropriate script to manage networking" >&2
   exit 1
fi

set -e
"$net_script" stop
if [ "$(is_vmxnet_needed)" = "yes" ]; then
   echo "Reloading vmxnet module" >&2
   vmware_load_module vmxnet
fi
if [ "$(is_vmxnet3_needed)" = "yes" ]; then
   echo "Reloading vmxnet3 module" >&2
   vmware_load_module vmxnet3
fi
"$net_script" start
