aboutsummaryrefslogtreecommitdiff
path: root/system/open-vm-tools/rc.vmtoolsd
diff options
context:
space:
mode:
Diffstat (limited to 'system/open-vm-tools/rc.vmtoolsd')
-rw-r--r--system/open-vm-tools/rc.vmtoolsd58
1 files changed, 58 insertions, 0 deletions
diff --git a/system/open-vm-tools/rc.vmtoolsd b/system/open-vm-tools/rc.vmtoolsd
new file mode 100644
index 000000000000..bbecb2329d01
--- /dev/null
+++ b/system/open-vm-tools/rc.vmtoolsd
@@ -0,0 +1,58 @@
+#!/bin/sh
+# Start/stop/restart open-vm-tools.
+
+openvmtools_check() {
+ vmware-checkvm
+ if [ $? -ne 0 ]; then
+ echo "eRRoR with vmware-checkvm"
+ exit 1
+ fi
+}
+
+openvmtools_start() {
+ openvmtools_check
+ CMDLINE="/usr/bin/vmtoolsd --background=/var/run/vmtoolsd.pid"
+ echo -n "Starting vmtoolsd: $CMDLINE"
+ $CMDLINE || exit 2
+ echo
+}
+
+openvmtools_stop() {
+ VMPID=$(cat /var/run/vmtoolsd.pid)
+ echo -n "Stopping vmtoolsd (PID $VMPID)..."
+ kill -9 $VMPID
+ echo
+}
+
+openvmtools_restart() {
+ openvmtools_stop
+ sleep 1
+ openvmtools_start
+}
+
+# Check if openvmtools is running
+openvmtools_status() {
+ if [ -e /var/run/vmtoolsd.pid ]; then
+ echo "vmtoolsd is running."
+ else
+ echo "vmtoolsd is stopped."
+ exit 1
+ fi
+}
+
+case "$1" in
+'start')
+ openvmtools_start
+ ;;
+'stop')
+ openvmtools_stop
+ ;;
+'restart')
+ openvmtools_restart
+ ;;
+'status')
+ openvmtools_status
+ ;;
+*)
+ echo "usage $0 start|stop|restart|status"
+esac