summaryrefslogtreecommitdiff
path: root/network/fail2ban/rc.fail2ban
blob: 001d698d3520db97b1174e49573021662e9d91f9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#!/bin/sh
#
# Copyright (c) 2008-2017, Nishant Limbachia, Hoffman Estates, IL, USA
# <nishant _AT_ mnspace _DOT_ net>
# /etc/rc.d/rc.fail2ban
#
# start|stop|restart|reload|status|ping fail2ban server
#
# To start fail2ban automatically at boot, make this file executable:
# chmod 755 /etc/rc.d/rc.fail2ban
# you must also add this to rc.local for fail2ban to start during boot.

# default socket file is /var/run/fail2ban/fail2ban.sock which can be
# changed via the config file: /etc/fail2ban/fail2ban.conf

fail2ban_start() {
  if [ -x /etc/rc.d/rc.fail2ban ]; then
	printf "Starting fail2ban\n"
	### using -x option to remove any stale socket file
	/usr/bin/fail2ban-client -x start
  fi
}

fail2ban_stop() {
	printf "Stopping fail2ban\n"
	/usr/bin/fail2ban-client stop
}

fail2ban_reload() {
	printf "Reloading fail2ban\n"
	/usr/bin/fail2ban-client reload
}

fail2ban_status() {
	printf "fail2ban Status\n"
	/usr/bin/fail2ban-client status
}

fail2ban_ping() {
	printf "Pinging fail2ban\n"
	/usr/bin/fail2ban-client ping
}

case "$1" in
'start')
	fail2ban_start
  ;;
'stop')
	fail2ban_stop
  ;;
'restart')
	fail2ban_stop
	sleep 5
	fail2ban_start
;;
'reload')
	fail2ban_reload
  ;;
'status')
	fail2ban_status
  ;;
'ping')
	fail2ban_ping
  ;;
*)
	echo "USAGE: $0 start|stop|restart|reload|status|ping"
	exit 1
  ;;
esac