#!/bin/bash # # chkconfig: - 95 05 # description: The ip-sentinel daemon keeps your IP space clean by \ # preventing unauthorized usage of IPs # processname: ip-sentinel # pidfile: /var/run/ip-sentinel.run # Reproduced for Debian GNU/Linux users by GopoDebian.com # IPS_USER= # IPS_GROUP= # IPS_CHROOT= # IPS_IPFILE=ips.cfg # IPS_LOGFILE=/var/log/ip-sentinel.out # IPS_ERRFILE=/var/log/ip-sentinel.err # IPS_OPTIONS= # IPS_DEVICE=eth0 progandpath=/usr/local/sbin/ip-sentinel ## Assign to yes if running a dietlibc-compiled version of ip-sentinel ## on a system using remote NSS for passwd-lookups (e.g. LDAP, NIS). ## ## When using a group which is not the effective group of the user, ## you will have to assign the numeric gid of this group to GROUP. # IPS_NEEDS_NUMERIC_UID= # Check that networking is not down. test -f /etc/sysconfig/network && . /etc/sysconfig/network test "$NETWORKING" != "no" || exit 0 defuser=ip-sentinel test -f /etc/sysconfig/ip-sentinel && . /etc/sysconfig/ip-sentinel prog="ip-sentinel" lockfile=/var/run/ip-sentinel.run addOption() { opt="$opt${2:+$1$2 }" } is_running() { retval=1 if [ -r ${lockfile} ]; then pid=`cat ${lockfile}` if [ -e /proc/$pid ]; then procname=`/bin/ps h -p $pid` [ -n "$procname" ] && retval=0 fi fi return $retval } start () { echo -n $"Starting $prog " if test x"${IPS_NEEDS_NUMERIC_UID}" = xyes; then test -z "$IPS_GROUP" && \ x=`id -g ${IPS_USER:-$defuser} 2>/dev/null` && IPS_GROUP="$x" x=`id -u ${IPS_USER:-$defuser} 2>/dev/null` && IPS_USER="$x" fi opt= addOption "-u " "$IPS_USER" addOption "-g " "$IPS_GROUP" addOption "-r " "$IPS_CHROOT" addOption "-i " "$IPS_IPFILE" addOption "-l " "$IPS_LOGFILE" addOption "-e " "$IPS_ERRFILE" addOption "" "$IPS_OPTIONS" start-stop-daemon --start --exec ${progandpath} -- ${opt} ${IPS_DEVICE:-eth0} ret=$? echo [ $ret -eq 0 ] && touch $lockfile return $ret } stop () { echo -n $"Stopping $prog " start-stop-daemon --stop --pidfile ${lockfile} ret=$? echo [ $ret -eq 0 ] && rm -f $lockfile return $ret } restart () { stop echo "Please, wait while child process quit..." while `ps aux | grep -v 'init.d' | grep [i]p-sentinel >/dev/null` do echo -n ". " sleep 1 done echo "[Done]" start } status() { STATUS="Status of ${prog}:" if is_running; then echo "$STATUS running." else echo "$STATUS stopped." fi } # See how we were called. case "$1" in start|stop|restart) $1 ;; reload) restart ;; condrestart) test ! -f $lockfile || restart ;; status) status ;; *) echo $"Usage: $0 {start|stop|restart|reload|condrestart}" exit 2 esac