ports/net-mgmt/unifi2/files/unifi.in
Mark Felder 74b6bf2aef Permit control of the flags passed to java through a new variable
called unifi_javaflags

Users have requested an easy way to make this change. Ubiquiti
recommends 1024M by default, but the actual memory requirement depends
on the size of your environment. It is safe to run at much lower levels
with only a few APs.
2014-03-10 02:48:21 +00:00

75 lines
1.5 KiB
Bash

#!/bin/sh
#
# Created by: Mark Felder <feld@feld.me>
# $FreeBSD: head/net-mgmt/unifi/files/unifi.in 334865 2013-11-25 16:52:21Z feld $
#
# 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"}
command_interpreter=.
command="%%PREFIX%%/bin/java"
command_args="${unifi_javaflags} -jar lib/ace.jar"
start_cmd=start_cmd
start_precmd=start_precmd
stop_cmd=stop_cmd
status_cmd=status_cmd
pidfile="/var/run/${name}.pid"
procname=$(JAVAVM_DRYRUN=yes ${command} | fgrep JAVAVM_COMMAND)
start_precmd()
{
if [ ! -e /var/run/unifi ] ; then
install -d -o %%USERS%% -g %%GROUPS%% /var/run/unifi;
fi
}
start_cmd()
{
check_startmsgs && echo "Starting ${name}."
cd ${unifi_chdir}
daemon -u %%USERS%% -f -p ${pidfile} ${command} ${command_args} start
}
stop_cmd()
{
check_startmsgs && echo "Stopping ${name}."
rc_pid=$(check_pidfile $pidfile $procname)
cd ${unifi_chdir}
${command} ${command_args} stop
wait_for_pids $rc_pid
}
status_cmd()
{
if [ -e ${pidfile} ] && $(pgrep -F ${pidfile} > /dev/null) ; then
mypid=$(cat ${pidfile})
fi
if [ ! ${mypid} = '' ]; then
echo "${name} is running with PID ${mypid}.";
else
echo "${name} not running?";
fi
}
run_rc_command "$1"