aboutsummaryrefslogtreecommitdiff
path: root/src/open-vm-tools/open-vm-tools.rc.d
diff options
context:
space:
mode:
Diffstat (limited to 'src/open-vm-tools/open-vm-tools.rc.d')
-rwxr-xr-xsrc/open-vm-tools/open-vm-tools.rc.d106
1 files changed, 106 insertions, 0 deletions
diff --git a/src/open-vm-tools/open-vm-tools.rc.d b/src/open-vm-tools/open-vm-tools.rc.d
new file mode 100755
index 0000000..1d9505a
--- /dev/null
+++ b/src/open-vm-tools/open-vm-tools.rc.d
@@ -0,0 +1,106 @@
+#!/bin/bash
+
+. /etc/rc.conf
+. /etc/rc.d/functions
+
+# source application-specific settings
+[ -f /etc/conf.d/open-vm-tools ] && . /etc/conf.d/open-vm-tools
+
+PID=`pidof -o %PPID /usr/bin/vmtoolsd`
+case "$1" in
+ start)
+ stat_busy "Starting Open Virtual Machine Tools"
+
+ if [ "$VM_DRAG_AND_DROP" == "yes" ]; then
+ VMBLOCK=`grep -w vmblock /proc/modules`
+ [ -z "$VMBLOCK" ] && modprobe vmblock
+ if [ $? -gt 0 ]; then
+ stat_fail
+ exit 1
+ fi
+
+ DND_TMPDIR="/tmp/VMwareDnD"
+ if [ ! -d "$DND_TMPDIR" ]; then
+ mkdir $DND_TMPDIR
+ chmod 1777 $DND_TMPDIR
+ fi
+
+ mount -t vmblock none /proc/fs/vmblock/mountPoint
+ if [ $? -gt 0 ]; then
+ stat_fail
+ exit 1
+ fi
+ fi
+
+
+ for m in ${VM_MODULES[@]}; do
+ VMMOD=`grep -w $m /proc/modules`
+ [ -z "$VMMOD" ] && \
+ { modprobe $m
+ if [ $? -gt 0 ]; then
+ stat_fail
+ exit 1
+ fi; }
+ done
+
+
+ [ -z "$PID" ] && /usr/bin/vmtoolsd --background $PIDFILE
+ if [ $? -gt 0 ]; then
+ stat_fail
+ else
+ add_daemon open-vm-tools
+ stat_done
+ fi
+ ;;
+ stop)
+ stat_busy "Stopping Open Virtual Machine Tools"
+ [ ! -z "$PID" ] && kill $PID &>/dev/null
+# if [ $? -gt 0 ]; then
+# stat_fail
+# exit 1
+# fi
+
+ VM_MODULES_RM=()
+ for m in ${VM_MODULES[@]}; do
+ VM_MODULES_RM=($m ${VM_MODULES_RM[@]})
+ done
+
+ for m in ${VM_MODULES_RM[@]}; do
+ VMMOD=`grep -w $m /proc/modules`
+ [ ! -z "$VMMOD" ] && rmmod $m
+ if [ $? -gt 0 ]; then
+ stat_fail
+ exit 4
+ fi
+ done
+
+ if [ "$VM_DRAG_AND_DROP" == "yes" ]; then
+ MOUNTPOINT=`grep -w "none /proc/fs/vmblock/mountPoint vmblock" /proc/modules`
+ [ -z "$MOUNTPOINT" ] && umount /proc/fs/vmblock/mountPoint
+ if [ $? -gt 0 ]; then
+ stat_fail
+ exit 5
+ fi
+
+ DND_TMPDIR="/tmp/VMwareDnD"
+ rm -r $DND_TMPDIR
+
+ VMBLOCK=`grep -w vmblock /proc/modules`
+ [ ! -z "$VMBLOCK" ] && rmmod vmblock
+ if [ $? -gt 0 ]; then
+ stat_fail
+ exit 6
+ fi
+ fi
+
+ rm_daemon open-vm-tools
+ stat_done
+ ;;
+ restart)
+ $0 stop
+ $0 start
+ ;;
+ *)
+ echo "usage: $0 {start|stop|restart}"
+esac
+exit 0