[packages/open-vm-tools] simplify

glen glen at pld-linux.org
Thu Sep 26 18:15:43 CEST 2013


commit 38a7a2ffa4a16ecc438047202904111e198d91f4
Author: Elan Ruusamäe <glen at delfi.ee>
Date:   Thu Sep 26 19:11:49 2013 +0300

    simplify

 open-vm-tools-init | 164 ++++++++++++++++++++++++++++-------------------------
 1 file changed, 86 insertions(+), 78 deletions(-)
---
diff --git a/open-vm-tools-init b/open-vm-tools-init
old mode 100644
new mode 100755
index a85d7f4..d15e1ff
--- a/open-vm-tools-init
+++ b/open-vm-tools-init
@@ -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}"
================================================================

---- gitweb:

http://git.pld-linux.org/gitweb.cgi/packages/open-vm-tools.git/commitdiff/415b0c7c50027188e4b601496fe1133084bc6121



More information about the pld-cvs-commit mailing list