aboutsummaryrefslogtreecommitdiff
path: root/src/virtualbox
diff options
context:
space:
mode:
authorAdrian C. (anrxc) <anrxc@sysphere.org>2012-11-25 21:24:58 +0100
committerAdrian C. (anrxc) <anrxc@sysphere.org>2012-11-25 21:24:58 +0100
commit16262790cb6ddacf6c632625cc865e03b1b8671f (patch)
tree09898d65deef518380915ecdc7575756c9ca8595 /src/virtualbox
parent7bb1499a7cd539f714bb7f603d7fc0a38fd8a963 (diff)
downloadrcdscripts-16262790cb6ddacf6c632625cc865e03b1b8671f.tar.xz
rcdscripts: import first snapshot of rc.d scripts as of 11.25.20122012.11.25
In 30 days these scripts will start dissapearing from official Arch Linux packages. This is an attempt to conserve them, and keep sysvinit usable.
Diffstat (limited to 'src/virtualbox')
-rwxr-xr-xsrc/virtualbox/vboxservice.rc39
-rwxr-xr-xsrc/virtualbox/vboxweb.rc86
2 files changed, 125 insertions, 0 deletions
diff --git a/src/virtualbox/vboxservice.rc b/src/virtualbox/vboxservice.rc
new file mode 100755
index 0000000..5a62d69
--- /dev/null
+++ b/src/virtualbox/vboxservice.rc
@@ -0,0 +1,39 @@
+#!/bin/bash
+
+. /etc/rc.conf
+. /etc/rc.d/functions
+. /etc/conf.d/${0##*/}
+
+name=VBoxService
+PID=$(pidof -o %PPID $name)
+
+case "$1" in
+ start)
+ stat_busy 'Starting VirtualBox Guest Service'
+ [[ -z "$PID" ]] && ${name} $VBOX_SERVICE_OPTION &>/dev/null \
+ && { add_daemon ${0##*/}; stat_done; } \
+ || { stat_fail; exit 1; }
+ ;;
+ stop)
+ stat_busy 'Stopping VirtualBox Guest Service'
+ [[ -n "$PID" ]] && kill $PID &>/dev/null \
+ && { rm_daemon ${0##*/}; stat_done; } \
+ || { stat_fail; exit 1; }
+ ;;
+ restart)
+ $0 stop
+ sleep 1
+ $0 start
+ ;;
+ status)
+ stat_busy 'Checking VirtualBox Guest Service status'
+ ck_status ${0##*/}
+ ;;
+ *)
+ echo "usage: ${0##*/} {start|stop|restart|status}" >&2
+ exit 1
+esac
+
+exit 0
+
+# vim:set ts=2 sw=2 ft=sh et:
diff --git a/src/virtualbox/vboxweb.rc b/src/virtualbox/vboxweb.rc
new file mode 100755
index 0000000..97273e3
--- /dev/null
+++ b/src/virtualbox/vboxweb.rc
@@ -0,0 +1,86 @@
+#!/bin/bash
+
+. /etc/rc.conf
+. /etc/rc.d/functions
+. /etc/vbox/vbox.cfg
+. /etc/conf.d/vboxweb
+
+BINARY="$INSTALL_DIR/vboxwebsrv"
+
+start() {
+ stat_busy "Starting VirtualBox Web Service";
+ if ! pidof -o %PPID $BINARY >/dev/null; then
+ [[ "$VBOXWEB_USER" ]] || stat_die
+ lsmod | grep -q "vboxdrv[^_-]" || stat_die
+ PARAMS="--background"
+ [[ "$VBOXWEB_HOST" ]] && PARAMS+=" -H $VBOXWEB_HOST"
+ [[ "$VBOXWEB_PORT" ]] && PARAMS+=" -p $VBOXWEB_PORT"
+ [[ "$VBOXWEB_TIMEOUT" ]] && PARAMS+=" -t $VBOXWEB_TIMEOUT"
+ [[ "$VBOXWEB_CHECK_INTERVAL" ]] && PARAMS+=" -i $VBOXWEB_CHECK_INTERVAL"
+ [[ "$VBOXWEB_THREADS" ]] && PARAMS+=" -T $VBOXWEB_THREADS"
+ [[ "$VBOXWEB_KEEPALIVE" ]] && PARAMS+=" -k $VBOXWEB_KEEPALIVE"
+ [[ "$VBOXWEB_LOGFILE" ]] && PARAMS+=" -F $VBOXWEB_LOGFILE"
+ # prevent inheriting this setting to VBoxSVC
+ unset VBOX_RELEASE_LOG_DEST
+ su - $VBOXWEB_USER -c "$BINARY $PARAMS" &>/dev/null
+ # ugly: wait until the final process has forked
+ sleep .2
+ if pidof -o %PPID $BINARY >/dev/null; then
+ add_daemon vboxweb
+ stat_done
+ else
+ stat_die
+ fi
+ else
+ stat_die
+ fi
+}
+
+stop() {
+ stat_busy "Stopping VirtualBox Web Service"
+ PID=$(pidof -o %PPID $BINARY)
+ [[ $PID ]] && kill $PID &>/dev/null
+ if ! pidof -o %PPID $BINARY >/dev/null; then
+ rm_daemon vboxweb
+ stat_done
+ else
+ stat_die
+ fi
+}
+
+restart() {
+ stop && start
+}
+
+status() {
+ stat_busy "Checking for VirtualBox Web Service"
+ if pidof -o %PPID $BINARY >/dev/null; then
+ stat_done
+ else
+ stat_fail
+ false
+ fi
+}
+
+case "$1" in
+start)
+ start
+ ;;
+stop)
+ stop
+ ;;
+restart)
+ restart
+ ;;
+force-reload)
+ restart
+ ;;
+status)
+ status
+ ;;
+*)
+ echo "Usage: $0 {start|stop|restart|status}"
+ exit 1
+esac
+
+# vim:set ts=2 sw=2 ft=sh et: