Prev
#! /bin/bash
#
# fail2ban Start/Stop the fail2ban daemon.
#
# chkconfig: 2345 90 60
# description: Fail2Ban scans log files and bans IP \
# that makes too many password failures.
# of the collected data.
# processname: fail2ban-server
# config: /etc/fail2ban/fail2ban
# pidfile: /var/run/fail2ban.pid
#
### BEGIN INIT INFO
# Provides: fail2ban
# Required-Start: $network
# Required-Stop: $network
# Default-Start: 2 3 4 5
# Short-Description: fail2ban
# Description: Fail2Ban scans log files and bans IP \
# that makes too many password failures.
# of the collected data.
### END INIT INFO
# Source function library.
. /etc/init.d/functions
RETVAL=0
# See how we were called.
prog="fail2ban"
start() {
gprintf "Starting %s: " "$prog"
daemon fail2ban-client start < /dev/null
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && touch /var/lock/subsys/fail2ban
return $RETVAL
}
stop() {
gprintf "Stopping %s: " "$prog"
killproc fail2ban-server
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/fail2ban
return $RETVAL
}
rhstatus() {
status fail2ban-server
}
restart() {
stop
start
}
reload() {
gprintf "Reloading collecting daemon configuration: "
killproc fail2ban-server -HUP
retval=$?
echo
return $RETVAL
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
restart
;;
reload)
reload
;;
status)
rhstatus
;;
condrestart)
[ -f /var/lock/subsys/fail2ban ] && restart || :
;;
*)
gprintf "Usage: %s {start|stop|status|reload|restart|condrestart}\n" "$0"
exit 1
esac
exit $?