updated on Tue Jan 17 12:00:36 UTC 2012
[aur-mirror.git] / virtualbox_bin_beta / vboxweb.rc
blob97273e3c7391d1ce03b3ac30ed5d780ba1403994
1 #!/bin/bash
3 . /etc/rc.conf
4 . /etc/rc.d/functions
5 . /etc/vbox/vbox.cfg
6 . /etc/conf.d/vboxweb
8 BINARY="$INSTALL_DIR/vboxwebsrv"
10 start() {
11 stat_busy "Starting VirtualBox Web Service";
12 if ! pidof -o %PPID $BINARY >/dev/null; then
13 [[ "$VBOXWEB_USER" ]] || stat_die
14 lsmod | grep -q "vboxdrv[^_-]" || stat_die
15 PARAMS="--background"
16 [[ "$VBOXWEB_HOST" ]] && PARAMS+=" -H $VBOXWEB_HOST"
17 [[ "$VBOXWEB_PORT" ]] && PARAMS+=" -p $VBOXWEB_PORT"
18 [[ "$VBOXWEB_TIMEOUT" ]] && PARAMS+=" -t $VBOXWEB_TIMEOUT"
19 [[ "$VBOXWEB_CHECK_INTERVAL" ]] && PARAMS+=" -i $VBOXWEB_CHECK_INTERVAL"
20 [[ "$VBOXWEB_THREADS" ]] && PARAMS+=" -T $VBOXWEB_THREADS"
21 [[ "$VBOXWEB_KEEPALIVE" ]] && PARAMS+=" -k $VBOXWEB_KEEPALIVE"
22 [[ "$VBOXWEB_LOGFILE" ]] && PARAMS+=" -F $VBOXWEB_LOGFILE"
23 # prevent inheriting this setting to VBoxSVC
24 unset VBOX_RELEASE_LOG_DEST
25 su - $VBOXWEB_USER -c "$BINARY $PARAMS" &>/dev/null
26 # ugly: wait until the final process has forked
27 sleep .2
28 if pidof -o %PPID $BINARY >/dev/null; then
29 add_daemon vboxweb
30 stat_done
31 else
32 stat_die
34 else
35 stat_die
39 stop() {
40 stat_busy "Stopping VirtualBox Web Service"
41 PID=$(pidof -o %PPID $BINARY)
42 [[ $PID ]] && kill $PID &>/dev/null
43 if ! pidof -o %PPID $BINARY >/dev/null; then
44 rm_daemon vboxweb
45 stat_done
46 else
47 stat_die
51 restart() {
52 stop && start
55 status() {
56 stat_busy "Checking for VirtualBox Web Service"
57 if pidof -o %PPID $BINARY >/dev/null; then
58 stat_done
59 else
60 stat_fail
61 false
65 case "$1" in
66 start)
67 start
69 stop)
70 stop
72 restart)
73 restart
75 force-reload)
76 restart
78 status)
79 status
82 echo "Usage: $0 {start|stop|restart|status}"
83 exit 1
84 esac
86 # vim:set ts=2 sw=2 ft=sh et: