#!/bin/sh
# $FreeBSD: branches/2020Q1/www/filtron/files/filtron.in 463944 2018-03-09 08:34:57Z yuri $

# PROVIDE: filtron
# REQUIRE: DAEMON NETWORKING
# BEFORE: LOGIN
# KEYWORD: shutdown

# Add the following lines to /etc/rc.conf to enable filtron:
# filtron_enable="YES"
#
# filtron_enable (bool):	Set to YES to enable filtron
#				Default: NO
# filtron_conf (str):		filtron configuration file
#				Default: ${PREFIX}/etc/filtron.conf
# filtron_user (str):		filtron daemon user
#				Default: filtron
# filtron_group (str):		filtron daemon group
#				Default: filtron
# filtron_flags (str):		Extra flags passed to filtron

. /etc/rc.subr

name="filtron"
rcvar=filtron_enable

: ${filtron_enable:="NO"}
: ${filtron_user:="www"}
: ${filtron_group:="www"}
: ${filtron_flags:=""}

# daemon
pidfile="/var/run/${name}.pid"
command=/usr/local/bin/filtron
procname="daemon"
command_args=" -rules /usr/local/etc/filtron-rules.json -listen 0.0.0.0:4004 &"
start_precmd="filtron_precmd"

filtron_precmd()
{
    install -o ${filtron_user} /dev/null ${pidfile}
}

load_rc_config $name
run_rc_command "$1"
