aboutsummaryrefslogtreecommitdiff
path: root/system/open-vm-tools/rc.vmtoolsd
blob: bbecb2329d012006c5fd359cd96a3ce454f1afc3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
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