dhcpd/rc.dhcpd

Sun, 29 May 2011 16:29:06 +0200

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sun, 29 May 2011 16:29:06 +0200
changeset 344
e33c1efbd60f
child 354
4ca17af53013
permissions
-rw-r--r--

Update, correct, improve build configuration and packaging logic.
Update to new version of vendor software, bump copyright date, remove implicit
gcc dependency, add comments for Trolltech bug tracking, correct enforced
dynamic library linkage, and install mysterious process stub binary.

michael@13 1 #!@l_prefix@/bin/openpkg rc
michael@13 2 ##
michael@13 3 ## rc.dhcpd -- Run-Commands
michael@13 4 ##
michael@13 5
michael@13 6 %config
michael@13 7 dhcpd_enable="$openpkg_rc_def"
michael@13 8 dhcpd_flags="-q"
michael@13 9 dhcpd_if=""
michael@13 10 dhcpd_port="67"
michael@13 11 dhcpd_log_prolog="true"
michael@13 12 dhcpd_log_epilog="true"
michael@13 13 dhcpd_log_numfiles="10"
michael@13 14 dhcpd_log_minsize="1M"
michael@13 15 dhcpd_log_complevel="9"
michael@13 16
michael@13 17 %common
michael@13 18 dhcpd_pidfile="@l_prefix@/var/dhcpd/run/dhcpd.pid"
michael@13 19 dhcpd_leases="@l_prefix@/var/dhcpd/db/dhcpd.leases"
michael@13 20 dhcpd_signal () {
michael@13 21 [ -f $dhcpd_pidfile ] && kill -$1 `cat $dhcpd_pidfile`
michael@13 22 }
michael@13 23 dhcpd_start () {
michael@13 24 if [ ! -f $dhcpd_leases ]; then
michael@13 25 touch $dhcpd_leases
michael@13 26 chmod 644 $dhcpd_leases
michael@13 27 chown @l_susr@:@l_mgrp@ $dhcpd_leases
michael@13 28 fi
michael@13 29 local cmd="@l_prefix@/sbin/dhcpd"
michael@13 30 cmd="$cmd $dhcpd_flags"
michael@13 31 echo ".$dhcpd_flags" | grep -- -p >/dev/null 2>&1
michael@13 32 if [ $? -ne 0 -a ".$dhcpd_port" != . ]; then
michael@13 33 cmd="$cmd -p $dhcpd_port"
michael@13 34 fi
michael@13 35 if [ $# -gt 0 ]; then
michael@13 36 cmd="$cmd $@"
michael@13 37 fi
michael@13 38 cmd="$cmd >/dev/null 2>&1"
michael@13 39 eval $cmd
michael@13 40 }
michael@13 41
michael@13 42 %status -u @l_susr@ -o
michael@13 43 dhcpd_usable="unknown"
michael@13 44 dhcpd_active="no"
michael@13 45 dhcpd_start -q -t || dhcpd_usable="no"
michael@13 46 [ ".$dhcpd_if" = . ] && dhcpd_usable="no"
michael@13 47 rcService dhcpd enable yes && \
michael@13 48 dhcpd_signal 0 && dhcpd_active="yes"
michael@13 49 echo "dhcpd_enable=\"$dhcpd_enable\""
michael@13 50 echo "dhcpd_usable=\"$dhcpd_usable\""
michael@13 51 echo "dhcpd_active=\"$dhcpd_active\""
michael@13 52
michael@13 53 %start -u @l_susr@
michael@13 54 rcService dhcpd enable yes || exit 0
michael@13 55 rcService dhcpd usable no && exit 0
michael@13 56 rcService dhcpd active yes && exit 0
michael@13 57 dhcpd_start $dhcpd_if
michael@13 58
michael@13 59 %stop -u @l_susr@
michael@13 60 rcService dhcpd enable yes || exit 0
michael@13 61 rcService dhcpd active no && exit 0
michael@13 62 dhcpd_signal TERM
michael@13 63 sleep 2
michael@13 64 rm -f $dhcpd_pidfile 2>/dev/null || true
michael@13 65
michael@13 66 %restart -u @l_susr@
michael@13 67 rcService dhcpd enable yes || exit 0
michael@13 68 rcService dhcpd active no && exit 0
michael@13 69 rc dhcpd stop start
michael@13 70
michael@13 71 %reload -u @l_susr@
michael@13 72 rcService dhcpd enable yes || exit 0
michael@13 73 dhcpd_signal HUP
michael@13 74
michael@13 75 %daily -u @l_susr@
michael@13 76 rcService dhcpd enable yes || exit 0
michael@13 77 rcTmp -i
michael@13 78 hintfile=`rcTmp -f -n hint`
michael@13 79 for tool in dhcpd dhclient dhrelay omshell; do
michael@13 80 shtool rotate -f \
michael@13 81 -n $dhcpd_log_numfiles -s $dhcpd_log_minsize -d \
michael@13 82 -z $dhcpd_log_complevel -m 644 -o @l_susr@ -g @l_mgrp@ \
michael@13 83 -P "$dhcpd_log_prolog" \
michael@13 84 -E "$dhcpd_log_epilog; echo 1 >$hintfile" \
michael@13 85 @l_prefix@/var/dhcpd/log/$tool.log
michael@13 86 done
michael@13 87 if [ -s $hintfile ]; then
michael@13 88 rc dhcpd restart
michael@13 89 fi
michael@13 90 rcTmp -k
michael@13 91

mercurial