36 lines
959 B
Bash
Executable File
36 lines
959 B
Bash
Executable File
#!/bin/sh
|
|
# PROVIDE: routerstats_client
|
|
|
|
# Configured by lines in /etc/rc.conf
|
|
# routerstats_client_enable=BOOL (default: NO, set to YES to start
|
|
# routerstats_client_flags=STR (default: "", set to "hostname port rrdfile passwd_file"
|
|
# routerstats_client_usr=STR (default: www, set to username to run under different user
|
|
|
|
. /etc/rc.subr
|
|
|
|
name="routerstats_client"
|
|
rcvar=routerstats_client_enable
|
|
|
|
load_rc_config $name
|
|
|
|
: ${routerstats_client_enable:="NO"}
|
|
: ${routerstats_client_usr:=www}
|
|
: ${routerstats_client_flags=""}
|
|
|
|
#daemon
|
|
basedir="/usr/local/www/routerstats"
|
|
pidfile="${basedir}/${name}.pid"
|
|
logfile="${basedir}/${name}.log"
|
|
script_py="${basedir}/${name}.py"
|
|
python="/usr/local/bin/python3"
|
|
command="/usr/sbin/daemon"
|
|
start_precmd="runfirst"
|
|
|
|
runfirst()
|
|
{
|
|
rc_flags=" -c -f -P ${pidfile} -u ${routerstats_client_usr} -o ${logfile} ${python} ${script_py} ${rc_flags}"
|
|
install -o ${routerstats_client_usr} /dev/null ${pidfile}
|
|
}
|
|
|
|
run_rc_command "$1"
|