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
|
#! /bin/sh
### BEGIN INIT INFO
# Provides: ipband
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: ipband daemon
# Description: This is a daemon which can monitor as many different subnets (or individual
# hosts, by specifying a "subnet" of /32) as you'd like.
### END INIT INFO
PATH=/sbin:/bin:/usr/sbin:/usr/bin
DAEMON=/usr/sbin/ipband
NAME=ipband
DESC=ipband
PIDDIR=/var/run/ipband
set -e
test -x $DAEMON || exit 0
if [ -r /etc/default/ipband ]; then
. /etc/default/ipband
else
printf "/etc/default/ipband is not readable, not starting ipband.\n"
exit 0
fi
. /lib/lsb/init-functions
case "$1" in
start)
printf "Starting $DESC:"
mkdir -p $PIDDIR
for config_file in $CONFIG_FILES; do
if [ ! -r "$config_file" ]; then
[ "$CONFIG" = "true" ] || CONFIG="false"
else
CONFIG="true"
IDENTIFIER="$(printf "$config_file" | tr / _)"
start-stop-daemon --start --background --make-pidfile \
--quiet --pidfile "$PIDDIR/$IDENTIFIER.pid" \
--exec $DAEMON -- $FLAGS -c "$config_file"
printf " $config_file"
fi
done
[ "$CONFIG" = "false" ] && printf " no configuration files found"
printf ".\n"
;;
stop)
printf "Stopping $DESC: "
for pid_file in $PIDDIR/*.pid; do
if [ ! -f "$pid_file" ]; then continue; fi
start-stop-daemon --oknodo --stop --quiet --pidfile "$pid_file" \
--exec $DAEMON -- $FLAGS && \
rm -f $pid_file
done
printf "$NAME.\n"
;;
restart|force-reload)
$0 stop || true
$0 start
;;
status)
count=$(ls -1 $PIDDIR/*.pid 2>/dev/null | wc -l)
if [ $count -gt 0 ]; then
echo -n "ipband is running $count configuration"
[ $count -eq 1 ] || echo -n "s"
echo "."
else
echo "Ipband is not running."
fi
;;
*)
N=/etc/init.d/$NAME
echo "Usage: $N {start|stop|restart|force-reload}" >&2
exit 1
;;
esac
exit 0
|