VirtualBox

source: vbox/trunk/src/VBox/Additions/linux/installer/vboxadd-service.sh@ 53402

Last change on this file since 53402 was 44528, checked in by vboxsync, 12 years ago

header (C) fixes

  • Property svn:eol-style set to LF
  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 5.3 KB
Line 
1#!/bin/sh
2#
3# Linux Additions Guest Additions service daemon init script.
4#
5# Copyright (C) 2006-2012 Oracle Corporation
6#
7# This file is part of VirtualBox Open Source Edition (OSE), as
8# available from http://www.virtualbox.org. This file is free software;
9# you can redistribute it and/or modify it under the terms of the GNU
10# General Public License (GPL) as published by the Free Software
11# Foundation, in version 2 as it comes in the "COPYING" file of the
12# VirtualBox OSE distribution. VirtualBox OSE is distributed in the
13# hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
14#
15
16# chkconfig: 35 35 65
17# description: VirtualBox Additions service
18#
19### BEGIN INIT INFO
20# Provides: vboxadd-service
21# Required-Start: vboxadd
22# Required-Stop: vboxadd
23# Default-Start: 2 3 4 5
24# Default-Stop: 0 1 6
25# Description: VirtualBox Additions Service
26### END INIT INFO
27
28PATH=$PATH:/bin:/sbin:/usr/sbin
29
30system=unknown
31if [ -f /etc/redhat-release ]; then
32 system=redhat
33 PIDFILE="/var/lock/subsys/vboxadd-service"
34elif [ -f /etc/SuSE-release ]; then
35 system=suse
36 PIDFILE="/var/run/vboxadd-service"
37elif [ -f /etc/debian_version ]; then
38 system=debian
39 PIDFILE="/var/run/vboxadd-service"
40elif [ -f /etc/gentoo-release ]; then
41 system=gentoo
42 PIDFILE="/var/run/vboxadd-service"
43elif [ -f /etc/arch-release ]; then
44 system=arch
45 PIDFILE="/var/run/vboxadd-service"
46elif [ -f /etc/slackware-version ]; then
47 system=slackware
48 PIDFILE="/var/run/vboxadd-service"
49elif [ -f /etc/lfs-release ]; then
50 system=lfs
51 PIDFILE="/var/run/vboxadd-service.pid"
52else
53 system=other
54 if [ -d /var/run -a -w /var/run ]; then
55 PIDFILE="/var/run/vboxadd-service"
56 fi
57fi
58
59if [ "$system" = "redhat" ]; then
60 . /etc/init.d/functions
61 fail_msg() {
62 echo_failure
63 echo
64 }
65
66 succ_msg() {
67 echo_success
68 echo
69 }
70
71 begin() {
72 echo -n "$1"
73 }
74fi
75
76if [ "$system" = "suse" ]; then
77 . /etc/rc.status
78 daemon() {
79 startproc ${1+"$@"}
80 }
81
82 fail_msg() {
83 rc_failed 1
84 rc_status -v
85 }
86
87 succ_msg() {
88 rc_reset
89 rc_status -v
90 }
91
92 begin() {
93 echo -n "$1"
94 }
95fi
96
97if [ "$system" = "debian" ]; then
98 daemon() {
99 start-stop-daemon --start --exec $1 -- $2
100 }
101
102 killproc() {
103 start-stop-daemon --stop --retry 2 --exec $@
104 }
105
106 fail_msg() {
107 echo " ...fail!"
108 }
109
110 succ_msg() {
111 echo " ...done."
112 }
113
114 begin() {
115 echo -n "$1"
116 }
117fi
118
119if [ "$system" = "gentoo" ]; then
120 if [ -f /sbin/functions.sh ]; then
121 . /sbin/functions.sh
122 elif [ -f /etc/init.d/functions.sh ]; then
123 . /etc/init.d/functions.sh
124 fi
125 daemon() {
126 start-stop-daemon --start --exec $1 -- $2
127 }
128
129 killproc() {
130 start-stop-daemon --stop --retry 2 --exec $@
131 }
132
133 fail_msg() {
134 echo " ...fail!"
135 }
136
137 succ_msg() {
138 echo " ...done."
139 }
140
141 begin() {
142 echo -n "$1"
143 }
144
145 if [ "`which $0`" = "/sbin/rc" ]; then
146 shift
147 fi
148fi
149
150if [ "$system" = "arch" ]; then
151 USECOLOR=yes
152 . /etc/rc.d/functions
153 daemon() {
154 $@
155 test $? -eq 0 && add_daemon rc.`basename $1`
156 }
157
158 killproc() {
159 killall $@
160 rm_daemon `basename $@`
161 }
162
163 fail_msg() {
164 stat_fail
165 }
166
167 succ_msg() {
168 stat_done
169 }
170
171 begin() {
172 stat_busy "$1"
173 }
174
175fi
176
177if [ "$system" = "slackware" -o "$system" = "other" ]; then
178 daemon() {
179 $1 $2
180 }
181
182 killproc() {
183 killall $1
184 rm -f $PIDFILE
185 }
186
187 fail_msg() {
188 echo " ...fail!"
189 }
190
191 succ_msg() {
192 echo " ...done."
193 }
194
195 begin() {
196 echo -n "$1"
197 }
198
199fi
200
201if [ "$system" = "lfs" ]; then
202 . /etc/rc.d/init.d/functions
203 daemon() {
204 loadproc $1 $2
205 }
206
207 fail_msg() {
208 echo_failure
209 }
210
211 succ_msg() {
212 echo_ok
213 }
214
215 begin() {
216 echo $1
217 }
218
219 status() {
220 statusproc $1
221 }
222fi
223
224binary=/usr/sbin/VBoxService
225
226testbinary() {
227 test -x "$binary" || {
228 echo "Cannot run $binary"
229 exit 1
230 }
231}
232
233vboxaddrunning() {
234 lsmod | grep -q "vboxguest[^_-]"
235}
236
237start() {
238 if ! test -f $PIDFILE; then
239 begin "Starting VirtualBox Guest Addition service ";
240 vboxaddrunning || {
241 echo "VirtualBox Additions module not loaded!"
242 exit 1
243 }
244 testbinary
245 daemon $binary > /dev/null
246 RETVAL=$?
247 test $RETVAL -eq 0 && echo `pidof VBoxService` > $PIDFILE
248 succ_msg
249 fi
250 return $RETVAL
251}
252
253stop() {
254 if test -f $PIDFILE; then
255 begin "Stopping VirtualBox Guest Addition service ";
256 killproc $binary
257 RETVAL=$?
258 if ! pidof VBoxService > /dev/null 2>&1; then
259 rm -f $PIDFILE
260 succ_msg
261 else
262 fail_msg
263 fi
264 fi
265 return $RETVAL
266}
267
268restart() {
269 stop && start
270}
271
272status() {
273 echo -n "Checking for VBoxService"
274 if [ -f $PIDFILE ]; then
275 echo " ...running"
276 else
277 echo " ...not running"
278 fi
279}
280
281case "$1" in
282start)
283 start
284 ;;
285stop)
286 stop
287 ;;
288restart)
289 restart
290 ;;
291status)
292 status
293 ;;
294setup)
295 ;;
296cleanup)
297 ;;
298*)
299 echo "Usage: $0 {start|stop|restart|status}"
300 exit 1
301esac
302
303exit $RETVAL
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette