db449ef
#!/bin/bash
db449ef
# dhclient-script for Linux. Dan Halbert, March, 1997.
db449ef
# Updated for Linux 2.[12] by Brian J. Murrell, January 1999.
db449ef
# No guarantees about this. I'm a novice at the details of Linux
db449ef
# networking.
db449ef
#
db449ef
# Modified by David Cantrell <dcantrell@redhat.com> for Fedora and RHEL
db449ef
db449ef
# Notes:
db449ef
db449ef
# 0. This script is based on the netbsd script supplied with dhcp-970306.
db449ef
db449ef
# 1. ifconfig down apparently deletes all relevant routes and flushes
db449ef
# the arp cache, so this doesn't need to be done explicitly.
db449ef
db449ef
# 2. The alias address handling here has not been tested AT ALL.
db449ef
# I'm just going by the doc of modern Linux ip aliasing, which uses
db449ef
# notations like eth0:0, eth0:1, for each alias.
db449ef
db449ef
# 3. I have to calculate the network address, and calculate the broadcast
db449ef
# address if it is not supplied. This might be much more easily done
db449ef
# by the dhclient C code, and passed on.
db449ef
db449ef
PATH=/bin:/usr/bin
db449ef
db449ef
function save_previous() {
db449ef
    if [ -e $1 ]; then
3aac9e5
        mv $1 $1.predhclient.$interface
db449ef
    else
3aac9e5
        echo ''> $1.predhclient.$interface
db449ef
    fi
db449ef
}
db449ef
db449ef
make_resolv_conf() {
db449ef
    if [ "${PEERDNS}" == "no" ]; then
db449ef
        return
db449ef
    fi
db449ef
db449ef
    if [ x$reason == xRENEW ] &&
db449ef
       [ "$new_domain_name" == "$old_domain_name" ] && 
db449ef
       [ "$new_domain_name_servers" == "$old_domain_name_servers" ]; then
db449ef
        return
db449ef
    fi
db449ef
db449ef
    if [ -n "$new_domain_name" ] || [ -n "$new_domain_name_servers" ]; then
3aac9e5
        cp -fp /etc/resolv.conf /etc/resolv.conf.predhclient.$interface
db449ef
        rscf=`mktemp /tmp/XXXXXX`;
db449ef
        echo '; generated by /sbin/dhclient-script' > $rscf
db449ef
ee10463
        if [ -n "$new_domain_search" ]; then
821e00d
            echo "search ${new_domain_search//\\032/ }" >> $rscf
db449ef
        else
db449ef
            if [ -n "$new_domain_name" ]; then
821e00d
                echo "search ${new_domain_name//\\032/ }" >> $rscf
db449ef
            fi
db449ef
        fi
db449ef
db449ef
        for nameserver in $new_domain_name_servers; do
db449ef
            echo nameserver $nameserver >> $rscf
db449ef
        done
db449ef
db449ef
        change_resolv_conf $rscf
db449ef
        rm -f $rscf
db449ef
    fi
db449ef
}
db449ef
db449ef
# Must be used on exit.   Invokes the local dhcp client exit hooks, if any.
db449ef
exit_with_hooks() {
db449ef
    exit_status=$1
db449ef
db449ef
    if [ -f /etc/dhclient-exit-hooks ]; then
db449ef
        . /etc/dhclient-exit-hooks
db449ef
    fi
db449ef
db449ef
    # probably should do something with exit status of the local script
db449ef
    exit $exit_status
db449ef
}
db449ef
db449ef
# Invoke the local dhcp client enter hooks, if they exist.
db449ef
if [ -f /etc/dhclient-enter-hooks ]; then
db449ef
    exit_status=0
db449ef
    . /etc/dhclient-enter-hooks
db449ef
    # allow the local script to abort processing of this state
db449ef
    # local script must set exit_status variable to nonzero.
db449ef
    if [ $exit_status -ne 0 ]; then
db449ef
        exit $exit_status
db449ef
    fi
db449ef
fi
db449ef
db449ef
# Import Red Hat Linux configuration
db449ef
cd /etc/sysconfig/network-scripts;
db449ef
. /etc/sysconfig/network-scripts/network-functions
db449ef
. /etc/rc.d/init.d/functions
db449ef
db449ef
[ -f ../network ] && . ../network
db449ef
[ -f ../networking/network ] && . ../networking/network
db449ef
db449ef
CONFIG=$interface
db449ef
db449ef
need_config ${CONFIG}
db449ef
db449ef
if [ -f "${CONFIG}" ]; then 
db449ef
    source_config
db449ef
else
db449ef
    echo $"$0: configuration for $interface not found. Continuing with defaults." >&2
db449ef
fi
db449ef
db449ef
source_config
db449ef
db449ef
release=$(uname -r)
db449ef
relmajor=$(echo $release | cut -f1 -d'.')
db449ef
relminor=$(echo $release | cut -f2 -d'.')
db449ef
db449ef
# simple IP arithmetic functions:
db449ef
function quad2num() {
db449ef
    if [ $# -eq 4 ]; then
db449ef
        let n="$1<<24|$2<<16|$3<<8|$4"
db449ef
        echo $n
db449ef
        return 0
db449ef
    fi
db449ef
    echo '0'
db449ef
    return 1
db449ef
}
db449ef
db449ef
function ip2num() {
db449ef
    IFS='.' quad2num $1
db449ef
}
db449ef
db449ef
function num2ip() {
db449ef
    let n="$1"
db449ef
    let o1='(n>>24)&0xff'
db449ef
    let o2='(n>>16)&0xff'
db449ef
    let o3='(n>>8)&0xff'
db449ef
    let o4='n & 0xff'
db449ef
    echo $o1.$o2.$o3.$o4
db449ef
}
db449ef
db449ef
function mask() {
db449ef
    ip=$1
db449ef
    m=$2
db449ef
    let ip=$(IFS='.' ip2num $ip)
db449ef
    let m=$(IFS='.' ip2num $m)
db449ef
    let n='ip&m'
db449ef
    num2ip $n
db449ef
}
db449ef
db449ef
function mask_bits() {
db449ef
    ip=$1
db449ef
    let ip=$(IFS='.' ip2num $ip)
db449ef
    let bits=0
db449ef
    for ((bit=1; '((ip&bit)==0) && (bits < 32)'; 'bit<<=1')) do
db449ef
        let bits+=1
db449ef
    done
db449ef
    let n_bits=32-bits
db449ef
    echo $n_bits
db449ef
}
db449ef
db449ef
function class_bits() {
db449ef
    let ip=$(IFS='.' ip2num $1)
db449ef
    let bits=32
db449ef
    let mask='255'
db449ef
    for ((i=0; i <= 3; i++, 'mask<<=8')); do
db449ef
        let v='ip&mask'
db449ef
        if [ "$v" -eq 0 ] ; then
db449ef
             let bits-=8
db449ef
        else
db449ef
             break
db449ef
        fi
db449ef
    done
db449ef
    echo $bits
db449ef
}
db449ef
db449ef
function routerReachable() {
db449ef
    # Handle silly DHCP servers that give us a router not on our subnet:
db449ef
    router=$1
db449ef
    routerSubnet=$(mask $router $new_subnet_mask)
db449ef
    mySubnet=$(mask $new_ip_address $new_subnet_mask)
db449ef
    unreachable=0
db449ef
    if [ "$routerSubnet" != "$mySubnet" ]; then
db449ef
        unreachable=1
db449ef
        if /sbin/arping -f -q -I $interface -w2 $router; then
db449ef
             /sbin/ip route add ${router}/32 dev $interface
db449ef
             if [ $? -eq 0 ]; then
db449ef
                 unreachable=0
db449ef
             else
db449ef
                 /usr/bin/logger -p local7.notice -t "NET"  "dhclient: failed to create host route for unreachable router $router not on subnet $mySubnet";
db449ef
             fi
db449ef
        else
db449ef
             unreachable=1
db449ef
             if [ -x /usr/bin/logger ]; then
db449ef
                 /usr/bin/logger -p local7.notice -t "NET"  "dhclient: DHCP router $router is unreachable on DHCP subnet $mySubnet router subnet $routerSubnet";
db449ef
             fi
db449ef
        fi
db449ef
    fi
db449ef
    return $unreachable
db449ef
}
db449ef
db449ef
function add_default_gateway() {
db449ef
    router=$1
db449ef
    metric=''
db449ef
    if [ $# -gt 1 ] && [ "$2" -gt 0 ]; then
db449ef
        metric="metric $2"
db449ef
    fi
db449ef
    if routerReachable $router ; then
db449ef
        /sbin/ip route replace default via $router dev $interface $metric
db449ef
        if [ $? -ne 0 ]; then
db449ef
            /usr/bin/logger -p local7.notice -t "NET"  'dhclient: failed to create default route: '$router dev $interface $metric
db449ef
            return 1
db449ef
        else
db449ef
            return 0
db449ef
        fi
db449ef
    fi
db449ef
    return 1
db449ef
}
db449ef
db449ef
function dhconfig() {
db449ef
    if [ x$old_ip_address != x ] && [ x$alias_ip_address != x ] && [ x$alias_ip_address != x$old_ip_address ]; then
db449ef
        # Possible new alias. Remove old alias.
db449ef
        ifconfig $interface:0- inet 0
db449ef
    fi
db449ef
db449ef
    if [ x$old_ip_address != x ] && [ x$old_ip_address != x$new_ip_address ]; then
db449ef
        # IP address changed. Bringing down the interface will delete all
db449ef
        # routes, and clear the ARP cache.
db449ef
        ifconfig $interface inet 0 down
db449ef
    fi
db449ef
db449ef
    if [ x$reason = xBOUND ] || [ x$reason = xREBOOT ] ||
db449ef
       [ x$old_ip_address  != x$new_ip_address ] ||
db449ef
       [ x$old_subnet_mask != x$new_subnet_mask ] ||
db449ef
       [ x$new_network_number != x$new_network_number ] ||
db449ef
       [ x$old_broadcast_address != x$new_broadcast_address ] ||
db449ef
       [ "x$old_routers" != "x$new_routers" ] ||
db449ef
       [ x$old_interface_mtu != x$new_interface_mtu ] ; then
db449ef
        ifconfig $interface inet $new_ip_address $new_subnet_arg $new_broadcast_arg
db449ef
        if [ -n "$new_interface_mtu" ]; then
db449ef
            /sbin/ip link set $interface mtu $new_interface_mtu
db449ef
        fi
db449ef
db449ef
        if [ -x /etc/dhclient-${interface}-up-hooks ]; then
db449ef
            . /etc/dhclient-${interface}-up-hooks
db449ef
        elif [ -x /etc/dhclient-up-hooks ]; then
db449ef
            . /etc/dhclient-up-hooks
db449ef
        fi
db449ef
db449ef
        prefix_bits=$(mask_bits $new_subnet_mask)
db449ef
        # Add a network route to the computed network address.
db449ef
        if [ $relmajor -lt 2 ] || ( [ $relmajor -eq 2 ] && [ $relminor -eq 0 ] ); then
db449ef
            /sbin/ip route replace ${new_network_number}/${prefix_bits} dev $interface
db449ef
            if [ $added_old_broadcast_route -eq 1 ]; then
db449ef
                /sbin/ip route del default
db449ef
            fi
db449ef
        fi
db449ef
db449ef
        if [[ (( -z "$GATEWAYDEV" ) || ( "$GATEWAYDEV" = "$interface" )) && (( -z "$GATEWAY" ) || (( -n "$DHCLIENT_IGNORE_GATEWAY" ) && ( "$DHCLIENT_IGNORE_GATEWAY" = [Yy]* ))) ]]; then
db449ef
            metric=${METRIC:-''}
db449ef
            let i=${METRIC:-0}
db449ef
            default_routers=()
db449ef
db449ef
            for router in $new_routers; do
db449ef
                added_router=0
db449ef
db449ef
                for r in ${default_routers[@]}; do
db449ef
                    if [ "$r" == "$router" ]; then
db449ef
                        added_router=1
db449ef
                    fi
db449ef
                done
db449ef
db449ef
                if [ -z "$router" ] || [ "$added_router" -eq 1 ] || [ $(IFS=. ip2num $router) -le 0 ] || [[ ( "$router" = "$new_broadcast_address" ) && ( "$new_subnet_mask" != "255.255.255.255" ) ]]; then
db449ef
                    continue
db449ef
                fi
db449ef
db449ef
                default_routers=(${default_routers[@]} $router)
db449ef
                add_default_gateway $router $metric
db449ef
                let i=i+1
db449ef
                metric=$i
db449ef
            done
db449ef
        elif [[ (( -z "$GATEWAYDEV" ) || ( "$GATEWAYDEV" = "$interface" )) && ( -n "$GATEWAY" ) ]]; then
db449ef
            routerSubnet=$(mask $GATEWAY $new_subnet_mask)
db449ef
            mySubnet=$(mask $new_ip_address $new_subnet_mask)
db449ef
db449ef
            if [ "$routerSubnet" = "$mySubnet" ]; then
db449ef
                /sbin/ip route replace default via $GATEWAY dev $interface
db449ef
            fi
db449ef
        fi
db449ef
db449ef
        # static routes
db449ef
        if [ "x$new_static_routes" != x ]; then
db449ef
            IFS=', 	' static_routes=($new_static_routes)
db449ef
            route_targets=()
db449ef
db449ef
            for((i=0; i<${#static_routes[@]}; i+=2)); do
db449ef
                target=${static_routes[$i]}
db449ef
                gateway=${static_routes[$i+1]}
db449ef
                metric=''
db449ef
db449ef
                for t in ${route_targets[@]}; do
db449ef
                    if [ $t == $target ]; then
db449ef
                        if [ -z "$metric" ]; then
db449ef
                            metric=1
db449ef
                        else
db449ef
                            ((metric=metric+1))
db449ef
                        fi
db449ef
                    fi
db449ef
                done
db449ef
db449ef
                if [ -n "$metric" ]; then
db449ef
                    metric="metric $metric"
db449ef
                fi
db449ef
db449ef
                if routerReachable $gateway; then
db449ef
                    /sbin/ip route replace ${target}/$(class_bits $target) via ${gateway} dev $interface ${metric}
db449ef
db449ef
                    if [ $? -ne 0 ]; then
db449ef
                        /usr/bin/logger -p local7.notice -t 'NET' 'dhclient: failed to create static route:' ${target}/`class_bits $target` via ${gateway} dev $interface ${metric}
db449ef
                    else
db449ef
                        route_targets=(${route_targets[@]} $target)
db449ef
                    fi
db449ef
                fi
db449ef
            done
db449ef
        fi
db449ef
    fi
db449ef
db449ef
    if [ x$new_ip_address != x$alias_ip_address ] && [ x$alias_ip_address != x ]; then
db449ef
        ifconfig $interface:0- inet 0
db449ef
        ifconfig $interface:0 inet $alias_ip_address $alias_subnet_arg
db449ef
        /sbin/ip route replace ${alias_ip_address}/32 dev $interface:0
db449ef
    fi
db449ef
db449ef
    make_resolv_conf
db449ef
db449ef
    if [ -n "$new_host_name" ] && need_hostname; then
db449ef
        hostname $new_host_name
db449ef
    fi
db449ef
db449ef
    if [ "${PEERNIS}" = no ]; then
db449ef
        :
db449ef
    elif [ -n "$new_nis_domain" ]; then
db449ef
        domainname "$new_nis_domain"
db449ef
        save_previous /etc/yp.conf
db449ef
        let contents=0
db449ef
        echo '# generated by /sbin/dhclient-script' > /etc/yp.conf
db449ef
db449ef
        if [ -n "$new_nis_servers" ]; then
db449ef
            for I in $new_nis_servers; do
db449ef
                echo "domain $new_nis_domain server $I" >> /etc/yp.conf
db449ef
                let contents=contents+1
db449ef
            done
db449ef
        else
db449ef
            echo "domain $new_nis_domain broadcast" >> /etc/yp.conf
db449ef
            let contents=contents+1
db449ef
        fi
db449ef
db449ef
        if [ $contents -gt 0 ] && [ -r /var/run/ypbind.pid ] && yppid=$(cat /var/run/ypbind.pid) && [ -d /proc/${yppid} ] && [ "$(if [ -x /usr/bin/readlink ]; then readlink /proc/${yppid}/exe; else echo /sbin/ypbind; fi)" = "/sbin/ypbind" ]; then
db449ef
            kill -HUP $yppid
db449ef
        fi
db449ef
    elif [ -n "$new_nis_servers" ]; then
db449ef
        save_previous /etc/yp.conf
db449ef
        echo '# generated by /sbin/dhclient-script' > /etc/yp.conf
db449ef
        let contents=0
db449ef
db449ef
        for I in $new_nis_servers; do
db449ef
            echo "ypserver $I" >> /etc/yp.conf
db449ef
            let contents=contents+1
db449ef
        done
db449ef
db449ef
        if [ $contents -gt 0 ] && [ -r /var/run/ypbind.pid ] && yppid=$(cat /var/run/ypbind.pid) && [ -d /proc/${yppid} ] && [ "$(if [ -x /usr/bin/readlink ]; then readlink /proc/${yppid}/exe; else echo /sbin/ypbind; fi)" = "/sbin/ypbind" ]; then
db449ef
            kill -HUP $yppid
db449ef
        fi
db449ef
    fi
db449ef
db449ef
    if [ -n "$DHCP_TIME_OFFSET_SETS_TIMEZONE" ] && [[ "$DHCP_TIME_OFFSET_SETS_TIMEZONE" = [yY1]* ]]; then
db449ef
        if [ -n "$new_time_offset" ]; then
db449ef
            # DHCP option "time-offset" is requested by default and should be
db449ef
            # handled.  The geographical zone abbreviation cannot be determined
db449ef
            # from the GMT offset, but the $ZONEINFO/Etc/GMT$offset file can be
db449ef
            # used - note: this disables DST.
db449ef
            ((z=new_time_offset/3600))
db449ef
            ((hoursWest=$(printf '%+d' $z)))
db449ef
db449ef
            if (( $hoursWest < 0 )); then
db449ef
                # tzdata treats negative 'hours west' as positive 'gmtoff'!
db449ef
                ((hoursWest*=-1))
db449ef
            fi
db449ef
db449ef
            tzfile=/usr/share/zoneinfo/Etc/GMT$(printf '%+d' $hoursWest)
db449ef
            if [ -e $tzfile ]; then
3aac9e5
                /bin/mv -f /etc/localtime /etc/localtime.predhclient.$interface
db449ef
                /bin/cp -fp $tzfile /etc/localtime
db449ef
                /bin/touch /etc/localtime
db449ef
            fi
db449ef
        fi
db449ef
    fi
db449ef
db449ef
    if [ "${PEERNTP}" = no ]; then
db449ef
        :
db449ef
    elif [ -n "$new_ntp_servers" ] && [ -e /etc/ntp.conf ]; then
db449ef
        save_previous /etc/ntp.conf
3aac9e5
        /bin/egrep -v '^server .*  # added by /sbin/dhclient-script$'< /etc/ntp.conf.predhclient.$interface > /etc/ntp.conf
db449ef
db449ef
        for s in $new_ntp_servers; do
db449ef
            echo "server $s  # added by /sbin/dhclient-script" >> /etc/ntp.conf
db449ef
        done
db449ef
3aac9e5
        if [ -x /usr/bin/diff ] && /usr/bin/diff -q /etc/ntp.conf /etc/ntp.conf.predhclient.$interface >/dev/null 2>&1; then
db449ef
            :
db449ef
        else
db449ef
            /sbin/service ntpd condrestart >/dev/null 2>&1
db449ef
        fi
db449ef
    fi
db449ef
}
db449ef
db449ef
if [ x$new_broadcast_address != x ] && [ x$new_subnet_mask != x ] && [ "$new_subnet_mask" != "255.255.255.255" ]; then
db449ef
    new_broadcast_arg="broadcast $new_broadcast_address"
db449ef
fi
db449ef
db449ef
if [ x$old_broadcast_address != x ]; then
db449ef
    old_broadcast_arg="broadcast $old_broadcast_address"
db449ef
fi
db449ef
db449ef
if [ x$new_subnet_mask != x ]; then
db449ef
    new_subnet_arg="netmask $new_subnet_mask"
db449ef
fi
db449ef
db449ef
if [ x$old_subnet_mask != x ]; then
db449ef
    old_subnet_arg="netmask $old_subnet_mask"
db449ef
fi
db449ef
db449ef
if [ x$alias_subnet_mask != x ]; then
db449ef
    alias_subnet_arg="netmask $alias_subnet_mask"
db449ef
fi
db449ef
db449ef
if [ x$reason = xMEDIUM ]; then
db449ef
    # Linux doesn't do mediums (ok, ok, media).
db449ef
    exit_with_hooks 0
db449ef
fi
db449ef
db449ef
added_old_broadcast_route=0
db449ef
if [ x$reason = xPREINIT ]; then
db449ef
    if [ x$alias_ip_address != x ]; then
db449ef
        # Bring down alias interface. Its routes will disappear too.
db449ef
        ifconfig $interface:0- inet 0
db449ef
    fi
db449ef
db449ef
    if [ x$keep_old_ip = xyes ]; then
db449ef
        ifconfig $interface up
db449ef
    elif [ $relmajor -lt 2 ] || ( [ $relmajor -eq 2 ] && [ $relminor -eq 0 ] )   then
db449ef
        ifconfig $interface inet 0.0.0.0 netmask 0.0.0.0 broadcast 255.255.255.255 up
db449ef
        # Add route to make broadcast work. Do not omit netmask.
db449ef
        /sbin/ip route replace default dev $interface && added_old_broadcast_route=1
db449ef
    else
db449ef
        ifconfig $interface 0 up
db449ef
    fi
db449ef
db449ef
    # We need to give the kernel some time to get the interface up.
db449ef
    # sleep 1
db449ef
    # I don't think this is necessary with modern kernels - no problems found
db449ef
    # during testing - JVD, 2005-06-17
db449ef
    # but just in case:
db449ef
    if [ -n "$DHCLIENT_DELAY" ] && [ "$DHCLIENT_DELAY" -gt 0 ] ; then
db449ef
        sleep $DHCLIENT_DELAY
db449ef
    fi
db449ef
db449ef
    exit_with_hooks 0
db449ef
fi
db449ef
db449ef
if [ x$reason = xARPCHECK ] || [ x$reason = xARPSEND ]; then
db449ef
    if [ -z "$new_ip_address" ] || [ -z "$interface" ] ||  /sbin/arping -q -f -c 2 -w 3 -D -I ${interface} ${new_ip_address}; then
db449ef
        exit_with_hooks 0
db449ef
    else
db449ef
        exit_with_hooks 1
db449ef
    fi
db449ef
fi
db449ef
db449ef
if [ x$reason = xBOUND ] || [ x$reason = xRENEW ] || \
db449ef
   [ x$reason = xREBIND ] || [ x$reason = xREBOOT ]; then
db449ef
    dhconfig
db449ef
    exit_with_hooks 0
db449ef
fi
db449ef
db449ef
if [ x$reason = xEXPIRE ] || [ x$reason = xFAIL ] || [ x$reason = xRELEASE ] \
db449ef
   || [ x$reason = xSTOP ]; then
3aac9e5
    # only restore config files if there are no other dhclient processes
3aac9e5
    # running (#306381)
3aac9e5
    any_other_clients="$(/bin/ps -eo pid,ppid,comm | /bin/grep dhclient | /bin/grep -v $PPID)"
3aac9e5
    if [ -n "$any_other_clients" ]; then
3aac9e5
        if [ -f /etc/resolv.conf.predhclient.$interface ]; then
3aac9e5
            change_resolv_conf /etc/resolv.conf.predhclient.$interface
3aac9e5
            rm -f /etc/resolv.conf.predhclient.$interface
3aac9e5
        fi
db449ef
3aac9e5
        if [ -n "$DHCP_TIME_OFFSET_SETS_TIMEZONE" ] && [[ "$DHCP_TIME_OFFSET_SETS_TIMEZONE" = [yY1]* ]]; then
3aac9e5
            if [ -e /etc/localtime.predhclient.$interface ]; then
3aac9e5
                /bin/rm -f /etc/localtime
3aac9e5
                /bin/mv -f /etc/localtime.predhclient.$interface /etc/localtime
3aac9e5
                /bin/touch /etc/localtime
3aac9e5
            fi
db449ef
        fi
db449ef
3aac9e5
        if [ -f /etc/ntp.conf.predhclient.$interface ]; then
3aac9e5
            /bin/rm -f /etc/ntp.conf
3aac9e5
            /bin/mv -f /etc/ntp.conf.predhclient.$interface /etc/ntp.conf
3aac9e5
            service ntpd condrestart >/dev/null 2>&1
3aac9e5
        fi
db449ef
3aac9e5
        if [ -f /etc/yp.conf.predhclient.$interface ]; then
3aac9e5
            /bin/rm -f /etc/yp.conf
3aac9e5
            /bin/mv -f /etc/yp.conf.predhclient.$interface /etc/yp.conf
db449ef
3aac9e5
            if [ -r /var/run/ypbind.pid ] && yppid=$(cat /var/run/ypbind.pid) && [ -d /proc/${yppid} ] && [ "$(if [ -x /usr/bin/readlink ]; then readlink /proc/${yppid}/exe; else echo /sbin/ypbind; fi)" = "/sbin/ypbind" ]; then
3aac9e5
               kill -HUP $yppid
3aac9e5
            fi
db449ef
        fi
db449ef
    fi
db449ef
db449ef
    if [ -x /etc/dhclient-${interface}-down-hooks ]; then
db449ef
        . /etc/dhclient-${interface}-down-hooks
db449ef
    elif [ -x /etc/dhclient-down-hooks ]; then
db449ef
        . /etc/dhclient-down-hooks
db449ef
    fi
db449ef
db449ef
    if [ x$alias_ip_address != x ]; then
db449ef
        # Turn off alias interface.
db449ef
        ifconfig $interface:0- inet 0
db449ef
    fi
db449ef
db449ef
    if [ x$old_ip_address != x ]; then
db449ef
        # Shut down interface, which will delete routes and clear arp cache.
db449ef
        ifconfig $interface inet 0 down
db449ef
    fi
db449ef
db449ef
    if [ x$alias_ip_address != x ]; then
db449ef
        ifconfig $interface:0 inet $alias_ip_address $alias_subnet_arg
db449ef
        /sbin/ip route replace ${alias_ip_address}/32 $interface:0
db449ef
    fi
db449ef
db449ef
    exit_with_hooks 0
db449ef
fi
db449ef
db449ef
if [ x$reason = xTIMEOUT ] && [ "x$new_routers" != 'x' ]; then
db449ef
    if [ x$alias_ip_address != x ]; then
db449ef
        ifconfig $interface:0- inet 0
db449ef
    fi
db449ef
db449ef
    ifconfig $interface inet $new_ip_address $new_subnet_arg $new_broadcast_arg
db449ef
    set $new_routers
db449ef
db449ef
    if ping -q -c 1 -w 10 -I $interface $1; then
db449ef
        dhconfig
db449ef
        exit_with_hooks 0
db449ef
    fi
db449ef
db449ef
    if [ -z "${dhc_dbus}" ] || (( ( dhc_dbus & 2 ) != 2 )); then
db449ef
        ifconfig $interface inet 0 down
db449ef
    fi
db449ef
db449ef
    exit_with_hooks 1
db449ef
elif [ x$reason = xTIMEOUT ]; then
db449ef
    exit_with_hooks 1
db449ef
fi
db449ef
db449ef
exit_with_hooks 0