]> git.pld-linux.org Git - packages/open-vm-tools.git/commitdiff
simplify
authorElan Ruusamäe <glen@delfi.ee>
Thu, 26 Sep 2013 16:11:49 +0000 (19:11 +0300)
committerElan Ruusamäe <glen@delfi.ee>
Thu, 26 Sep 2013 16:11:49 +0000 (19:11 +0300)
open-vm-tools-init [changed mode: 0644->0755]

old mode 100644 (file)
new mode 100755 (executable)
index a85d7f4..d15e1ff
@@ -15,14 +15,14 @@ RETVAL=0
 
 is_ESX_running() {
     if [ ! -f /usr/bin/vmware-checkvm ] ; then
-       echo no
-       return
+               echo no
+               return
     fi
     
     if /usr/bin/vmware-checkvm -p | grep -q ESX; then
-       echo yes
+               echo yes
     else
-       echo no
+               echo no
     fi
 }
 
@@ -34,35 +34,37 @@ module_exist() {
 
 start_vmxnet() {
        # Check if the service is already running?
-       if [ ! -f /var/lock/subsys/open-vm-tools-vmxnet ]; then
-               msg_starting "Open Virtual Machine vmxnet script"
-               busy
-               if is_no `module_exist vmxnet`; then
-                       fail
-                       echo -e "\tCan't find vmxnet module"
-                       RETVAL=1
-                       return
-               fi
-
-               for ethif in `ifconfig -a | grep ^eth | cut -d' ' -f1`; do
-                       /sbin/ethtool -K $ethif tso on > /dev/null 2>&1
-               done
-               ok
-               touch /var/lock/subsys/open-vm-tools-vmxnet
-       else
+       if [ -f /var/lock/subsys/open-vm-tools-vmxnet ]; then
                msg_already_running "Open Virtual Machine vmxnet script"
+               return
+       fi
+
+       msg_starting "Open Virtual Machine vmxnet script"
+       busy
+       if is_no `module_exist vmxnet`; then
+               fail
+               echo -e "\tCan't find vmxnet module"
+               RETVAL=1
+               return
        fi
+
+       for ethif in `ifconfig -a | grep ^eth | cut -d' ' -f1`; do
+               /sbin/ethtool -K $ethif tso on > /dev/null 2>&1
+       done
+       ok
+       touch /var/lock/subsys/open-vm-tools-vmxnet
 }
 
 stop_vmxnet() {
-       if [ -f /var/lock/subsys/open-vm-tools-vmxnet ]; then
-               msg_stopping "Open Virtual Machine vmxnet script"
-               busy
-               rm -f /var/lock/subsys/open-vm-tools-vmxnet
-               ok
-       else
+       if [ ! -f /var/lock/subsys/open-vm-tools-vmxnet ]; then
                msg_not_running "Open Virtual Machine vmxnet script"
+               return
        fi
+
+       msg_stopping "Open Virtual Machine vmxnet script"
+       busy
+       rm -f /var/lock/subsys/open-vm-tools-vmxnet
+       ok
 }
 
 start_vmblock() {
@@ -71,34 +73,36 @@ start_vmblock() {
        is_no `module_exist vmblock` && return
 
        # Check if the service is already running?
-       if [ ! -f /var/lock/subsys/open-vm-tools-vmblock ]; then
-               _modprobe single vmblock
-               msg_starting "Open Virtual Machine vmblock script"
-               busy
-               mkdir -p /tmp/VMwareDnD
-               chmod 1777 /tmp/VMwareDnD
-               mount -t vmblock none /proc/fs/vmblock/mountPoint
-               RETVAL=$?
-               [ $RETVAL -eq 0 ] && touch /var/lock/subsys/open-vm-tools-vmblock && ok && return
-               fail
-       else
+       if [ -f /var/lock/subsys/open-vm-tools-vmblock ]; then
                msg_already_running "Open Virtual Machine vmblock script"
+               return
        fi
+
+       _modprobe single vmblock
+       msg_starting "Open Virtual Machine vmblock script"
+       busy
+       mkdir -p /tmp/VMwareDnD
+       chmod 1777 /tmp/VMwareDnD
+       mount -t vmblock none /proc/fs/vmblock/mountPoint
+       RETVAL=$?
+       [ $RETVAL -eq 0 ] && touch /var/lock/subsys/open-vm-tools-vmblock && ok && return
+       fail
 }
 
 stop_vmblock() {
        is_no `module_exist vmblock` && return
 
-       if [ -f /var/lock/subsys/open-vm-tools-vmblock ]; then
-               msg_stopping "Open Virtual Machine vmblock script"
-               busy
-               umount /proc/fs/vmblock/mountPoint
-               RETVAL=$?
-               [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/open-vm-tools-vmblock && ok && return
-               fail
-       else
+       if [ ! -f /var/lock/subsys/open-vm-tools-vmblock ]; then
                msg_not_running "Open Virtual Machine vmblock script"
+               return
        fi
+
+       msg_stopping "Open Virtual Machine vmblock script"
+       busy
+       umount /proc/fs/vmblock/mountPoint
+       RETVAL=$?
+       [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/open-vm-tools-vmblock && ok && return
+       fail
 }
 
 start_vmhgfs() {
@@ -107,56 +111,60 @@ start_vmhgfs() {
        is_no `module_exist vmhgfs` && return
 
        # Check if the service is already running?
-       if [ ! -f /var/lock/subsys/open-vm-tools-vmhgfs ]; then
-               _modprobe single vmhgfs
-               msg_starting "Open Virtual Machine vmhgfs script"
-               busy
-               mkdir -p /mnt/hgfs
-               mount -t vmhgfs .host:/ /mnt/hgfs
-               RETVAL=$?
-               [ $RETVAL -eq 0 ] && touch /var/lock/subsys/open-vm-tools-vmhgfs && ok && return
-               fail
-       else
+       if [ -f /var/lock/subsys/open-vm-tools-vmhgfs ]; then
                msg_already_running "Open Virtual Machine vmhgfs script"
+               return
        fi
+
+       _modprobe single vmhgfs
+       msg_starting "Open Virtual Machine vmhgfs script"
+       busy
+       mkdir -p /mnt/hgfs
+       mount -t vmhgfs .host:/ /mnt/hgfs
+       RETVAL=$?
+       [ $RETVAL -eq 0 ] && touch /var/lock/subsys/open-vm-tools-vmhgfs && ok && return
+       fail
 }
 
 stop_vmhgfs() {
        is_no `module_exist vmhgfs` && return
 
-       if [ -f /var/lock/subsys/open-vm-tools-vmhgfs ]; then
-               msg_stopping "Open Virtual Machine vmhgfs script"
-               busy
-               umount /mnt/hgfs
-               RETVAL=$?
-               [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/open-vm-tools-vmhgfs && ok && return
-               fail
-       else
+       if [ ! -f /var/lock/subsys/open-vm-tools-vmhgfs ]; then
                msg_not_running "Open Virtual Machine vmhgfs script"
+               return
        fi
+
+       msg_stopping "Open Virtual Machine vmhgfs script"
+       busy
+       umount /mnt/hgfs
+       RETVAL=$?
+       [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/open-vm-tools-vmhgfs && ok && return
+       fail
 }
 
 start_vmsync() {
        # Check if the service is already running?
-       if [ ! -f /var/lock/subsys/open-vm-tools-vmsync ]; then
-               _modprobe single vmsync
-               msg_starting "Open Virtual Machine vmsync script"
-               daemon /usr/bin/vmtoolsd --background /var/run/vmtoolsd.pid
-               RETVAL=$?
-               [ $RETVAL -eq 0 ] && touch /var/lock/subsys/open-vm-tools-vmsync
-       else
+       if [ -f /var/lock/subsys/open-vm-tools-vmsync ]; then
                msg_already_running "Open Virtual Machine vmsync script"
+               return
        fi
+
+       _modprobe single vmsync
+       msg_starting "Open Virtual Machine vmsync script"
+       daemon /usr/bin/vmtoolsd --background /var/run/vmtoolsd.pid
+       RETVAL=$?
+       [ $RETVAL -eq 0 ] && touch /var/lock/subsys/open-vm-tools-vmsync
 }
 
 stop_vmsync() {
-       if [ -f /var/lock/subsys/open-vm-tools-vmsync ]; then
-               msg_stopping "Open Virtual Machine vmsync script"
-               killproc --pidfile vmtoolsd.pid vmtoolsd
-               rm -f /var/lock/subsys/open-vm-tools-vmsync
-       else
+       if [ ! -f /var/lock/subsys/open-vm-tools-vmsync ]; then
                msg_not_running "Open Virtual Machine vmsync script"
+               return
        fi
+
+       msg_stopping "Open Virtual Machine vmsync script"
+       killproc --pidfile vmtoolsd.pid vmtoolsd
+       rm -f /var/lock/subsys/open-vm-tools-vmsync
 }
 
 start() {
@@ -185,11 +193,11 @@ case "$1" in
        start
        ;;
   stop)
-       stop
+       stop
        ;;
   restart)
-       stop
-       start
+       stop
+       start
        ;;
   *)
        msg_usage "$0 {start|stop|restart}"
This page took 0.527895 seconds and 4 git commands to generate.