2010-05-11 20:01:32 +02:00
|
|
|
#!/bin/sh
|
|
|
|
#
|
2010-05-13 00:36:23 +02:00
|
|
|
# Copyright (c) 2008-2009, Nishant Limbachia, Hoffman Est, IL, USA (nishant@mnspace.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-05-13 00:36:23 +02:00
|
|
|
# To start fail2ban automatically at boot, make this file executable:
|
|
|
|
# chmod 755 /etc/rc.d/rc.fail2ban
|
|
|
|
# you must also add this file to rc.local for fail2ban to start during boot.
|
2010-05-12 17:43:15 +02:00
|
|
|
|
2010-05-13 00:36:23 +02: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
|
|
|
else
|
2010-05-11 22:25:16 +02:00
|
|
|
echo "rc.fail2ban is not executable or you don't have enough permissions"
|
|
|
|
exit 1
|
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
|