VirtualBox

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

Last change on this file since 41244 was 38810, checked in by vboxsync, 13 years ago

Additions/linux/installer: apparently openSUSE 12.1 will no longer have /var/lock/subsys (ticket #6229)

  • Property svn:eol-style set to LF
  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 5.1 KB
Line 
1#!/bin/sh
2#
3# Linux Additions Guest Additions service daemon init script.
4#
5# Copyright (C) 2006-2010 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 . /sbin/functions.sh
121 daemon() {
122 start-stop-daemon --start --exec $1 -- $2
123 }
124
125 killproc() {
126 start-stop-daemon --stop --retry 2 --exec $@
127 }
128
129 fail_msg() {
130 echo " ...fail!"
131 }
132
133 succ_msg() {
134 echo " ...done."
135 }
136
137 begin() {
138 echo -n "$1"
139 }
140
141 if [ "`which $0`" = "/sbin/rc" ]; then
142 shift
143 fi
144fi
145
146if [ "$system" = "arch" ]; then
147 USECOLOR=yes
148 . /etc/rc.d/functions
149 daemon() {
150 $@
151 test $? -eq 0 && add_daemon rc.`basename $1`
152 }
153
154 killproc() {
155 killall $@
156 rm_daemon `basename $@`
157 }
158
159 fail_msg() {
160 stat_fail
161 }
162
163 succ_msg() {
164 stat_done
165 }
166
167 begin() {
168 stat_busy "$1"
169 }
170
171fi
172
173if [ "$system" = "slackware" -o "$system" = "other" ]; then
174 daemon() {
175 $1 $2
176 }
177
178 killproc() {
179 killall $1
180 rm -f $PIDFILE
181 }
182
183 fail_msg() {
184 echo " ...fail!"
185 }
186
187 succ_msg() {
188 echo " ...done."
189 }
190
191 begin() {
192 echo -n "$1"
193 }
194
195fi
196
197if [ "$system" = "lfs" ]; then
198 . /etc/rc.d/init.d/functions
199 daemon() {
200 loadproc $1 $2
201 }
202
203 fail_msg() {
204 echo_failure
205 }
206
207 succ_msg() {
208 echo_ok
209 }
210
211 begin() {
212 echo $1
213 }
214
215 status() {
216 statusproc $1
217 }
218fi
219
220binary=/usr/sbin/VBoxService
221
222testbinary() {
223 test -x "$binary" || {
224 echo "Cannot run $binary"
225 exit 1
226 }
227}
228
229vboxaddrunning() {
230 lsmod | grep -q "vboxguest[^_-]"
231}
232
233start() {
234 if ! test -f $PIDFILE; then
235 begin "Starting VirtualBox Guest Addition service ";
236 vboxaddrunning || {
237 echo "VirtualBox Additions module not loaded!"
238 exit 1
239 }
240 testbinary
241 daemon $binary > /dev/null
242 RETVAL=$?
243 test $RETVAL -eq 0 && echo `pidof VBoxService` > $PIDFILE
244 succ_msg
245 fi
246 return $RETVAL
247}
248
249stop() {
250 if test -f $PIDFILE; then
251 begin "Stopping VirtualBox Guest Addition service ";
252 killproc $binary
253 RETVAL=$?
254 if ! pidof VBoxService > /dev/null 2>&1; then
255 rm -f $PIDFILE
256 succ_msg
257 else
258 fail_msg
259 fi
260 fi
261 return $RETVAL
262}
263
264restart() {
265 stop && start
266}
267
268status() {
269 echo -n "Checking for VBoxService"
270 if [ -f $PIDFILE ]; then
271 echo " ...running"
272 else
273 echo " ...not running"
274 fi
275}
276
277case "$1" in
278start)
279 start
280 ;;
281stop)
282 stop
283 ;;
284restart)
285 restart
286 ;;
287status)
288 status
289 ;;
290setup)
291 ;;
292cleanup)
293 ;;
294*)
295 echo "Usage: $0 {start|stop|restart|status}"
296 exit 1
297esac
298
299exit $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