#!/bin/sh # # fail2ban # # chkconfig: 345 92 08 # description: Fail2ban daemon # http://fail2ban.sourceforge.net/wiki/index.php/Main_Page # process name: fail2ban-server # pidfile: /var/run/fail2ban.pid # config: /etc/fail2ban/fail2ban.conf # # # Source function library . /etc/rc.d/init.d/functions # Get network config . /etc/sysconfig/network # Get service config [ -f /etc/sysconfig/fail2ban ] && . /etc/sysconfig/fail2ban # Check that networking is up. if is_yes "${NETWORKING}"; then if [ ! -f /var/lock/subsys/network -a "$1" != stop -a "$1" != status ]; then msg_network_down fail2ban exit 1 fi else exit 0 fi start() { # Check if the service is already running? if [ ! -f /var/lock/subsys/fail2ban ]; then msg_starting fail2ban daemon /usr/bin/fail2ban-client start RETVAL=$? [ $RETVAL -eq 0 ] && touch /var/lock/subsys/fail2ban else msg_already_running fail2ban fi } stop() { # Stop daemons. if [ -f /var/lock/subsys/fail2ban ]; then msg_stopping fail2ban daemon /usr/bin/fail2ban-client stop rm -f /var/lock/subsys/fail2ban /var/run/fail2ban.pid >/dev/null 2>&1 else msg_not_running fail2ban fi } RETVAL=0 # See how we were called. case "$1" in start) start ;; stop) stop ;; status) status fail2ban RETVAL=$? /usr/bin/fail2ban-client status ;; restart|reload) stop start ;; *) msg_usage "$0 {start|stop|restart|reload|status}" exit 3 ;; esac exit $RETVAL