]> git.ipfire.org Git - thirdparty/open-vm-tools.git/commitdiff
Using service name from find_networking_script for Sysv 'service' command.
authorVMware, Inc <>
Tue, 13 Mar 2012 20:06:05 +0000 (13:06 -0700)
committerDmitry Torokhov <dtor@vmware.com>
Wed, 14 Mar 2012 16:04:58 +0000 (09:04 -0700)
Directly runing init script to start network service fails on
distros like OpenSuse 12.1. so we need to first try Sysv's 'service'.

The currently approach of finding network service name
with 'service status xxx' will fail when network service is down (return 3),
as a result, suspend vm will fail. This patch fixes the issue by
using the network service name returned from find_networking_script, thus
avoided 'service status xxx' command.

Signed-off-by: Dmitry Torokhov <dtor@vmware.com>
open-vm-tools/scripts/linux/network

index bbdfbcba6d94b1fd19d43572d89b63dd473f3880..1d8100bbca3ec922443de91b1e8c94bda206cdf8 100644 (file)
@@ -87,29 +87,17 @@ find_networking_script() {
 #
 run_network_script()
 {
-   # Do we have SysV "service"? If we do, check whether the network service
-   # is called "network" or "networking".
-   service=`which service 2>/dev/null`
-   serviceName=
-   if [ $? = 0 -a -n "$service" ]; then
-      if $service network status 1>/dev/null 2>/dev/null; then
-         serviceName=network
-      elif $service networking status 1>/dev/null 2>/dev/null; then
-         serviceName=networking
-      fi
-   fi
-
-   if [ -n "$serviceName" ]; then
-      $service $serviceName $1
-      return $?
-   fi
-
-   # If we failed to detect things using the "service" way, fall back to
-   # brute force.
    script=`find_networking_script`
    [ "$script" != "error" ] || Panic "Cannot find system networking script."
 
-   "$script" $1
+   # Using SysV "service" if it exists, otherwise fall back to run the script directly
+   service=`which service 2>/dev/null`
+   if [ $? = 0 -a -n "$service" ]; then
+      serviceName=`basename "$script"`
+      "$service" "$serviceName" "$1"
+   else
+      "$script" "$1"
+   fi
 }