# PROVIDE: threatline
# REQUIRE: LOGIN
# KEYWORD: shutdown

# Add the following lines to /etc/rc.conf to enable threatline:
#
# threatline_enable="YES"
#
#

. /etc/rc.subr

name="threatline"
rcvar=threatline_enable

# read configuration and set defaults
load_rc_config "$name"
: ${threatline_enable="NO"}
: ${threatline_agents="normalize enrich check archive"}
: ${threatline_pidfile="/tmp/threatline.pid"}
: ${threatline_path="/usr/local/threatline/threatline/threatline.py"}

start_cmd="threatline_start"
stop_cmd="threatline_stop"
daemon_head=/usr/sbin/daemon
python_path=/usr/local/bin/python2.7

threatline_start()
{
    if checkyesno ${rcvar}; then
        echo "* starting threatline... "
        $daemon_head -p $threatline_pidfile $python_path $threatline_path $threatline_agents 
    fi
}

threatline_stop()
{
    if checkyesno ${rcvar}; then
        echo "* stopping threatline... "
        #pkill python
        kill `ps ax | awk '/threatline/{print $1}'` 2>/dev/null
    fi
}

threatline_restart()
{
    threatline_stop
    threatline_start
}

run_rc_command "$1"
