/[packages]/cauldron/dhcp/current/SOURCES/dhcpd.init
ViewVC logotype

Diff of /cauldron/dhcp/current/SOURCES/dhcpd.init

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 138690 by tv, Tue Aug 30 07:02:43 2011 UTC revision 138691 by guillomovitch, Mon Sep 5 09:17:05 2011 UTC
# Line 1  Line 1 
1  #!/bin/bash  #!/bin/sh
 #  
 # dhcpd         This shell script takes care of starting and stopping  
 #               dhcpd.  
 #  
 # chkconfig: 345 65 35  
 # description: dhcpd provides the Dynamic Host Configuration Protocol service.  
 #  
 # processname: dhcpd  
 # config: /etc/dhcpd.conf  
 # pidfile: /var/run/dhcpd/dhcpd.pid  
2  #  #
3  ### BEGIN INIT INFO  ### BEGIN INIT INFO
4  # Provides: dhcpd  # Provides: dhcpd
5  # Required-Start: $network  # Default-Start:
 # Should-Start: ldap  
 # Required-Stop: $network  
6  # Default-Stop: 0 6  # Default-Stop: 0 6
7    # Should-Start: ldap
8    # Required-Start: $network
9  # Should-Stop: ldap  # Should-Stop: ldap
10  # Short-Description: The dhcpd daemon  # Short-Description: Start and stop the DHCP server
11  # Description: dhcpd provides the Dynamic Host Configuration Protocol service.  # Description: dhcpd provides the Dynamic Host Configuration Protocol (DHCP)
12    #              server.
13  ### END INIT INFO  ### END INIT INFO
14    #
15    # The fields below are left around for legacy tools (will remove later).
16    #
17    # chkconfig: - 65 35
18    # description: dhcpd provides the Dynamic Host Configuration Protocol (DHCP) \
19    #              server
20    # processname: dhcpd
21    # config: /etc/dhcp/dhcpd.conf
22    # config: /var/lib/dhcpd/dhcpd.leases
23    # pidfile: /var/run/dhcpd.pid
24    
 # Source function library.  
25  . /etc/rc.d/init.d/functions  . /etc/rc.d/init.d/functions
26    
 # Source networking configuration.  
 . /etc/sysconfig/network  
   
 # Check that networking is up.  
 [ ${NETWORKING} = "no" ] && exit 0  
   
27  [ -x /usr/sbin/dhcpd ] || exit 0  [ -x /usr/sbin/dhcpd ] || exit 0
28    
29  # The following variables should be set in the file  # The following variables should be set in the file
# Line 60  OPTIONS="-q" Line 54  OPTIONS="-q"
54  RETVAL=0  RETVAL=0
55    
56  start() {  start() {
57          # Start daemons.          # Start daemons.
58          echo -n "Starting dhcpd: "          echo -n "Starting dhcpd: "
59          if [ -n "${ROOTDIR}" -a "x${ROOTDIR}" != "x/" ]; then          if [ -n "${ROOTDIR}" -a "x${ROOTDIR}" != "x/" ]; then
60                  OPTIONS="${OPTIONS} -chroot ${ROOTDIR}"                  OPTIONS="${OPTIONS} -chroot ${ROOTDIR}"
61          fi          fi
62          daemon /usr/sbin/dhcpd -cf $CONFIGFILE -lf $LEASEFILE $OPTIONS $INTERFACES          daemon /usr/sbin/dhcpd -cf $CONFIGFILE -lf $LEASEFILE $OPTIONS $INTERFACES
63          RETVAL=$?          RETVAL=$?
64          echo          echo
65          [ $RETVAL -eq 0 ] && touch /var/lock/subsys/dhcpd          [ $RETVAL -eq 0 ] && touch /var/lock/subsys/dhcpd
66          return $RETVAL          return $RETVAL
67  }  }
68    
69  stop() {  stop() {
70          # Stop daemons.          # Stop daemons.
71          echo -n "Shutting down dhcpd: "          echo -n "Shutting down dhcpd: "
72          if [ -r ${ROOTDIR}/var/run/dhcpd/dhcpd.pid ]; then          if [ -r ${ROOTDIR}/var/run/dhcpd/dhcpd.pid ]; then
73              kill -TERM `cat ${ROOTDIR}/var/run/dhcpd/dhcpd.pid`              kill -TERM `cat ${ROOTDIR}/var/run/dhcpd/dhcpd.pid`
74              RETVAL=$?              RETVAL=$?
75              [ "$RETVAL" = 0 ] && success "stop" || failure "stop"              [ "$RETVAL" = 0 ] && success "stop" || failure "stop"
76          else          else
77              success "already stopped"              success "already stopped"
78              RETVAL=0              RETVAL=0
79          fi          fi
80          [ $RETVAL -eq 0 ] && rm -f ${ROOTDIR}/var/run/dhcpd/dhcpd.pid          [ $RETVAL -eq 0 ] && rm -f ${ROOTDIR}/var/run/dhcpd/dhcpd.pid
81          [ $RETVAL = 0 ] && rm -f /var/lock/subsys/dhcpd          [ $RETVAL = 0 ] && rm -f /var/lock/subsys/dhcpd
82          echo          echo
83          return $RETVAL          return $RETVAL
84    }
85    
86    configtest() {
87        /usr/sbin/dhcpd -q -t -cf $CONFIGFILE
88        RETVAL=$?
89        if [ $RETVAL -eq 1 ]; then
90            /usr/sbin/dhcpd -t -cf $CONFIGFILE
91        else
92            echo "Syntax: OK" >&2
93        fi
94        return $RETVAL
95  }  }
96    
97  # See how we were called.  # See how we were called.
98  case "$1" in  case "$1" in
99    start)      start)
100          start          start
101          ;;          ;;
102    stop)      stop)
103          stop          stop
104          ;;          ;;
105    restart|reload)      restart|reload)
106          stop          stop
107          start          start
108          RETVAL=$?          RETVAL=$?
109          ;;          ;;
110    condrestart)      condrestart)
111          if [ -f /var/lock/subsys/dhcpd ]; then          if [ -f /var/lock/subsys/dhcpd ]; then
112              stop              stop
113              start              start
114              RETVAL=$?              RETVAL=$?
115          fi          fi
116          ;;          ;;
117    status)      configtest)
118          status dhcpd          configtest
119          RETVAL=$?          ;;
120          ;;      status)
121    *)          status dhcpd
122          echo "Usage: dhcpd {start|stop|restart|condrestart|status}"          RETVAL=$?
123          exit 1          ;;
124        *)
125            echo "Usage: dhcpd {start|stop|restart|condrestart|status}"
126            exit 1
127  esac  esac
128    
129  exit $RETVAL  exit $RETVAL

Legend:
Removed from v.138690  
changed lines
  Added in v.138691

  ViewVC Help
Powered by ViewVC 1.1.28