Files
routerstats/routerstats_httpd.rc
2024-05-20 18:57:08 +02:00

36 lines
955 B
Bash
Executable File

#!/bin/sh
# PROVIDE: routerstats_httpd
# Configured by lines in /etc/rc.conf
# routerstats_httpd_enable=BOOL (default: NO, set to YES to start
# routerstats_httpd_flags=STR (default: "", set to the RRD-file you want to display data from
# routerstats_httpd_usr=STR (default: www, set to username to run under different user
. /etc/rc.subr
name="routerstats_httpd"
rcvar=routerstats_httpd_enable
load_rc_config $name
: ${routerstats_httpd_enable:="NO"}
: ${routerstats_httpd_usr:=www}
: ${routerstats_httpd_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_httpd_usr} -o ${logfile} ${python} ${script_py} ${rc_flags}"
install -o ${routerstats_httpd_usr} /dev/null ${pidfile}
}
run_rc_command "$1"