summaryrefslogtreecommitdiff
path: root/emulators/virtualbox-ose/files/vboxwebsrv.in
blob: a7e1e38e309081b79c2ea351cdce544e7f6b9d0d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
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"