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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 16733 - (show annotations) (download)
Thu Jan 13 23:42:18 2011 UTC (10 years, 5 months ago) by dmorgan
File size: 2787 byte(s)
imported package dhcp
1 #!/bin/bash
2 #
3 # dhcpd This shell script takes care of starting and stopping
4 # dhcpd.
5 #
6 # chkconfig: 345 65 35
7 # description: dhcpd provides the Dynamic Host Configuration Protocol service.
8 #
9 # processname: dhcpd
10 # config: /etc/dhcpd.conf
11 # pidfile: /var/run/dhcpd/dhcpd.pid
12 #
13 ### BEGIN INIT INFO
14 # Provides: dhcpd
15 # Required-Start: $network
16 # Should-Start: ldap
17 # Required-Stop: $network
18 # Should-Stop: ldap
19 # Short-Description: The dhcpd daemon
20 # Description: dhcpd provides the Dynamic Host Configuration Protocol service.
21 ### END INIT INFO
22
23 # Source function library.
24 . /etc/rc.d/init.d/functions
25
26 # Source networking configuration.
27 . /etc/sysconfig/network
28
29 # Check that networking is up.
30 [ ${NETWORKING} = "no" ] && exit 0
31
32 [ -x /usr/sbin/dhcpd ] || exit 0
33
34 # The following variables should be set in the file
35 # /etc/sysconfig/dhcpd.
36
37 # Which configuration file to use.
38 CONFIGFILE="/etc/dhcpd.conf"
39 # Where to store the lease state information.
40 LEASEFILE="/var/lib/dhcp/dhcpd.leases"
41 # Define INTERFACES to limit which network interfaces dhcpd listens on.
42 # The default null value causes dhcpd to listen on all interfaces.
43 INTERFACES=""
44 # Define OPTIONS with any other options to pass to the dhcpd server.
45 OPTIONS="-q"
46
47 # Source dhcpd configuration. Values specified in this file override
48 # the defaults above.
49 [ -f /etc/sysconfig/dhcpd ] && . /etc/sysconfig/dhcpd
50
51 # If null values were specified, use defaults so we don't get a syntax
52 # error below.
53 [ "${CONFIGFILE}" = "" ] && CONFIGFILE="/etc/dhcpd.conf"
54 [ "${LEASEFILE}" = "" ] && LEASEFILE="/var/lib/dhcp/dhcpd.leases"
55
56 [ -f $CONFIGFILE ] || exit 0
57 [ -f $LEASEFILE ] || exit 0
58
59 RETVAL=0
60
61 start() {
62 # Start daemons.
63 echo -n "Starting dhcpd: "
64 if [ -n "${ROOTDIR}" -a "x${ROOTDIR}" != "x/" ]; then
65 OPTIONS="${OPTIONS} -chroot ${ROOTDIR}"
66 fi
67 daemon /usr/sbin/dhcpd -cf $CONFIGFILE -lf $LEASEFILE $OPTIONS $INTERFACES
68 RETVAL=$?
69 echo
70 [ $RETVAL -eq 0 ] && touch /var/lock/subsys/dhcpd
71 return $RETVAL
72 }
73
74 stop() {
75 # Stop daemons.
76 echo -n "Shutting down dhcpd: "
77 if [ -r ${ROOTDIR}/var/run/dhcpd/dhcpd.pid ]; then
78 kill -TERM `cat ${ROOTDIR}/var/run/dhcpd/dhcpd.pid`
79 RETVAL=$?
80 [ "$RETVAL" = 0 ] && success "stop" || failure "stop"
81 else
82 success "already stopped"
83 RETVAL=0
84 fi
85 [ $RETVAL -eq 0 ] && rm -f ${ROOTDIR}/var/run/dhcpd/dhcpd.pid
86 [ $RETVAL = 0 ] && rm -f /var/lock/subsys/dhcpd
87 echo
88 return $RETVAL
89 }
90
91 # See how we were called.
92 case "$1" in
93 start)
94 start
95 ;;
96 stop)
97 stop
98 ;;
99 restart|reload)
100 stop
101 start
102 RETVAL=$?
103 ;;
104 condrestart)
105 if [ -f /var/lock/subsys/dhcpd ]; then
106 stop
107 start
108 RETVAL=$?
109 fi
110 ;;
111 status)
112 status dhcpd
113 RETVAL=$?
114 ;;
115 *)
116 echo "Usage: dhcpd {start|stop|restart|condrestart|status}"
117 exit 1
118 esac
119
120 exit $RETVAL

  ViewVC Help
Powered by ViewVC 1.1.28