#!/bin/ksh
 
daemon="/usr/local/bin/fail2ban-server"
 
. /etc/rc.d/rc.subr
 
rc_bg=YES
rc_reload=NO
 
rc_pre() {
    install -d -o root -m 0700 /var/run/fail2ban
}
 
rc_start() {
    # FYI https://github.com/fail2ban/fail2ban/issues/3923
    nohup ${daemon} -xf start ${daemon_flags} &
}
 
rc_check() {
    pgrep -q -f "fail2ban-server"
}
 
rc_stop() {
    ${rcexec} ${daemon} -x stop
}
 
rc_cmd $1
