Files
denyhosts/denyhosts.init

107 lines
2.7 KiB
Plaintext
Raw Normal View History

#! /bin/sh
#
# This library is free software; you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation; either version 2.1 of the License, or (at
# your option) any later version.
#
# This library is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307,
# USA.
#
# /etc/init.d/denyhosts
# and its symbolic link
# /usr/sbin/rcdenyhosts
#
# LSB compatible service control script; see http://www.linuxbase.org/spec/
#
### BEGIN INIT INFO
# Provides: denyhosts
# Required-Start: $syslog $local_fs $network $remote_fs
# Should-Start: sshd
# Required-Stop: $syslog $local_fs $network $remote_fs
# Should-Stop: sshd
# Default-Start: 3 5
# Default-Stop: 0 1 2 6
# Short-Description: denyhosts daemon to block ssh attempts
# Description: DenyHosts is a python program that automatically blocks ssh
# attacks by adding entries to /etc/hosts.deny.
### END INIT INFO
# Check for missing binaries
DAEMON=/usr/sbin/denyhosts
test -x $DAEMON || { echo "$DAEMON not installed";
if [ "$1" = "stop" ]; then exit 0;
else exit 5; fi; }
CONFIG=/etc/denyhosts.conf
test -r $CONFIG || { echo "$CONFIG not existing";
if [ "$1" = "stop" ]; then exit 0;
else exit 6; fi; }
FLAGS="--daemon --purge --config=$CONFIG"
PIDFILE=/var/run/denyhosts.pid
. /etc/rc.status
rc_reset
case "$1" in
start)
echo -n "Starting DenyHosts "
/sbin/startproc -p $PIDFILE $DAEMON $FLAGS
rc_status -v
;;
stop)
echo -n "Shutting down DenyHosts "
/sbin/killproc -p $PIDFILE -TERM $DAEMON
rc_status -v
;;
try-restart|condrestart)
if test "$1" = "condrestart"; then
echo "${attn} Use try-restart ${done}(LSB)${attn} rather than condrestart ${warn}(RH)${norm}"
fi
$0 status
if test $? = 0; then
$0 restart
else
rc_reset # Not running is not a failure.
fi
rc_status
;;
restart)
$0 stop
$0 start
rc_status
;;
force-reload)
echo -n "Reload service DenyHosts "
/sbin/killproc -HUP $DAEMON
rc_status -v
$0 try-restart
rc_status
;;
reload)
echo -n "Reload service DenyHosts "
/sbin/killproc -HUP $DAEMON
rc_status -v
;;
status)
echo -n "Checking for service DenyHosts "
/sbin/checkproc $DAEMON
rc_status -v
;;
*)
echo "Usage: $0 {start|stop|status|try-restart|restart|force-reload|reload}"
exit 1
;;
esac
rc_exit