]> git.pld-linux.org Git - packages/pdnsd.git/blobdiff - pdnsd.init
b33080f49c508cf64bf7e227d37c1758 pdnsd-ac_am.patch
[packages/pdnsd.git] / pdnsd.init
index fe43533b400589a265ed433e3a27ca798245ce90..402e08481b4ae924c538c5a540861ff128f5e348 100644 (file)
@@ -1,53 +1,85 @@
-#!/bin/bash
+#!/bin/sh
 #
-# $Id$
+# pdns         Proxy DNS Daemon
 #
-#      /etc/rc.d/init.d/pdnsd
+# chkconfig:   345 14 89
 #
-# Starts the Proxy DNS Daemon
-#
-# tested on Redhat 6.1 should work on 5.0+
-# chkconfig: 345 87 14
-# description: Proxy DNS Daemon
+# description: Proxy DNS Daemon
 #
 
-# Source function library.
+# Source function library
 . /etc/rc.d/init.d/functions
 
+# Get network config
+. /etc/sysconfig/network
+
+# Default parameters
+STATUS="--status"
+DEBUG="--debug"
+VERBOSE="-v2"
+
+# Get service config - may override defaults
+[ -f /etc/sysconfig/pdnsd ] && . /etc/sysconfig/pdnsd
+
+# Check that networking is up.
+if is_yes "${NETWORKING}"; then
+       if [ ! -f /var/lock/subsys/network -a "$1" != stop -a "$1" != status ]; then
+               msg_network_down Pdnsd
+               exit 1
+       fi
+else
+       exit 0
+fi
+
 test -x /usr/sbin/pdnsd || exit 0
 
 RETVAL=0
-
-#
-#      See how we were called.
-#
 case "$1" in
   start)
-       echo -n 'Starting pdnsd: '
-       daemon /usr/sbin/pdnsd -d
-       RETVAL=$? 
-       [ $RETVAL -eq 0 ] && touch /var/lock/subsys/pdnsd
-       echo
+       # Check if the service is already running?
+       if [ ! -f /var/lock/subsys/pdns ]; then
+               msg_starting Pdns
+               daemon pdnsd --daemon $STATUS $DEBUG $VERBOSE
+               RETVAL=$?
+               [ $RETVAL -eq 0 ] && touch /var/lock/subsys/pdns
+       else
+               msg_already_running Pdns
+       fi
        ;;
   stop)
-       echo -n 'Shutting down pdnsd: '
-       killproc pdnsd 
-       RETVAL=$? 
-       [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/pdnsd
-       echo
-       ;;
-  status)
-    status pdnsd
-       exit $?
+       if [ -f /var/lock/subsys/pdns ]; then
+               # Stop daemons.
+               # show "Stopping %s service" pdns
+               msg_stopping Pdns
+               killproc pdnsd
+               rm -f /var/lock/subsys/pdns >/dev/null 2>&1
+       else
+               msg_not_running Pdns
+       fi
        ;;
-  reload|restart)
+  restart)
        $0 stop
        $0 start
-       RETVAL=$?
-       ;;
+       exit $?
+       ;;
+  reload|force-reload)
+       if [ -f /var/lock/subsys/pdns ]; then
+               msg_reloading Pdns
+               killproc pdnsd -HUP
+               RETVAL=$?
+       else
+               msg_not_running Pdns >&2
+               exit 7
+       fi
+       ;;
+  status)
+       status pdnsd
+       exit $?
+       ;;
   *)
-       echo "Usage: /etc/rc.d/init.d/pdnsd {start|stop|status|restart|reload}"
-       exit 1
+       # show "Usage: %s {start|stop|restart|reload|force-reload|status}"
+       msg_usage "$0 {start|stop|restart|reload|force-reload|status}"
+       exit 3
 esac
 
 exit $RETVAL
This page took 0.032301 seconds and 4 git commands to generate.