]>
Commit | Line | Data |
---|---|---|
98be3241 | 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 | |
415b0c7c | 13 | set -x |
98be3241 | 14 | |
15 | RETVAL=0 | |
9aed8438 | 16 | kver=`uname -r` |
98be3241 | 17 | |
71a75d2b | 18 | is_ESX_running() { |
19 | if [ ! -f /usr/bin/vmware-checkvm ] ; then | |
38a7a2ff ER |
20 | echo no |
21 | return | |
71a75d2b | 22 | fi |
23 | ||
24 | if /usr/bin/vmware-checkvm -p | grep -q ESX; then | |
38a7a2ff | 25 | echo yes |
71a75d2b | 26 | else |
38a7a2ff | 27 | echo no |
71a75d2b | 28 | fi |
29 | } | |
30 | ||
415b0c7c | 31 | # return true if $module exists for current kernel |
98be3241 | 32 | module_exist() { |
415b0c7c ER |
33 | local module=$1 |
34 | test -f /lib/modules/$kver/misc/$module.ko* | |
98be3241 | 35 | } |
36 | ||
37 | start_vmxnet() { | |
38 | # Check if the service is already running? | |
38a7a2ff | 39 | if [ -f /var/lock/subsys/open-vm-tools-vmxnet ]; then |
98be3241 | 40 | msg_already_running "Open Virtual Machine vmxnet script" |
38a7a2ff ER |
41 | return |
42 | fi | |
43 | ||
44 | msg_starting "Open Virtual Machine vmxnet script" | |
45 | busy | |
415b0c7c | 46 | if ! module_exist vmxnet; then |
38a7a2ff ER |
47 | fail |
48 | echo -e "\tCan't find vmxnet module" | |
49 | RETVAL=1 | |
50 | return | |
98be3241 | 51 | fi |
38a7a2ff ER |
52 | |
53 | for ethif in `ifconfig -a | grep ^eth | cut -d' ' -f1`; do | |
54 | /sbin/ethtool -K $ethif tso on > /dev/null 2>&1 | |
55 | done | |
56 | ok | |
57 | touch /var/lock/subsys/open-vm-tools-vmxnet | |
98be3241 | 58 | } |
59 | ||
60 | stop_vmxnet() { | |
38a7a2ff | 61 | if [ ! -f /var/lock/subsys/open-vm-tools-vmxnet ]; then |
98be3241 | 62 | msg_not_running "Open Virtual Machine vmxnet script" |
38a7a2ff | 63 | return |
98be3241 | 64 | fi |
38a7a2ff ER |
65 | |
66 | msg_stopping "Open Virtual Machine vmxnet script" | |
67 | busy | |
68 | rm -f /var/lock/subsys/open-vm-tools-vmxnet | |
69 | ok | |
98be3241 | 70 | } |
71 | ||
72 | start_vmblock() { | |
73 | # vmblock is not required and unsupported on ESX so first check | |
74 | # if it's installed then try to use | |
415b0c7c | 75 | module_exist vmblock || return |
98be3241 | 76 | |
77 | # Check if the service is already running? | |
38a7a2ff | 78 | if [ -f /var/lock/subsys/open-vm-tools-vmblock ]; then |
98be3241 | 79 | msg_already_running "Open Virtual Machine vmblock script" |
38a7a2ff | 80 | return |
98be3241 | 81 | fi |
38a7a2ff ER |
82 | |
83 | _modprobe single vmblock | |
84 | msg_starting "Open Virtual Machine vmblock script" | |
85 | busy | |
86 | mkdir -p /tmp/VMwareDnD | |
87 | chmod 1777 /tmp/VMwareDnD | |
88 | mount -t vmblock none /proc/fs/vmblock/mountPoint | |
89 | RETVAL=$? | |
90 | [ $RETVAL -eq 0 ] && touch /var/lock/subsys/open-vm-tools-vmblock && ok && return | |
91 | fail | |
98be3241 | 92 | } |
93 | ||
94 | stop_vmblock() { | |
415b0c7c | 95 | module_exist vmblock || return |
98be3241 | 96 | |
38a7a2ff | 97 | if [ ! -f /var/lock/subsys/open-vm-tools-vmblock ]; then |
98be3241 | 98 | msg_not_running "Open Virtual Machine vmblock script" |
38a7a2ff | 99 | return |
98be3241 | 100 | fi |
38a7a2ff ER |
101 | |
102 | msg_stopping "Open Virtual Machine vmblock script" | |
103 | busy | |
104 | umount /proc/fs/vmblock/mountPoint | |
105 | RETVAL=$? | |
106 | [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/open-vm-tools-vmblock && ok && return | |
107 | fail | |
98be3241 | 108 | } |
109 | ||
110 | start_vmhgfs() { | |
111 | # vmhgfs is not required and usupported on ESX so first check | |
112 | # if it's installed then try to use | |
415b0c7c | 113 | module_exist vmhgfs || return |
98be3241 | 114 | |
115 | # Check if the service is already running? | |
38a7a2ff | 116 | if [ -f /var/lock/subsys/open-vm-tools-vmhgfs ]; then |
98be3241 | 117 | msg_already_running "Open Virtual Machine vmhgfs script" |
38a7a2ff | 118 | return |
98be3241 | 119 | fi |
38a7a2ff ER |
120 | |
121 | _modprobe single vmhgfs | |
122 | msg_starting "Open Virtual Machine vmhgfs script" | |
123 | busy | |
124 | mkdir -p /mnt/hgfs | |
125 | mount -t vmhgfs .host:/ /mnt/hgfs | |
126 | RETVAL=$? | |
127 | [ $RETVAL -eq 0 ] && touch /var/lock/subsys/open-vm-tools-vmhgfs && ok && return | |
128 | fail | |
98be3241 | 129 | } |
130 | ||
131 | stop_vmhgfs() { | |
415b0c7c | 132 | module_exist vmhgfs || return |
98be3241 | 133 | |
38a7a2ff | 134 | if [ ! -f /var/lock/subsys/open-vm-tools-vmhgfs ]; then |
98be3241 | 135 | msg_not_running "Open Virtual Machine vmhgfs script" |
38a7a2ff | 136 | return |
98be3241 | 137 | fi |
38a7a2ff ER |
138 | |
139 | msg_stopping "Open Virtual Machine vmhgfs script" | |
140 | busy | |
141 | umount /mnt/hgfs | |
142 | RETVAL=$? | |
143 | [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/open-vm-tools-vmhgfs && ok && return | |
144 | fail | |
98be3241 | 145 | } |
146 | ||
147 | start_vmsync() { | |
148 | # Check if the service is already running? | |
38a7a2ff | 149 | if [ -f /var/lock/subsys/open-vm-tools-vmsync ]; then |
98be3241 | 150 | msg_already_running "Open Virtual Machine vmsync script" |
38a7a2ff | 151 | return |
98be3241 | 152 | fi |
38a7a2ff ER |
153 | |
154 | _modprobe single vmsync | |
155 | msg_starting "Open Virtual Machine vmsync script" | |
156 | daemon /usr/bin/vmtoolsd --background /var/run/vmtoolsd.pid | |
157 | RETVAL=$? | |
158 | [ $RETVAL -eq 0 ] && touch /var/lock/subsys/open-vm-tools-vmsync | |
98be3241 | 159 | } |
160 | ||
161 | stop_vmsync() { | |
38a7a2ff | 162 | if [ ! -f /var/lock/subsys/open-vm-tools-vmsync ]; then |
98be3241 | 163 | msg_not_running "Open Virtual Machine vmsync script" |
38a7a2ff | 164 | return |
98be3241 | 165 | fi |
38a7a2ff ER |
166 | |
167 | msg_stopping "Open Virtual Machine vmsync script" | |
168 | killproc --pidfile vmtoolsd.pid vmtoolsd | |
169 | rm -f /var/lock/subsys/open-vm-tools-vmsync | |
98be3241 | 170 | } |
171 | ||
172 | start() { | |
173 | start_vmxnet | |
71a75d2b | 174 | if is_no `is_ESX_running`; then |
175 | start_vmblock | |
176 | start_vmhgfs | |
177 | fi | |
ae69fefb | 178 | _modprobe single vmware_vmmemctl |
98be3241 | 179 | _modprobe single vmci |
180 | _modprobe single vsock | |
224f2e73 | 181 | _modprobe single vmw_pvscsi |
98be3241 | 182 | start_vmsync |
183 | } | |
184 | ||
185 | stop() { | |
186 | stop_vmxnet | |
187 | stop_vmblock | |
188 | stop_vmhgfs | |
189 | stop_vmsync | |
190 | } | |
191 | ||
192 | # See how we were called. | |
193 | case "$1" in | |
194 | start) | |
195 | start | |
196 | ;; | |
197 | stop) | |
38a7a2ff | 198 | stop |
98be3241 | 199 | ;; |
200 | restart) | |
38a7a2ff ER |
201 | stop |
202 | start | |
98be3241 | 203 | ;; |
204 | *) | |
205 | msg_usage "$0 {start|stop|restart}" | |
206 | exit 3 | |
207 | esac | |
208 | ||
209 | exit $RETVAL |