Package: dhcp3-server
Version: 3.0.2-2
Tags: patch

The following patch provides a "status" option for the
/etc/init.d/dhcp3-server script.  It also removes the pid
file on "stop".

 < Stephen

--- dhcp3-3.0.2/debian/dhcp3-server.init.d      2005-07-31 08:00:03.000000000 
-0700
+++ debian/dhcp3-server.init.d  2005-07-31 08:02:23.000000000 -0700
@@ -18,6 +18,8 @@
 # should listen on.)
 . /etc/default/dhcp3-server
 
+NAME=dhcpd3
+DESC="DHCP server"
 DHCPDPID=/var/run/dhcpd.pid
 
 test_config()
@@ -30,24 +32,41 @@
        fi
 }
 
+# single arg is -v for messages, -q for none
+check_status()
+{
+    if [ ! -r "$DHCPDPID" ]; then
+       test "$1" != -v || echo "$NAME is not running."
+       return 3
+    fi
+    if read pid < "$DHCPDPID" && ps -p "$pid" > /dev/null 2>&1; then
+       test "$1" != -v || echo "$NAME is running."
+       return 0
+    else
+       test "$1" != -v || echo "$NAME is not running but $DHCPDPID exists."
+       return 1
+    fi
+}
+
 case "$1" in
        start)
                test_config
-               echo -n "Starting DHCP server: "
+               echo -n "Starting $DESC: "
                start-stop-daemon --start --quiet --pidfile $DHCPDPID \
                        --exec /usr/sbin/dhcpd3 -- -q $INTERFACES
                sleep 2
 
-               if [ -f "$DHCPDPID" ] && ps h `cat "$DHCPDPID"` >/dev/null; then
-                       echo "dhcpd3."
+               if check_status -q; then
+                       echo "$NAME."
                else
-                       echo "dhcpd3 failed to start - check syslog for 
diagnostics."
+                       echo "$NAME failed to start - check syslog for 
diagnostics."
                        exit 1
                fi
                ;;
        stop)
-               echo -n "Stopping DHCP server: dhcpd3"
+               echo -n "Stopping $DESC: $NAME"
                start-stop-daemon --stop --quiet --pidfile $DHCPDPID
+               rm -f "$DHCPDPID"
                echo "."
                ;;
        restart | force-reload)
@@ -59,8 +78,13 @@
                        exit 1
                fi
                ;;
+       status)
+               echo -n "Status of $DESC: "
+               check_status -v
+               exit "$?"
+               ;;
        *)
-               echo "Usage: /etc/init.d/dhcp3-server 
{start|stop|restart|force-reload}"
+               echo "Usage: $0 {start|stop|restart|force-reload|status}"
                exit 1 
 esac
 


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]

Reply via email to