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