Package: ntp-server
Version: 4.2.0a+stable-8
Tags: patch

The following patch provides a "status" option for the
/etc/init.d/ntp-server script.  It also corrects the "run-as" username
displayed in the error message when that user account does not exist.

 < Stephen


--- ntp-4.2.0a+stable/debian/ntp-server.init.d  2005-07-19 06:59:26.000000000 
-0700
+++ debian/ntp-server.init.d    2005-07-20 18:42:48.000000000 -0700
@@ -1,42 +1,61 @@
 #!/bin/sh -e
 
 PATH=/sbin:/bin:/usr/bin
+DAEMON=/usr/sbin/ntpd
+NAME=ntpd
+PIDFILE=/var/run/$NAME.pid
+DESC="NTP server"
 
-test -f /usr/sbin/ntpd || exit 0
+test -f "$DAEMON" || exit 0
 
 RUNASUSER=ntp
 UGID=$(getent passwd $RUNASUSER | cut -f 3,4 -d:) || true
 
 if [ -z "$UGID" ]; then
-  echo "User $USER does not exist" >&2
+  echo "User $RUNASUSER does not exist" >&2
   exit 1
 fi
 
 case "$1" in
        start)
-               echo -n "Starting NTP server: ntpd"
-               start-stop-daemon --start --quiet --pidfile /var/run/ntpd.pid 
--exec /usr/sbin/ntpd -- -p /var/run/ntpd.pid -u $UGID
+               echo -n "Starting $DESC: $NAME"
+               start-stop-daemon --start --quiet --pidfile "$PIDFILE" --exec 
"$DAEMON" -- -p "$PIDFILE" -u $UGID
                echo "."
                ;;
        stop)
-               echo -n "Stopping NTP server: ntpd"
-               start-stop-daemon --stop --quiet --pidfile /var/run/ntpd.pid
+               echo -n "Stopping $DESC: $NAME"
+               start-stop-daemon --stop --quiet --pidfile "$PIDFILE"
                echo "."
-               rm -f /var/run/ntpd.pid
+               rm -f "$PIDFILE"
                ;;
        restart|force-reload)
-               echo -n "Restarting NTP server: ntpd... "
-               start-stop-daemon --stop --quiet --pidfile /var/run/ntpd.pid
+               echo -n "Restarting $DESC: $NAME ..."
+               start-stop-daemon --stop --quiet --pidfile "$PIDFILE"
                sleep 2
-               start-stop-daemon --start --quiet --exec /usr/sbin/ntpd -- -p 
/var/run/ntpd.pid -u $UGID
+               start-stop-daemon --start --quiet --exec "$DAEMON" -- -p 
"$PIDFILE" -u $UGID
                echo "done."
                ;;
+       status)
+               echo -n "Status of $DESC: "
+               if [ ! -r "$PIDFILE" ]; then
+                       echo "$NAME is not running."
+                       exit 3
+               fi
+               if ps -p "$(cat "$PIDFILE" 2> /dev/null)" > /dev/null 2>&1; then
+                       echo "$NAME is running."
+                       exit 0
+               else
+                       echo "$NAME is not running but $PIDFILE exists."
+                       exit 1
+               fi
+               ;;
        reload)
                echo "Not supported, sorry. Use 'restart' or 'force-reload'." 
>&2
                exit 1
                ;;
        *)
-               echo "Usage: /etc/init.d/ntp-server 
{start|stop|restart|force-reload}"
+               ME=/etc/init.d/${0##*/}
+               echo "Usage: $ME {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