1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/dhcpd/rc.dhcpd Tue Jan 06 23:40:39 2009 +0100 1.3 @@ -0,0 +1,91 @@ 1.4 +#!@l_prefix@/bin/openpkg rc 1.5 +## 1.6 +## rc.dhcpd -- Run-Commands 1.7 +## 1.8 + 1.9 +%config 1.10 + dhcpd_enable="$openpkg_rc_def" 1.11 + dhcpd_flags="-q" 1.12 + dhcpd_if="" 1.13 + dhcpd_port="67" 1.14 + dhcpd_log_prolog="true" 1.15 + dhcpd_log_epilog="true" 1.16 + dhcpd_log_numfiles="10" 1.17 + dhcpd_log_minsize="1M" 1.18 + dhcpd_log_complevel="9" 1.19 + 1.20 +%common 1.21 + dhcpd_pidfile="@l_prefix@/var/dhcpd/run/dhcpd.pid" 1.22 + dhcpd_leases="@l_prefix@/var/dhcpd/db/dhcpd.leases" 1.23 + dhcpd_signal () { 1.24 + [ -f $dhcpd_pidfile ] && kill -$1 `cat $dhcpd_pidfile` 1.25 + } 1.26 + dhcpd_start () { 1.27 + if [ ! -f $dhcpd_leases ]; then 1.28 + touch $dhcpd_leases 1.29 + chmod 644 $dhcpd_leases 1.30 + chown @l_susr@:@l_mgrp@ $dhcpd_leases 1.31 + fi 1.32 + local cmd="@l_prefix@/sbin/dhcpd" 1.33 + cmd="$cmd $dhcpd_flags" 1.34 + echo ".$dhcpd_flags" | grep -- -p >/dev/null 2>&1 1.35 + if [ $? -ne 0 -a ".$dhcpd_port" != . ]; then 1.36 + cmd="$cmd -p $dhcpd_port" 1.37 + fi 1.38 + if [ $# -gt 0 ]; then 1.39 + cmd="$cmd $@" 1.40 + fi 1.41 + cmd="$cmd >/dev/null 2>&1" 1.42 + eval $cmd 1.43 + } 1.44 + 1.45 +%status -u @l_susr@ -o 1.46 + dhcpd_usable="unknown" 1.47 + dhcpd_active="no" 1.48 + dhcpd_start -q -t || dhcpd_usable="no" 1.49 + [ ".$dhcpd_if" = . ] && dhcpd_usable="no" 1.50 + rcService dhcpd enable yes && \ 1.51 + dhcpd_signal 0 && dhcpd_active="yes" 1.52 + echo "dhcpd_enable=\"$dhcpd_enable\"" 1.53 + echo "dhcpd_usable=\"$dhcpd_usable\"" 1.54 + echo "dhcpd_active=\"$dhcpd_active\"" 1.55 + 1.56 +%start -u @l_susr@ 1.57 + rcService dhcpd enable yes || exit 0 1.58 + rcService dhcpd usable no && exit 0 1.59 + rcService dhcpd active yes && exit 0 1.60 + dhcpd_start $dhcpd_if 1.61 + 1.62 +%stop -u @l_susr@ 1.63 + rcService dhcpd enable yes || exit 0 1.64 + rcService dhcpd active no && exit 0 1.65 + dhcpd_signal TERM 1.66 + sleep 2 1.67 + rm -f $dhcpd_pidfile 2>/dev/null || true 1.68 + 1.69 +%restart -u @l_susr@ 1.70 + rcService dhcpd enable yes || exit 0 1.71 + rcService dhcpd active no && exit 0 1.72 + rc dhcpd stop start 1.73 + 1.74 +%reload -u @l_susr@ 1.75 + rcService dhcpd enable yes || exit 0 1.76 + dhcpd_signal HUP 1.77 + 1.78 +%daily -u @l_susr@ 1.79 + rcService dhcpd enable yes || exit 0 1.80 + rcTmp -i 1.81 + hintfile=`rcTmp -f -n hint` 1.82 + for tool in dhcpd dhclient dhrelay omshell; do 1.83 + shtool rotate -f \ 1.84 + -n $dhcpd_log_numfiles -s $dhcpd_log_minsize -d \ 1.85 + -z $dhcpd_log_complevel -m 644 -o @l_susr@ -g @l_mgrp@ \ 1.86 + -P "$dhcpd_log_prolog" \ 1.87 + -E "$dhcpd_log_epilog; echo 1 >$hintfile" \ 1.88 + @l_prefix@/var/dhcpd/log/$tool.log 1.89 + done 1.90 + if [ -s $hintfile ]; then 1.91 + rc dhcpd restart 1.92 + fi 1.93 + rcTmp -k 1.94 +