summaryrefslogtreecommitdiff
path: root/emulators/virtualbox-ose-71/files/vboxwatchdog.in
diff options
context:
space:
mode:
Diffstat (limited to 'emulators/virtualbox-ose-71/files/vboxwatchdog.in')
-rw-r--r--emulators/virtualbox-ose-71/files/vboxwatchdog.in51
1 files changed, 51 insertions, 0 deletions
diff --git a/emulators/virtualbox-ose-71/files/vboxwatchdog.in b/emulators/virtualbox-ose-71/files/vboxwatchdog.in
new file mode 100644
index 000000000000..c21bc03b3523
--- /dev/null
+++ b/emulators/virtualbox-ose-71/files/vboxwatchdog.in
@@ -0,0 +1,51 @@
+#!/bin/sh
+
+# PROVIDE: vboxwatchdog
+# REQUIRE: LOGIN
+# KEYWORD: shutdown
+#
+# Add the following line to /etc/rc.conf[.local] to enable vboxwatchdog
+#
+# vboxwatchdog_enable (bool): Set to "NO" by default.
+# Set it to "YES" to enable vboxwatchdog.
+# vboxwatchdog_user (str): User account to run with.
+# vboxwatchdog_flags (str): Custom flags for VBoxWatchdog.
+
+. /etc/rc.subr
+
+name=vboxwatchdog
+rcvar=vboxwatchdog_enable
+
+command="%%VBOXDIR%%/VBoxBalloonCtrl"
+pidfile="/var/run/${name}.pid"
+
+start_cmd="${name}_start"
+
+vboxwatchdog_start()
+{
+ local pid
+
+ HOME=$(/usr/sbin/pw usershow -7 -n "${vboxwatchdog_user}" | /usr/bin/cut -d: -f6)
+ pid=$(check_pidfile $pidfile $command)
+
+ if [ -n "${pid}" ]; then
+ echo "${name} already running? (pid=${pid})."
+ return 1
+ fi
+
+ # prevent inheriting this setting to VBoxSVC
+ unset VBOX_RELEASE_LOG_DEST
+
+ echo -n "Starting ${name}"
+ /usr/bin/install -o ${vboxwatchdog_user} -g %%VBOXGROUP%% -m 644 /dev/null ${pidfile}
+ /usr/sbin/daemon -f -p ${pidfile} -u ${vboxwatchdog_user} ${command} ${vboxwatchdog_flags}
+ echo '.'
+}
+
+load_rc_config $name
+
+: ${vboxwatchdog_enable="NO"}
+: ${vboxwatchdog_user="%%VBOXUSER%%"}
+: ${vboxwatchdog_flags=""}
+
+run_rc_command "$1"