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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 138691 - (hide annotations) (download)
Mon Sep 5 09:17:05 2011 UTC (9 years, 10 months ago) by guillomovitch
File size: 3283 byte(s)
- sync init scripts with fedora (lsb headers, mostly)
- ship systemd service files

1 guillomovitch 138691 #!/bin/sh
2 dmorgan 16733 #
3     ### BEGIN INIT INFO
4     # Provides: dhcpd
5 guillomovitch 138691 # Default-Start:
6     # Default-Stop: 0 6
7     # Should-Start: ldap
8 dmorgan 16733 # Required-Start: $network
9     # Should-Stop: ldap
10 guillomovitch 138691 # Short-Description: Start and stop the DHCP server
11     # Description: dhcpd provides the Dynamic Host Configuration Protocol (DHCP)
12     # server.
13 dmorgan 16733 ### END INIT INFO
14 guillomovitch 138691 #
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 dmorgan 16733
25     . /etc/rc.d/init.d/functions
26    
27     [ -x /usr/sbin/dhcpd ] || exit 0
28    
29     # The following variables should be set in the file
30     # /etc/sysconfig/dhcpd.
31    
32     # Which configuration file to use.
33     CONFIGFILE="/etc/dhcpd.conf"
34     # Where to store the lease state information.
35     LEASEFILE="/var/lib/dhcp/dhcpd.leases"
36     # Define INTERFACES to limit which network interfaces dhcpd listens on.
37     # The default null value causes dhcpd to listen on all interfaces.
38     INTERFACES=""
39     # Define OPTIONS with any other options to pass to the dhcpd server.
40     OPTIONS="-q"
41    
42     # Source dhcpd configuration. Values specified in this file override
43     # the defaults above.
44     [ -f /etc/sysconfig/dhcpd ] && . /etc/sysconfig/dhcpd
45    
46     # If null values were specified, use defaults so we don't get a syntax
47     # error below.
48     [ "${CONFIGFILE}" = "" ] && CONFIGFILE="/etc/dhcpd.conf"
49     [ "${LEASEFILE}" = "" ] && LEASEFILE="/var/lib/dhcp/dhcpd.leases"
50    
51     [ -f $CONFIGFILE ] || exit 0
52     [ -f $LEASEFILE ] || exit 0
53    
54     RETVAL=0
55    
56     start() {
57 guillomovitch 138691 # Start daemons.
58     echo -n "Starting dhcpd: "
59     if [ -n "${ROOTDIR}" -a "x${ROOTDIR}" != "x/" ]; then
60     OPTIONS="${OPTIONS} -chroot ${ROOTDIR}"
61     fi
62     daemon /usr/sbin/dhcpd -cf $CONFIGFILE -lf $LEASEFILE $OPTIONS $INTERFACES
63     RETVAL=$?
64     echo
65     [ $RETVAL -eq 0 ] && touch /var/lock/subsys/dhcpd
66     return $RETVAL
67 dmorgan 16733 }
68    
69     stop() {
70 guillomovitch 138691 # Stop daemons.
71     echo -n "Shutting down dhcpd: "
72     if [ -r ${ROOTDIR}/var/run/dhcpd/dhcpd.pid ]; then
73     kill -TERM `cat ${ROOTDIR}/var/run/dhcpd/dhcpd.pid`
74     RETVAL=$?
75     [ "$RETVAL" = 0 ] && success "stop" || failure "stop"
76     else
77     success "already stopped"
78     RETVAL=0
79     fi
80 dmorgan 16733 [ $RETVAL -eq 0 ] && rm -f ${ROOTDIR}/var/run/dhcpd/dhcpd.pid
81 guillomovitch 138691 [ $RETVAL = 0 ] && rm -f /var/lock/subsys/dhcpd
82     echo
83     return $RETVAL
84 dmorgan 16733 }
85    
86 guillomovitch 138691 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 dmorgan 16733 # See how we were called.
98     case "$1" in
99 guillomovitch 138691 start)
100     start
101     ;;
102     stop)
103     stop
104     ;;
105     restart|reload)
106     stop
107     start
108     RETVAL=$?
109     ;;
110     condrestart)
111     if [ -f /var/lock/subsys/dhcpd ]; then
112     stop
113     start
114     RETVAL=$?
115     fi
116     ;;
117     configtest)
118     configtest
119     ;;
120     status)
121     status dhcpd
122     RETVAL=$?
123     ;;
124     *)
125     echo "Usage: dhcpd {start|stop|restart|condrestart|status}"
126     exit 1
127 dmorgan 16733 esac
128    
129     exit $RETVAL

  ViewVC Help
Powered by ViewVC 1.1.28