]> git.pld-linux.org Git - packages/open-vm-tools.git/blob - open-vm-tools-init
- packaging of outstanding files
[packages/open-vm-tools.git] / open-vm-tools-init
1 #!/bin/sh
2 #
3 # open-vm-tools Helper scripts for open-vm-tools
4 #
5 # chkconfig:    345 90 20
6 #
7 # description:  Helper scripts for open-vm-tools
8 #
9 # $Id$
10
11 # Source function library.
12 . /etc/rc.d/init.d/functions
13
14 RETVAL=0
15 kver=`uname -r`
16
17 is_ESX_running() {
18     if [ ! -f /usr/bin/vmware-checkvm ] ; then
19                 echo no
20                 return
21     fi
22     
23     if /usr/bin/vmware-checkvm -p | grep -q ESX; then
24                 echo yes
25     else
26                 echo no
27     fi
28 }
29
30 # return true if $module exists for current kernel
31 module_exist() {
32         local module=$1
33         test -f /lib/modules/$kver/misc/$module.ko*
34 }
35
36 start_vmblock() {
37         # vmblock is not required and unsupported on ESX so first check
38         # if it's installed then try to use
39         module_exist vmblock || return
40
41         # Check if the service is already running?
42         if [ -f /var/lock/subsys/open-vm-tools-vmblock ]; then
43                 msg_already_running "Open Virtual Machine vmblock script"
44                 return
45         fi
46
47         _modprobe single vmblock
48         msg_starting "Open Virtual Machine vmblock script"
49         busy
50         mkdir -p /tmp/VMwareDnD
51         chmod 1777 /tmp/VMwareDnD
52         mount -t vmblock none /proc/fs/vmblock/mountPoint
53         RETVAL=$?
54         [ $RETVAL -eq 0 ] && touch /var/lock/subsys/open-vm-tools-vmblock && ok && return
55         fail
56 }
57
58 stop_vmblock() {
59         module_exist vmblock || return
60
61         if [ ! -f /var/lock/subsys/open-vm-tools-vmblock ]; then
62                 msg_not_running "Open Virtual Machine vmblock script"
63                 return
64         fi
65
66         msg_stopping "Open Virtual Machine vmblock script"
67         busy
68         umount /proc/fs/vmblock/mountPoint
69         RETVAL=$?
70         [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/open-vm-tools-vmblock && ok && return
71         fail
72 }
73
74 start_vmhgfs() {
75         # vmhgfs is not required and usupported on ESX so first check
76         # if it's installed then try to use
77         module_exist vmhgfs || return
78
79         # Check if the service is already running?
80         if [ -f /var/lock/subsys/open-vm-tools-vmhgfs ]; then
81                 msg_already_running "Open Virtual Machine vmhgfs script"
82                 return
83         fi
84
85         _modprobe single vmhgfs
86         msg_starting "Open Virtual Machine vmhgfs script"
87         busy
88         mkdir -p /mnt/hgfs
89         mount -t vmhgfs .host:/ /mnt/hgfs
90         RETVAL=$?
91         [ $RETVAL -eq 0 ] && touch /var/lock/subsys/open-vm-tools-vmhgfs && ok && return
92         fail
93 }
94
95 stop_vmhgfs() {
96         module_exist vmhgfs || return
97
98         if [ ! -f /var/lock/subsys/open-vm-tools-vmhgfs ]; then
99                 msg_not_running "Open Virtual Machine vmhgfs script"
100                 return
101         fi
102
103         msg_stopping "Open Virtual Machine vmhgfs script"
104         busy
105         umount /mnt/hgfs
106         RETVAL=$?
107         [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/open-vm-tools-vmhgfs && ok && return
108         fail
109 }
110
111 start_vmsync() {
112         # Check if the service is already running?
113         if [ -f /var/lock/subsys/open-vm-tools-vmsync ]; then
114                 msg_already_running "Open Virtual Machine vmsync script"
115                 return
116         fi
117
118         msg_starting "Open Virtual Machine vmsync script"
119         daemon /usr/bin/vmtoolsd --background /var/run/vmtoolsd.pid
120         RETVAL=$?
121         [ $RETVAL -eq 0 ] && touch /var/lock/subsys/open-vm-tools-vmsync
122 }
123
124 stop_vmsync() {
125         if [ ! -f /var/lock/subsys/open-vm-tools-vmsync ]; then
126                 msg_not_running "Open Virtual Machine vmsync script"
127                 return
128         fi
129
130         msg_stopping "Open Virtual Machine vmsync script"
131         killproc --pidfile vmtoolsd.pid vmtoolsd
132         rm -f /var/lock/subsys/open-vm-tools-vmsync
133 }
134
135 start() {
136         if is_no `is_ESX_running`; then
137                 start_vmblock
138                 start_vmhgfs
139         fi
140         _modprobe single vmware_vmmemctl
141         _modprobe single vmw_vmci
142         _modprobe single vsock
143         start_vmsync
144 }
145
146 stop() {
147         stop_vmblock
148         stop_vmhgfs
149         stop_vmsync
150 }
151
152 # See how we were called.
153 case "$1" in
154   start)
155         start
156         ;;
157   stop)
158         stop
159         ;;
160   restart)
161         stop
162         start
163         ;;
164   *)
165         msg_usage "$0 {start|stop|restart}"
166         exit 3
167 esac
168
169 exit $RETVAL
This page took 0.235897 seconds and 3 git commands to generate.