2010-05-11 20:01:32 +02:00
|
|
|
#!/bin/sh
|
|
|
|
#
|
2013-04-29 00:41:00 +02:00
|
|
|
# Copyright (c) 2008-2013, Nishant Limbachia, Hoffman Estates, IL, USA
|
2010-12-07 06:12:15 +01:00
|
|
|
# <nishant _AT_ mnspace _DOT_ net>
|
2010-05-11 20:01:32 +02:00
|
|
|
# /etc/rc.d/rc.fail2ban
|
|
|
|
#
|
2010-05-13 00:36:23 +02:00
|
|
|
# start|stop|restart|reload|status|ping fail2ban server
|
2010-05-11 20:01:32 +02:00
|
|
|
#
|
2010-12-07 06:12:15 +01:00
|
|
|
# To start fail2ban automatically at boot, make this file executable:
|
2010-05-13 00:36:23 +02:00
|
|
|
# chmod 755 /etc/rc.d/rc.fail2ban
|
2011-12-25 13:33:11 +01:00
|
|
|
# you must also add this to rc.local for fail2ban to start during boot.
|
2010-05-12 17:43:15 +02:00
|
|
|
|
2011-12-25 13:33:11 +01:00
|
|
|
# default socket file is /var/run/fail2ban/fail2ban.sock which can be
|
|
|
|
# changed via the config file: /etc/fail2ban/fail2ban.conf
|
2010-05-11 20:01:32 +02:00
|
|
|
|
|
|
|
fail2ban_start() {
|
|
|
|
if [ -x /etc/rc.d/rc.fail2ban ]; then
|
2010-05-11 22:25:16 +02:00
|
|
|
echo "Starting fail2ban: "
|
2010-05-13 00:36:23 +02:00
|
|
|
### using -x option to remove any stale socket file.
|
|
|
|
/usr/bin/fail2ban-client -x start
|
2010-05-11 20:01:32 +02:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
fail2ban_stop() {
|
2010-05-11 22:25:16 +02:00
|
|
|
echo "Stopping fail2ban"
|
2010-05-13 00:36:23 +02:00
|
|
|
/usr/bin/fail2ban-client stop
|
2010-05-11 20:01:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
fail2ban_reload() {
|
2010-05-11 22:25:16 +02:00
|
|
|
echo "Reloading fail2ban"
|
2010-05-13 00:36:23 +02:00
|
|
|
/usr/bin/fail2ban-client reload
|
2010-05-11 20:01:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
fail2ban_status() {
|
2010-05-11 22:25:16 +02:00
|
|
|
echo "Status: fail2ban"
|
2010-05-13 00:36:23 +02:00
|
|
|
/usr/bin/fail2ban-client status
|
2010-05-11 20:01:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
fail2ban_ping() {
|
2010-05-11 22:25:16 +02:00
|
|
|
echo "Pinging fail2ban"
|
2010-05-13 00:36:23 +02:00
|
|
|
/usr/bin/fail2ban-client ping
|
2010-05-11 20:01:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
case "$1" in
|
|
|
|
'start')
|
2010-05-11 22:25:16 +02:00
|
|
|
fail2ban_start
|
2010-05-11 20:01:32 +02:00
|
|
|
;;
|
|
|
|
'stop')
|
2010-05-11 22:25:16 +02:00
|
|
|
fail2ban_stop
|
2010-05-11 20:01:32 +02:00
|
|
|
;;
|
2010-05-11 22:25:16 +02:00
|
|
|
'restart')
|
|
|
|
fail2ban_stop
|
2010-05-13 00:36:23 +02:00
|
|
|
sleep 5
|
2010-05-11 22:25:16 +02:00
|
|
|
fail2ban_start
|
|
|
|
;;
|
2010-05-11 20:01:32 +02:00
|
|
|
'reload')
|
2010-05-11 22:25:16 +02:00
|
|
|
fail2ban_reload
|
2010-05-11 20:01:32 +02:00
|
|
|
;;
|
|
|
|
'status')
|
2010-05-11 22:25:16 +02:00
|
|
|
fail2ban_status
|
2010-05-11 20:01:32 +02:00
|
|
|
;;
|
|
|
|
'ping')
|
2010-05-11 22:25:16 +02:00
|
|
|
fail2ban_ping
|
2010-05-11 20:01:32 +02:00
|
|
|
;;
|
2010-05-12 17:43:15 +02:00
|
|
|
*)
|
2010-05-11 22:25:16 +02:00
|
|
|
echo "USAGE: $0 start|stop|restart|reload|status|ping"
|
|
|
|
exit 1
|
2010-05-11 20:01:32 +02:00
|
|
|
;;
|
|
|
|
esac
|