]> git.pld-linux.org Git - packages/dhcp.git/blob - dhcp.init
- enable timeouts even if not debugging
[packages/dhcp.git] / dhcp.init
1 #!/bin/sh
2 # DHCP Server
3 #
4 # chkconfig:    345 80 20
5 # description:  DHCP Server
6
7 # Source function library
8 . /etc/rc.d/init.d/functions
9
10 # Get network config
11 . /etc/sysconfig/network
12
13 # Get service config
14 [ -f /etc/sysconfig/dhcpd ] && . /etc/sysconfig/dhcpd
15
16 # Check that networking is up.
17 if is_yes "${NETWORKING}"; then
18         if [ ! -f /var/lock/subsys/network -a "$1" != stop -a "$1" != status ]; then
19                 msg_network_down "DHCP Server"
20                 exit 1
21         fi
22 else
23         exit 0
24 fi
25
26 checkconfig() {
27         show "Checking %s configuration" "DHCP Server"
28         out=`/usr/sbin/dhcpd -t 2>&1`; rc=$?
29         if [ $rc -gt 0 ]; then
30                 fail
31                 echo >&2 "$out"
32         else
33                 ok
34         fi
35         return $rc
36 }
37
38 start() {
39         # Check if the service is already running?
40         if [ ! -f /var/lock/subsys/dhcpd ]; then
41                 msg_starting "DHCP Server"
42                 daemon dhcpd $DHCPD_INTERFACES
43                 RETVAL=$?
44                 [ $RETVAL -eq 0 ] && touch /var/lock/subsys/dhcpd
45         else
46                 msg_already_running "DHCP Server"
47         fi
48 }
49
50 stop() {
51         if [ -f /var/lock/subsys/dhcpd ]; then
52                 msg_stopping "DHCP Server"
53                 killproc dhcpd
54                 rm -f /var/run/dhcpd.pid /var/lock/subsys/dhcpd >/dev/null 2>&1
55         else
56                 msg_not_running "DHCP Server"
57         fi
58 }
59
60 RETVAL=0
61 # See how we were called.
62 case "$1" in
63   start)
64         checkconfig || exit 1
65         start
66         ;;
67   stop)
68         stop
69         ;;
70   restart)
71         checkconfig || exit 1
72         stop
73         start
74         ;;
75   checkconfig)
76         checkconfig
77         ;;
78   status)
79         status dhcpd
80         exit $?
81         ;;
82   *)
83         msg_usage "$0 {start|stop|restart|checkconfig|status}"
84         exit 3
85 esac
86
87 exit $RETVAL
This page took 0.040784 seconds and 3 git commands to generate.