#!/bin/sh # # chkconfig: 2345 65 35 # description: dhcp_probe attempts to discover DHCP and BootP servers on a directly-attached # Ethernet network. A network administrator can use this tool to locate # unauthorized DHCP and BootP servers. # processname: dhcp_probe # pidfile: /var/run/dhcp_probe.pid # config: /etc/dhcp_probe.cf ### BEGIN INIT INFO # Provides: dhcp_probe # Required-Start: $network # Required-Stop: $network # Default-Stop: 0 1 2 6 # Short-Description: start/stop/restart the dhcp_probe daemon # Description: dhcp_probe attempts to discover DHCP and BootP servers. ### END INIT INFO # Source function library . /etc/rc.d/init.d/functions # Get network config . /etc/sysconfig/network [ -f /etc/sysconfig/dhcp_probe ] && . /etc/sysconfig/dhcp_probe start() { if [ -f /var/lock/subsys/dhcp_probe ]; then msg_already_running "dhcp_probe" return fi for nic in $INTERFACES; do msg_starting "dhcp_probe on $nic" daemon /usr/sbin/dhcp_probe -p /var/run/dhcp_probe.$nic.pid $nic done touch /var/lock/subsys/dhcp_probe } stop() { if [ ! -f /var/lock/subsys/dhcp_probe ]; then msg_not_running "dhcp_probe" return fi for nic in $INTERFACES; do msg_stopping "dhcp_probe on $nic" killproc --pidfile /var/run/dhcp_probe.$nic.pid dhcp_probe done # kill leftovers if an interface was removed from $INTERFACES for file in /var/run/dhcp_probe*pid ; do nic=${file##/var/run/dhcp_probe.} nic=${nic%%pid} [ -z "$nic" ] && nic="unknown interface" msg_stopping "dhcp_probe on $nic" killproc --pidfile $file dhcp_probe done rm -f /var/lock/subsys/dhcp_probe >/dev/null 2>&1 } reload(){ for nic in $INTERFACES; do killproc --pidfile /var/run/dhcp_probe.$nic.pid dhcp_probe -HUP done } status_f() { for nic in $INTERFACES; do status --pidfile /var/run/dhcp_probe.$nic.pid "dhcp_probe on $nic" done } condrestart() { if [ ! -f /var/lock/subsys/dhcp_probe ]; then msg_not_running "dhcp_probe" return fi stop start } RETVAL=0 # See how we were called. case "$1" in start) start ;; stop) stop ;; status) status_f ;; restart|force-reload) stop start ;; reload) reload ;; condrestart|try-restart) restart ;; *) msg_usage "$0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload}" exit 3 ;; esac exit $RETVAL