1 |
#! /bin/sh |
2 |
# |
3 |
# This library is free software; you can redistribute it and/or modify it |
4 |
# under the terms of the GNU Lesser General Public License as published by |
5 |
# the Free Software Foundation; either version 2.1 of the License, or (at |
6 |
# your option) any later version. |
7 |
# |
8 |
# This library is distributed in the hope that it will be useful, but |
9 |
# WITHOUT ANY WARRANTY; without even the implied warranty of |
10 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
11 |
# Lesser General Public License for more details. |
12 |
# |
13 |
# You should have received a copy of the GNU Lesser General Public |
14 |
# License along with this library; if not, write to the Free Software |
15 |
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, |
16 |
# USA. |
17 |
# |
18 |
# /etc/init.d/denyhosts |
19 |
# and its symbolic link |
20 |
# /usr/sbin/rcdenyhosts |
21 |
# |
22 |
# LSB compatible service control script; see http://www.linuxbase.org/spec/ |
23 |
# |
24 |
### BEGIN INIT INFO |
25 |
# Provides: denyhosts |
26 |
# Required-Start: $syslog $local_fs $network $remote_fs |
27 |
# Should-Start: sshd |
28 |
# Required-Stop: $syslog $local_fs $network $remote_fs |
29 |
# Should-Stop: sshd |
30 |
# Default-Start: 3 5 |
31 |
# Default-Stop: 0 1 2 6 |
32 |
# Short-Description: denyhosts daemon to block ssh attempts |
33 |
# Description: DenyHosts is a python program that automatically blocks ssh |
34 |
# attacks by adding entries to /etc/hosts.deny. |
35 |
### END INIT INFO |
36 |
|
37 |
|
38 |
# Check for missing binaries |
39 |
DAEMON=/usr/sbin/denyhosts |
40 |
test -x $DAEMON || { echo "$DAEMON not installed"; |
41 |
if [ "$1" = "stop" ]; then exit 0; |
42 |
else exit 5; fi; } |
43 |
|
44 |
CONFIG=/etc/denyhosts.conf |
45 |
test -r $CONFIG || { echo "$CONFIG not existing"; |
46 |
if [ "$1" = "stop" ]; then exit 0; |
47 |
else exit 6; fi; } |
48 |
|
49 |
FLAGS="--daemon --purge --config=$CONFIG" |
50 |
PIDFILE=/var/run/denyhosts.pid |
51 |
|
52 |
. /etc/rc.status |
53 |
|
54 |
rc_reset |
55 |
|
56 |
case "$1" in |
57 |
start) |
58 |
echo -n "Starting DenyHosts " |
59 |
/sbin/startproc -p $PIDFILE $DAEMON $FLAGS |
60 |
rc_status -v |
61 |
;; |
62 |
stop) |
63 |
echo -n "Shutting down DenyHosts " |
64 |
/sbin/killproc -p $PIDFILE -TERM $DAEMON |
65 |
rc_status -v |
66 |
;; |
67 |
try-restart|condrestart) |
68 |
if test "$1" = "condrestart"; then |
69 |
echo "${attn} Use try-restart ${done}(LSB)${attn} rather than condrestart ${warn}(RH)${norm}" |
70 |
fi |
71 |
$0 status |
72 |
if test $? = 0; then |
73 |
$0 restart |
74 |
else |
75 |
rc_reset # Not running is not a failure. |
76 |
fi |
77 |
rc_status |
78 |
;; |
79 |
restart) |
80 |
$0 stop |
81 |
$0 start |
82 |
rc_status |
83 |
;; |
84 |
force-reload) |
85 |
echo -n "Reload service DenyHosts " |
86 |
/sbin/killproc -HUP $DAEMON |
87 |
rc_status -v |
88 |
$0 try-restart |
89 |
rc_status |
90 |
;; |
91 |
reload) |
92 |
echo -n "Reload service DenyHosts " |
93 |
/sbin/killproc -HUP $DAEMON |
94 |
rc_status -v |
95 |
;; |
96 |
status) |
97 |
echo -n "Checking for service DenyHosts " |
98 |
/sbin/checkproc $DAEMON |
99 |
rc_status -v |
100 |
;; |
101 |
*) |
102 |
echo "Usage: $0 {start|stop|status|try-restart|restart|force-reload|reload}" |
103 |
exit 1 |
104 |
;; |
105 |
esac |
106 |
rc_exit |