dhcpd/rc.dhcpd

changeset 482
8c83aede6fbd
parent 13
cb59d6afeb61
equal deleted inserted replaced
0:51889f9ad780 1:2c61e623ccfc
16 16
17 %common 17 %common
18 dhcpd_pidfile="@l_prefix@/var/dhcpd/run/dhcpd.pid" 18 dhcpd_pidfile="@l_prefix@/var/dhcpd/run/dhcpd.pid"
19 dhcpd_leases="@l_prefix@/var/dhcpd/db/dhcpd.leases" 19 dhcpd_leases="@l_prefix@/var/dhcpd/db/dhcpd.leases"
20 dhcpd_signal () { 20 dhcpd_signal () {
21 [ -f $dhcpd_pidfile ] && kill -$1 `cat $dhcpd_pidfile` 21 if [ ! -f $dhcpd_pidfile ]; then return 1; fi
22 kill -$1 `cat $dhcpd_pidfile`
22 } 23 }
23 dhcpd_start () { 24 dhcpd_start () {
24 if [ ! -f $dhcpd_leases ]; then 25 if [ ! -f $dhcpd_leases ]; then
25 touch $dhcpd_leases 26 touch $dhcpd_leases
26 chmod 644 $dhcpd_leases 27 chmod 644 $dhcpd_leases
27 chown @l_susr@:@l_mgrp@ $dhcpd_leases 28 chown @l_susr@:@l_mgrp@ $dhcpd_leases
28 fi 29 fi
29 local cmd="@l_prefix@/sbin/dhcpd" 30 local cmd="@l_prefix@/sbin/dhcpd"
31 cmd="$cmd -f"
30 cmd="$cmd $dhcpd_flags" 32 cmd="$cmd $dhcpd_flags"
31 echo ".$dhcpd_flags" | grep -- -p >/dev/null 2>&1 33 echo ".$dhcpd_flags" | grep -- -p >/dev/null 2>&1
32 if [ $? -ne 0 -a ".$dhcpd_port" != . ]; then 34 if [ $? -ne 0 -a ".$dhcpd_port" != . ]; then
33 cmd="$cmd -p $dhcpd_port" 35 cmd="$cmd -p $dhcpd_port"
34 fi 36 fi
35 if [ $# -gt 0 ]; then 37 if [ $# -gt 0 ]; then
36 cmd="$cmd $@" 38 cmd="$cmd $@"
37 fi 39 fi
38 cmd="$cmd >/dev/null 2>&1" 40 ( eval "nohup $cmd </dev/null >/dev/null 2>&1 &"
39 eval $cmd 41 echo $! >$dhcpd_pidfile
42 ) >/dev/null 2>&1
40 } 43 }
41 44
42 %status -u @l_susr@ -o 45 %status -u @l_susr@ -o
43 dhcpd_usable="unknown" 46 dhcpd_usable="unknown"
44 dhcpd_active="no" 47 dhcpd_active="no"
45 dhcpd_start -q -t || dhcpd_usable="no" 48 @l_prefix@/sbin/dhcpd -q -t || dhcpd_usable="no"
46 [ ".$dhcpd_if" = . ] && dhcpd_usable="no" 49 [ ".$dhcpd_if" = . ] && dhcpd_usable="no"
47 rcService dhcpd enable yes && \ 50 rcService dhcpd enable yes && \
48 dhcpd_signal 0 && dhcpd_active="yes" 51 dhcpd_signal 0 && dhcpd_active="yes"
49 echo "dhcpd_enable=\"$dhcpd_enable\"" 52 echo "dhcpd_enable=\"$dhcpd_enable\""
50 echo "dhcpd_usable=\"$dhcpd_usable\"" 53 echo "dhcpd_usable=\"$dhcpd_usable\""

mercurial