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