3
# Linux Additions Guest Additions service daemon init script.
5
# Copyright (C) 2006-2010 Oracle Corporation
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.
17
# description: VirtualBox Additions service
20
# Provides: vboxweb-service
21
# Required-Start: vboxdrv
22
# Required-Stop: vboxdrv
23
# Default-Start: 2 3 4 5
25
# Description: VirtualBox Additions Service
28
PATH=$PATH:/bin:/sbin:/usr/sbin
32
[ -f /lib/lsb/init-functions ] || NOLSB=yes
33
[ -f /etc/vbox/vbox.cfg ] && . /etc/vbox/vbox.cfg
35
if [ -n "$INSTALL_DIR" ]; then
36
binary="$INSTALL_DIR/vboxwebsrv"
38
binary="/usr/lib/%PACKAGE%/vboxwebsrv"
41
# silently exit if the package was uninstalled but not purged,
42
# applies to Debian packages only
43
[ -z "$DEBIAN" -o -x $binary ] || exit 0
45
[ -r /etc/default/%PACKAGE% ] && . /etc/default/%PACKAGE%
48
if [ -f /etc/redhat-release ]; then
50
PIDFILE="/var/lock/subsys/vboxweb-service"
51
elif [ -f /etc/SuSE-release ]; then
53
PIDFILE="/var/lock/subsys/vboxweb-service"
54
elif [ -f /etc/debian_version ]; then
56
PIDFILE="/var/run/vboxweb-service"
57
elif [ -f /etc/gentoo-release ]; then
59
PIDFILE="/var/run/vboxweb-service"
60
elif [ -f /etc/arch-release ]; then
62
PIDFILE="/var/run/vboxweb-service"
63
elif [ -f /etc/slackware-version ]; then
65
PIDFILE="/var/run/vboxweb-service"
66
elif [ -f /etc/lfs-release ]; then
68
PIDFILE="/var/run/vboxweb-service.pid"
71
if [ -d /var/run -a -w /var/run ]; then
72
PIDFILE="/var/run/vboxweb-service"
76
if [ -z "$NOLSB" ]; then
77
. /lib/lsb/init-functions
83
log_success_msg " done."
90
if [ "$system" = "redhat" ]; then
91
. /etc/init.d/functions
92
if [ -n "$NOLSB" ]; then
112
if [ "$system" = "suse" ]; then
119
if [ -n "$NOLSB" ]; then
134
if [ "$system" = "debian" ]; then
140
start-stop-daemon --background --chuid $usr --start --exec $bin -- $@
143
start-stop-daemon --stop --exec $@
145
if [ -n "$NOLSB" ]; then
158
if [ "$system" = "gentoo" ]; then
165
start-stop-daemon --background --chuid $usr --start --exec $bin -- $@
168
start-stop-daemon --stop --exec $@
170
if [ -n "$NOLSB" ]; then
180
if [ "`which $0`" = "/sbin/rc" ]; then
186
if [ "$system" = "arch" ]; then
188
. /etc/rc.d/functions
193
test $? -eq 0 && add_daemon rc.`basename $2`
197
rm_daemon `basename $@`
199
if [ -n "$NOLSB" ]; then
212
if [ "$system" = "slackware" ]; then
217
if [ -n "$NOLSB" ]; then
235
if [ "$system" = "lfs" ]; then
236
. /etc/rc.d/init.d/functions
237
if [ -n "$NOLSB" ]; then
258
if [ "$system" = "other" ]; then
259
if [ -n "$NOLSB" ]; then
273
lsmod | grep -q "vboxdrv[^_-]"
276
check_single_user() {
278
fail_msg "VBOXWEB_USER must not contain multiple users!"
284
if ! test -f $PIDFILE; then
285
[ -z "$VBOXWEB_USER" ] && exit 0
286
begin_msg "Starting VirtualBox web service";
287
check_single_user $VBOXWEB_USER
289
fail_msg "VirtualBox kernel module not loaded!"
292
PARAMS="--background"
293
[ -n "$VBOXWEB_HOST" ] && PARAMS="$PARAMS -H $VBOXWEB_HOST"
294
[ -n "$VBOXWEB_PORT" ] && PARAMS="$PARAMS -p $VBOXWEB_PORT"
295
[ -n "$VBOXWEB_TIMEOUT" ] && PARAMS="$PARAMS -t $VBOXWEB_TIMEOUT"
296
[ -n "$VBOXWEB_CHECK_INTERVAL" ] && PARAMS="$PARAMS -i $VBOXWEB_CHECK_INTERVAL"
297
[ -n "$VBOXWEB_THREADS" ] && PARAMS="$PARAMS -T $VBOXWEB_THREADS"
298
[ -n "$VBOXWEB_KEEPALIVE" ] && PARAMS="$PARAMS -k $VBOXWEB_KEEPALIVE"
299
[ -n "$VBOXWEB_LOGFILE" ] && PARAMS="$PARAMS -F $VBOXWEB_LOGFILE"
300
# prevent inheriting this setting to VBoxSVC
301
unset VBOX_RELEASE_LOG_DEST
302
start_daemon $VBOXWEB_USER $binary $PARAMS > /dev/null 2>&1
303
# ugly: wait until the final process has forked
305
PID=`pidof $binary 2>/dev/null`
306
if [ -n "$PID" ]; then
307
echo "$PID" > $PIDFILE
319
if test -f $PIDFILE; then
320
begin_msg "Stopping VirtualBox web service";
323
if ! pidof $binary > /dev/null 2>&1; then
338
echo -n "Checking for VBox Web Service"
339
if [ -f $PIDFILE ]; then
342
echo " ...not running"
364
echo "Usage: $0 {start|stop|restart|status}"