michael@13: #!@l_prefix@/bin/openpkg rc michael@13: ## michael@13: ## rc.dhcpd -- Run-Commands michael@13: ## michael@13: michael@13: %config michael@13: dhcpd_enable="$openpkg_rc_def" michael@13: dhcpd_flags="-q" michael@13: dhcpd_if="" michael@13: dhcpd_port="67" michael@13: dhcpd_log_prolog="true" michael@13: dhcpd_log_epilog="true" michael@13: dhcpd_log_numfiles="10" michael@13: dhcpd_log_minsize="1M" michael@13: dhcpd_log_complevel="9" michael@13: michael@13: %common michael@13: dhcpd_pidfile="@l_prefix@/var/dhcpd/run/dhcpd.pid" michael@13: dhcpd_leases="@l_prefix@/var/dhcpd/db/dhcpd.leases" michael@13: dhcpd_signal () { michael@13: [ -f $dhcpd_pidfile ] && kill -$1 `cat $dhcpd_pidfile` michael@13: } michael@13: dhcpd_start () { michael@13: if [ ! -f $dhcpd_leases ]; then michael@13: touch $dhcpd_leases michael@13: chmod 644 $dhcpd_leases michael@13: chown @l_susr@:@l_mgrp@ $dhcpd_leases michael@13: fi michael@13: local cmd="@l_prefix@/sbin/dhcpd" michael@13: cmd="$cmd $dhcpd_flags" michael@13: echo ".$dhcpd_flags" | grep -- -p >/dev/null 2>&1 michael@13: if [ $? -ne 0 -a ".$dhcpd_port" != . ]; then michael@13: cmd="$cmd -p $dhcpd_port" michael@13: fi michael@13: if [ $# -gt 0 ]; then michael@13: cmd="$cmd $@" michael@13: fi michael@13: cmd="$cmd >/dev/null 2>&1" michael@13: eval $cmd michael@13: } michael@13: michael@13: %status -u @l_susr@ -o michael@13: dhcpd_usable="unknown" michael@13: dhcpd_active="no" michael@13: dhcpd_start -q -t || dhcpd_usable="no" michael@13: [ ".$dhcpd_if" = . ] && dhcpd_usable="no" michael@13: rcService dhcpd enable yes && \ michael@13: dhcpd_signal 0 && dhcpd_active="yes" michael@13: echo "dhcpd_enable=\"$dhcpd_enable\"" michael@13: echo "dhcpd_usable=\"$dhcpd_usable\"" michael@13: echo "dhcpd_active=\"$dhcpd_active\"" michael@13: michael@13: %start -u @l_susr@ michael@13: rcService dhcpd enable yes || exit 0 michael@13: rcService dhcpd usable no && exit 0 michael@13: rcService dhcpd active yes && exit 0 michael@13: dhcpd_start $dhcpd_if michael@13: michael@13: %stop -u @l_susr@ michael@13: rcService dhcpd enable yes || exit 0 michael@13: rcService dhcpd active no && exit 0 michael@13: dhcpd_signal TERM michael@13: sleep 2 michael@13: rm -f $dhcpd_pidfile 2>/dev/null || true michael@13: michael@13: %restart -u @l_susr@ michael@13: rcService dhcpd enable yes || exit 0 michael@13: rcService dhcpd active no && exit 0 michael@13: rc dhcpd stop start michael@13: michael@13: %reload -u @l_susr@ michael@13: rcService dhcpd enable yes || exit 0 michael@13: dhcpd_signal HUP michael@13: michael@13: %daily -u @l_susr@ michael@13: rcService dhcpd enable yes || exit 0 michael@13: rcTmp -i michael@13: hintfile=`rcTmp -f -n hint` michael@13: for tool in dhcpd dhclient dhrelay omshell; do michael@13: shtool rotate -f \ michael@13: -n $dhcpd_log_numfiles -s $dhcpd_log_minsize -d \ michael@13: -z $dhcpd_log_complevel -m 644 -o @l_susr@ -g @l_mgrp@ \ michael@13: -P "$dhcpd_log_prolog" \ michael@13: -E "$dhcpd_log_epilog; echo 1 >$hintfile" \ michael@13: @l_prefix@/var/dhcpd/log/$tool.log michael@13: done michael@13: if [ -s $hintfile ]; then michael@13: rc dhcpd restart michael@13: fi michael@13: rcTmp -k michael@13: