source: /cluster/svnroot/bccd-ng/branches/littlefe-hw/trees/etc/init.d/vboxadd-service @ 2075

Last change on this file since 2075 was 2075, checked in by skylar, 11 years ago

adding vbox services (#421), fixing cuda symlink (#418)

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