dhcpd/rc.dhcpd

Sat, 21 May 2011 22:05:42 +0200

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 21 May 2011 22:05:42 +0200
changeset 340
870131689a5c
child 354
4ca17af53013
permissions
-rw-r--r--

Correct diverse buildconf of upstream release and reconcile packaging somewhat.
These changes stem from the obvious changes in the latest vendor release, but
from discussions with trolls Daniel and Oswald as well regarding build config.

This commital follows conclusion of buildconf adjustments to allow the new
vendor version to build on Linux AMD64, but is incomplete as many packaging
comments show. The next series of changes focus on Solaris IA32 and reduction
of buildconf adjustments testing old problems comprehensively in anticipation
of discussion at the upcoming Nokia Contributor Summit in Berlin.

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

mercurial