4917e33051
VoIP and Video of Ubiquiti Networks. This port tracks the development releases. WWW: http://wiki.ubnt.com/UniFi_FAQ PR: 223401
60 lines
1.1 KiB
Bash
60 lines
1.1 KiB
Bash
#!/bin/sh
|
|
#
|
|
# Created by: Mark Felder <feld@FreeBSD.org>
|
|
# $FreeBSD$
|
|
#
|
|
|
|
# PROVIDE: unifi
|
|
# REQUIRE: LOGIN
|
|
# KEYWORD: shutdown
|
|
|
|
#
|
|
# Add the following line to /etc/rc.conf to enable `unifi':
|
|
#
|
|
# unifi_enable="YES"
|
|
|
|
. /etc/rc.subr
|
|
name=unifi
|
|
|
|
rcvar=unifi_enable
|
|
load_rc_config ${name}
|
|
|
|
: ${unifi_enable:=NO}
|
|
: ${unifi_user:=%%USERS%%}
|
|
: ${unifi_group:=%%GROUPS%%}
|
|
: ${unifi_chdir=%%JAVASHAREDIR%%/unifi}
|
|
: ${unifi_javaflags:="-Djava.awt.headless=true -Xmx1024M"}
|
|
|
|
pidfile="/var/run/unifi/${name}.pid"
|
|
procname=%%JAVA%%
|
|
command="/usr/sbin/daemon"
|
|
command_args="-f -p ${pidfile} %%JAVA%% ${unifi_javaflags} -jar lib/ace.jar start"
|
|
start_precmd=start_precmd
|
|
stop_precmd=stop_precmd
|
|
stop_postcmd=stop_postcmd
|
|
|
|
start_precmd()
|
|
{
|
|
if [ ! -e /var/run/unifi ] ; then
|
|
install -d -o %%USERS%% -g %%GROUPS%% /var/run/unifi;
|
|
fi
|
|
}
|
|
|
|
stop_precmd()
|
|
{
|
|
if [ -r ${pidfile} ]; then
|
|
_UNIFIPID=$(check_pidfile ${pidfile} ${procname})
|
|
export _UNIFI_CHILDREN=$(pgrep -P ${_UNIFIPID})
|
|
fi
|
|
}
|
|
|
|
stop_postcmd()
|
|
{
|
|
if ! [ -z ${_UNIFI_CHILDREN} ]; then
|
|
echo "Cleaning up leftover child processes."
|
|
kill $sig_stop ${_UNIFI_CHILDREN}
|
|
wait_for_pids ${_UNIFI_CHILDREN}
|
|
fi
|
|
}
|
|
|
|
run_rc_command "$1"
|