]> git.pld-linux.org Git - packages/dhcp.git/blobdiff - dhcp-relay.init
- updated from somewhere, but not 4.0.0 compatible
[packages/dhcp.git] / dhcp-relay.init
index 61bf1f14b3724605e2c9868eca1e2a0da119454d..62716c4f61f95a1f6dbc373d28d26cfc65d56f13 100644 (file)
@@ -1,42 +1,92 @@
 #!/bin/sh
-# DHCP Server
+# DHCP relay agent
 #
-# chkconfig: 345 80 20
-# description: DHCP Relay
+# chkconfig:   345 80 20
+# description: DHCP relay agent
 
 # Source function library.
 . /etc/rc.d/init.d/functions
 
-if [ -f /etc/sysconfig/dhcrelay ]; then
-       . /etc/sysconfig/dhcrelay
+# Source networking configuration.
+. /etc/sysconfig/network
+
+# Demon specified configuration.
+OPTIONS=""
+. /etc/sysconfig/dhcp-relay
+
+# 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 "DHCP realay"
+               exit 1
+       fi
 else
        exit 0
 fi
 
+if [ -n "DHCP_RELAY_INTERFACES" ]; then
+       for iface in $DHCP_RELAY_INTERFACES ; do
+               OPTIONS="$OPTIONS -i $iface"
+       done
+fi
+
+start() {
+       if [ ! -f /var/lock/subsys/dhcp-relay ]; then
+               msg_starting "DHCP relay"
+               daemon dhcrelay $OPTIONS $DHCP_SERVERS_IP
+               RETVAL=$?
+               [ $RETVAL -eq 0 ] && touch /var/lock/subsys/dhcp-relay
+       else
+               msg_already_running "DHCP relay"
+       fi
+}
+
+stop() {
+       if [ -f /var/lock/subsys/dhcp-relay ]; then
+               msg_stopping "DHCP relay"
+               killproc dhcrelay
+               rm -f /var/lock/subsys/dhcp-relay
+       else
+               msg_not_running "DHCP relay"
+       fi
+}
 
+condrestart() {
+       if [ -f /var/lock/subsys/dhcp-relay ]; then
+               stop
+               start
+       else
+               msg_not_running "DHCP relay"
+               RETVAL=$1
+       fi
+}
+
+RETVAL=0
 # See how we were called.
 case "$1" in
   start)
-       show Starting DHCP Relay
-       daemon dhcrelay $DHCP_SERVERS
-       touch /var/lock/subsys/dhcrelay
+       start
        ;;
   stop)
-       show Stopping DHCP Relay
-       killproc dhrelay
-       rm -f /var/lock/subsys/dhcrelay
+       stop
        ;;
   restart)
-       $0 stop
-       $0 start
+       stop
+       start
+       ;;
+  try-restart)
+       condrestart 0
+       ;;
+  force-reload)
+       condrestart 7
        ;;
   status)
-       status dhcpd
+       status dhcrelay
+       exit $?
        ;;
   *)
-       echo "Usage: $0 {start|stop|restart|status}"
-       exit 1
+       msg_usage "$0 {start|stop|restart|try-restart|force-reload|status}"
+       exit 3
 esac
 
-exit 0
-
+exit $RETVAL
This page took 0.121264 seconds and 4 git commands to generate.