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