dhcpd/rc.dhcpd

changeset 606
c93d7930a2da
parent 605
04069b15fd9c
child 607
3f80fa12b972
     1.1 --- a/dhcpd/rc.dhcpd	Tue Aug 28 18:52:30 2012 +0200
     1.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.3 @@ -1,94 +0,0 @@
     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 -        if [ ! -f $dhcpd_pidfile ]; then return 1; fi
    1.25 -        kill -$1 `cat $dhcpd_pidfile`
    1.26 -    }
    1.27 -    dhcpd_start () {
    1.28 -        if [ ! -f $dhcpd_leases ]; then
    1.29 -            touch $dhcpd_leases
    1.30 -            chmod 644 $dhcpd_leases
    1.31 -            chown @l_susr@:@l_mgrp@ $dhcpd_leases
    1.32 -        fi
    1.33 -        local cmd="@l_prefix@/sbin/dhcpd"
    1.34 -        cmd="$cmd -f"
    1.35 -        cmd="$cmd $dhcpd_flags"
    1.36 -        echo ".$dhcpd_flags" | grep -- -p >/dev/null 2>&1
    1.37 -        if [ $? -ne 0 -a ".$dhcpd_port" != . ]; then
    1.38 -            cmd="$cmd -p $dhcpd_port"
    1.39 -        fi
    1.40 -        if [ $# -gt 0 ]; then
    1.41 -            cmd="$cmd $@"
    1.42 -        fi
    1.43 -        ( eval "nohup $cmd </dev/null >/dev/null 2>&1 &"
    1.44 -          echo $! >$dhcpd_pidfile
    1.45 -        ) >/dev/null 2>&1
    1.46 -    }
    1.47 -
    1.48 -%status -u @l_susr@ -o
    1.49 -    dhcpd_usable="unknown"
    1.50 -    dhcpd_active="no"
    1.51 -    @l_prefix@/sbin/dhcpd -q -t || dhcpd_usable="no"
    1.52 -    [ ".$dhcpd_if" = . ] && dhcpd_usable="no"
    1.53 -    rcService dhcpd enable yes && \
    1.54 -        dhcpd_signal 0 && dhcpd_active="yes"
    1.55 -    echo "dhcpd_enable=\"$dhcpd_enable\""
    1.56 -    echo "dhcpd_usable=\"$dhcpd_usable\""
    1.57 -    echo "dhcpd_active=\"$dhcpd_active\""
    1.58 -
    1.59 -%start -u @l_susr@
    1.60 -    rcService dhcpd enable yes || exit 0
    1.61 -    rcService dhcpd usable no  && exit 0
    1.62 -    rcService dhcpd active yes && exit 0
    1.63 -    dhcpd_start $dhcpd_if
    1.64 -
    1.65 -%stop -u @l_susr@
    1.66 -    rcService dhcpd enable yes || exit 0
    1.67 -    rcService dhcpd active no  && exit 0
    1.68 -    dhcpd_signal TERM
    1.69 -    sleep 2
    1.70 -    rm -f $dhcpd_pidfile 2>/dev/null || true
    1.71 -
    1.72 -%restart -u @l_susr@
    1.73 -    rcService dhcpd enable yes || exit 0
    1.74 -    rcService dhcpd active no  && exit 0
    1.75 -    rc dhcpd stop start
    1.76 -
    1.77 -%reload -u @l_susr@
    1.78 -    rcService dhcpd enable yes || exit 0
    1.79 -    dhcpd_signal HUP
    1.80 -
    1.81 -%daily -u @l_susr@
    1.82 -    rcService dhcpd enable yes || exit 0
    1.83 -    rcTmp -i
    1.84 -    hintfile=`rcTmp -f -n hint`
    1.85 -    for tool in dhcpd dhclient dhrelay omshell; do
    1.86 -        shtool rotate -f \
    1.87 -            -n $dhcpd_log_numfiles -s $dhcpd_log_minsize -d \
    1.88 -            -z $dhcpd_log_complevel -m 644 -o @l_susr@ -g @l_mgrp@ \
    1.89 -            -P "$dhcpd_log_prolog" \
    1.90 -            -E "$dhcpd_log_epilog; echo 1 >$hintfile" \
    1.91 -            @l_prefix@/var/dhcpd/log/$tool.log
    1.92 -    done
    1.93 -    if [ -s $hintfile ]; then
    1.94 -        rc dhcpd restart
    1.95 -    fi
    1.96 -    rcTmp -k
    1.97 -

mercurial