freebsd-ports/emulators/virtualbox-ose-legacy/files/vboxwatchdog.in
Bernhard Froehlich a60eaff53f - Update to virtualbox-ose 4.2.20_1
- This update pulls in many changes from the port and brings better support
for FreeBSD 10 and GCC from ports. I am doing that in preparation of the
upcoming VirtualBox 4.3 update that should land soon.
2013-12-13 11:17:19 +00:00

53 lines
1.2 KiB
Bash

#!/bin/sh
# $FreeBSD$
#
# 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="%%PREFIX%%/bin/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 wheel -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="-b"}
run_rc_command "$1"