/etc/init.d/denyhosts is in denyhosts 2.10-2.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
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 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 | #! /bin/sh
#
# Init script for denyhosts
#
# Author: Marco Bertorello <marco@bertorello.ns0.it>.
#
### BEGIN INIT INFO
# Provides: denyhosts
# Required-Start: $syslog $local_fs $remote_fs $time
# Required-Stop: $syslog $local_fs $remote_fs
# Should-Start: $network
# Should-Stop: $network
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start/stop denyhosts
# Description: Start/stop denyhosts, a daemon that automatically blocks
# SSH brute-force attacks by adding entries to /etc/hosts.deny
### END INIT INFO
# Using LSB funtions:
. /lib/lsb/init-functions
set -e
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
DESC="DenyHosts"
NAME=denyhosts
DAEMON=/usr/bin/python
DAEMONCTL=/usr/share/denyhosts/denyhosts_ctl.py
PIDFILE=/run/$NAME.pid
SCRIPTNAME=/etc/init.d/$NAME
CONFIG=/etc/denyhosts.conf
FLAGS="--config=$CONFIG"
# Function that starts the daemon/service.
d_start() {
# Gracefully exit if the package has been removed.
test -x $DAEMON || exit 5
test -e $CONFIG || (log_failure_msg "Config file doesn't exists!" && log_end_msg 1)
#check if HOSTS_DENY file exist
HOSTS_DENY=$(grep ^HOSTS_DENY $CONFIG | cut -d = -f 2)
test -e $HOSTS_DENY || touch $HOSTS_DENY
if [ -e $PIDFILE ]; then
pid=$(cat $PIDFILE)
if kill -0 "$pid" > /dev/null; then
log_success_msg "$DESC already running"
return
else
log_success_msg "Removing stale PID file $PIDFILE."
rm -f $PIDFILE
fi
fi
log_daemon_msg "Starting $DESC" "$NAME"
start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON --startas $DAEMONCTL -- start $FLAGS >/dev/null
log_end_msg $?
}
# Function that stops the daemon/service.
d_stop() {
if [ -e $PIDFILE ]; then
pid=$(cat $PIDFILE)
if kill -0 "$pid" > /dev/null; then
log_daemon_msg "Stopping $DESC" "$NAME"
start-stop-daemon --stop --quiet --pidfile $PIDFILE
log_end_msg $?
else
log_failure_msg "I can't stop $DESC" "Maybe it's NOT running?"
rm -f $PIDFILE
fi
fi
}
# Function that sends a SIGHUP to the daemon/service.
case "$1" in
start)
d_start
;;
stop)
d_stop
;;
restart|force-reload)
d_stop || /bin/true
sleep 1
d_start
;;
status)
status_of_proc -p $PIDFILE $DAEMON $NAME
;;
*)
log_daemon_msg "Usage: $SCRIPTNAME {start|stop|restart|force-reload|status}" >&2
exit 3
;;
esac
exit 0
|