Subversion Repositories configs

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
4 - 1
#!/bin/bash
2
#
3
# chkconfig: - 92 08
4
# processname: fail2ban-server
5
# config: /etc/fail2ban/fail2ban.conf
6
# pidfile: /var/run/fail2ban/fail2ban.pid
7
# description: fail2ban is a daemon to ban hosts that cause multiple authentication errors
8
#
9
### BEGIN INIT INFO
10
# Provides: fail2ban
11
# Required-Start: $local_fs $remote_fs
12
# Required-Stop: $local_fs $remote_fs
13
# Should-Start: $time $network $syslog iptables firehol shorewall ferm
14
# Should-Stop: $network $syslog iptables firehol shorewall ferm
15
# Default-Start: 3 4 5
16
# Default-Stop: 0 1 6
17
# Short-Description: Start/Stop fail2ban
18
# Description: Start/Stop fail2ban, a daemon to ban hosts that cause multiple authentication errors
19
### END INIT INFO
20
 
21
# Source function library.
22
. /etc/rc.d/init.d/functions
23
 
24
# Check that the config file exists
25
[ -f /etc/fail2ban/fail2ban.conf ] || exit 0
26
 
27
FAIL2BAN="/usr/bin/fail2ban-client"
28
prog=fail2ban-server
29
lockfile=${LOCKFILE-/var/lock/subsys/fail2ban}
30
socket=${SOCKET-/var/run/fail2ban/fail2ban.sock}
31
pidfile=${PIDFILE-/var/run/fail2ban/fail2ban.pid}
32
RETVAL=0
33
 
34
start() {
35
    echo -n $"Starting fail2ban: "
36
    ${FAIL2BAN} -x start > /dev/null
37
    RETVAL=$?
38
    if [ $RETVAL = 0 ]; then
39
        touch ${lockfile}
40
        echo_success
41
    else
42
        echo_failure
43
    fi
44
    echo
45
    return $RETVAL
46
}
47
 
48
stop() {
49
    echo -n $"Stopping fail2ban: "
50
    ${FAIL2BAN} stop > /dev/null
51
    RETVAL=$?
52
    if [ $RETVAL = 0 ]; then
53
        rm -f ${lockfile} ${pidfile}
54
        echo_success
55
    else
56
        echo_failure
57
    fi
58
    echo
59
    return $RETVAL
60
}
61
 
62
reload() {
63
    echo "Reloading fail2ban: "
64
    ${FAIL2BAN} reload
65
    RETVAL=$?
66
    echo
67
    return $RETVAL
68
}
69
 
70
# See how we were called.
71
case "$1" in
72
    start)
73
        status -p ${pidfile} ${prog} >/dev/null 2>&1 && exit 0
74
        start
75
        ;;
76
    stop)
77
        stop
78
        ;;
79
    reload)
80
        reload
81
        ;;
82
    restart)
83
        stop
84
        start
85
        ;;
86
    status)
87
        status -p ${pidfile} ${prog}
88
        RETVAL=$?
89
        [ $RETVAL = 0 ] && ${FAIL2BAN} status
90
        ;;
91
    *)
92
        echo $"Usage: fail2ban {start|stop|restart|reload|status}"
93
        RETVAL=2
94
esac
95
 
96
exit $RETVAL