wok-stable diff udhcpc6-fake/stuff/etc/dhclient-script @ rev 9507

Fix libwnck.
author Christopher Rogers <slaxemulator@gmail.com>
date Wed Apr 06 07:35:59 2011 +0000 (2011-04-06)
parents
children
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/udhcpc6-fake/stuff/etc/dhclient-script	Wed Apr 06 07:35:59 2011 +0000
     1.3 @@ -0,0 +1,266 @@
     1.4 +#!/bin/ash
     1.5 +
     1.6 +# dhclient-script for Linux. Dan Halbert, March, 1997.
     1.7 +# Updated for Linux 2.[12] by Brian J. Murrell, January 1999.
     1.8 +# Modified for Debian.  Matt Zimmerman and Eloy Paris, December 2003
     1.9 +# Modified to remove useless tests for antiquated kernel versions that
    1.10 +# this doesn't even work with anyway, and introduces a dependency on /usr
    1.11 +# being mounted, which causes cosmetic errors on hosts that NFS mount /usr
    1.12 +# Andrew Pollock, February 2005
    1.13 +# Modified to work on point-to-point links. Andrew Pollock, June 2005
    1.14 +# Modified to support passing the parameters called with to the hooks. Andrew Pollock, November 2005
    1.15 +
    1.16 +# The alias handling in here probably still sucks. -mdz
    1.17 +
    1.18 +make_resolv_conf() {
    1.19 +    if [ -n "$new_domain_name" -o -n "$new_domain_name_servers" ]; then
    1.20 +        # Find out whether we are going to mount / rw
    1.21 +        exec 9>&0 </etc/fstab
    1.22 +        rootmode=rw
    1.23 +        while read dev mnt type opts dump pass junk; do
    1.24 +            [ "$mnt" != / ] && continue
    1.25 +            case "$opts" in
    1.26 +                ro|ro,*|*,ro|*,ro,*)
    1.27 +                   rootmode=ro
    1.28 +                   ;;
    1.29 +                 esac
    1.30 +         done
    1.31 +         exec 0>&9 9>&-
    1.32 + 
    1.33 +        # Wait for /etc/resolv.conf to become writable
    1.34 +        if [ "$rootmode" = "rw" ]; then
    1.35 +            while [ ! -w /etc ]; do
    1.36 +                sleep 1
    1.37 +            done
    1.38 +        fi
    1.39 +
    1.40 +        local new_resolv_conf=/etc/resolv.conf.dhclient-new
    1.41 +        rm -f $new_resolv_conf
    1.42 +        if [ -n "$new_domain_name" ]; then
    1.43 +            echo search $new_domain_name >>$new_resolv_conf
    1.44 +        else # keep 'old' search/domain scope
    1.45 +            egrep -i '^ *[:space:]*(search|domain)' /etc/resolv.conf >> $new_resolv_conf
    1.46 +        fi
    1.47 +        if [ -n "$new_domain_name_servers" ]; then
    1.48 +                   for nameserver in $new_domain_name_servers; do
    1.49 +                       echo nameserver $nameserver >>$new_resolv_conf
    1.50 +            done
    1.51 +        else # keep 'old' nameservers
    1.52 +            sed -n /^\w*[Nn][Aa][Mm][Ee][Ss][Ee][Rr][Vv][Ee][Rr]/p /etc/resolv.conf >>$new_resolv_conf
    1.53 +        fi
    1.54 +        chown root.root $new_resolv_conf
    1.55 +        chmod 644 $new_resolv_conf
    1.56 +        mv -f $new_resolv_conf /etc/resolv.conf
    1.57 +    fi
    1.58 +}
    1.59 +
    1.60 +run_hook() {
    1.61 +    local script="$1"
    1.62 +    local exit_status
    1.63 +    shift	# discard the first argument, then the rest are the script's
    1.64 +
    1.65 +    if [ -f $script ]; then
    1.66 +        . $script "$@"
    1.67 +    fi
    1.68 +
    1.69 +
    1.70 +    if [ -n "$exit_status" ] && [ "$exit_status" -ne 0 ]; then
    1.71 +        logger -p daemon.err "$script returned non-zero exit status $exit_status"
    1.72 +        save_exit_status=$exit_status
    1.73 +    fi
    1.74 +
    1.75 +    return $exit_status
    1.76 +}
    1.77 +
    1.78 +run_hookdir() {
    1.79 +    local dir="$1"
    1.80 +    local exit_status
    1.81 +    shift	# See run_hook
    1.82 +
    1.83 +    if [ -d "$dir" ]; then
    1.84 +        for script in $(run-parts --list $dir); do
    1.85 +            run_hook $script "$@" || true
    1.86 +            exit_status=$?
    1.87 +        done
    1.88 +    fi
    1.89 +
    1.90 +    return $exit_status
    1.91 +}
    1.92 +
    1.93 +# Must be used on exit.   Invokes the local dhcp client exit hooks, if any.
    1.94 +exit_with_hooks() {
    1.95 +    exit_status=$1
    1.96 +
    1.97 +    # Source the documented exit-hook script, if it exists
    1.98 +    if ! run_hook /etc/dhcp3/dhclient-exit-hooks "$@"; then
    1.99 +        exit_status=$?
   1.100 +    fi
   1.101 +
   1.102 +    # Now run scripts in the Debian-specific directory.
   1.103 +    if ! run_hookdir /etc/dhcp3/dhclient-exit-hooks.d "$@"; then
   1.104 +        exit_status=$?
   1.105 +    fi
   1.106 +
   1.107 +    exit $exit_status
   1.108 +}
   1.109 +
   1.110 +set_hostname() {
   1.111 +    local current_hostname=$(hostname)
   1.112 +    if [ -z "$current_hostname" -o "$current_hostname" = "(none)" ]; then
   1.113 +        hostname "$new_host_name"
   1.114 +    fi
   1.115 +}
   1.116 +
   1.117 +if [ -n "$new_broadcast_address" ]; then
   1.118 +    new_broadcast_arg="broadcast $new_broadcast_address"
   1.119 +fi
   1.120 +if [ -n "$old_broadcast_address" ]; then
   1.121 +    old_broadcast_arg="broadcast $old_broadcast_address"
   1.122 +fi
   1.123 +if [ -n "$new_subnet_mask" ]; then
   1.124 +    new_subnet_arg="netmask $new_subnet_mask"
   1.125 +fi
   1.126 +if [ -n "$old_subnet_mask" ]; then
   1.127 +    old_subnet_arg="netmask $old_subnet_mask"
   1.128 +fi
   1.129 +if [ -n "$alias_subnet_mask" ]; then
   1.130 +    alias_subnet_arg="netmask $alias_subnet_mask"
   1.131 +fi
   1.132 +if [ -n "$new_interface_mtu" ] && [ $new_interface_mtu -ge 575 ]; then
   1.133 +    mtu_arg="mtu $new_interface_mtu"
   1.134 +fi
   1.135 +if [ -n "$IF_METRIC" ]; then
   1.136 +    metric_arg="metric $IF_METRIC"	# interfaces(5), "metric" option
   1.137 +fi
   1.138 +
   1.139 +
   1.140 +# The action starts here
   1.141 +
   1.142 +# Invoke the local dhcp client enter hooks, if they exist.
   1.143 +run_hook /etc/dhcp3/dhclient-enter-hooks
   1.144 +run_hookdir /etc/dhcp3/dhclient-enter-hooks.d
   1.145 +
   1.146 +# Execute the operation
   1.147 +case "$reason" in
   1.148 +    MEDIUM|ARPCHECK|ARPSEND)
   1.149 +        # Do nothing
   1.150 +        ;;
   1.151 +    PREINIT)
   1.152 +        # The DHCP client is requesting that an interface be
   1.153 +        # configured as required in order to send packets prior to
   1.154 +        # receiving an actual address. - dhclient-script(8)
   1.155 +
   1.156 +        if [ -n "$alias_ip_address" ]; then
   1.157 +            # Bring down alias interface. Its routes will disappear too.
   1.158 +            ifconfig $interface:0- inet 0
   1.159 +        fi
   1.160 +        ifconfig $interface inet 0 up
   1.161 +
   1.162 +        # We need to give the kernel some time to get the interface up.
   1.163 +        sleep 1
   1.164 +        ;;
   1.165 +    BOUND|RENEW|REBIND|REBOOT)
   1.166 +
   1.167 +        set_hostname
   1.168 +        
   1.169 +        if [ -n "$old_ip_address" -a -n "$alias_ip_address" -a \
   1.170 +             "$alias_ip_address" != "$old_ip_address" ]; then
   1.171 +            # Possible new alias. Remove old alias.
   1.172 +            ifconfig $interface:0- inet 0
   1.173 +        fi
   1.174 +
   1.175 +        if [ -n "$old_ip_address" -a \
   1.176 +             "$old_ip_address" != "$new_ip_address" ]; then
   1.177 +            # IP address changed. Bringing down the interface will delete all routes,
   1.178 +            # and clear the ARP cache.
   1.179 +            ifconfig $interface inet 0
   1.180 +
   1.181 +        fi
   1.182 +
   1.183 +        if [ -z "$old_ip_address" -o "$old_ip_address" != "$new_ip_address" -o \
   1.184 +            "$reason" = "BOUND" -o "$reason" = "REBOOT" ]; then
   1.185 +
   1.186 +            ifconfig $interface inet $new_ip_address $new_subnet_arg \
   1.187 +                $new_broadcast_arg $mtu_arg
   1.188 +
   1.189 +	    # point to point
   1.190 +	    if [ "$new_subnet_mask" == "255.255.255.255" ]; then
   1.191 +	    	for router in $new_routers; do
   1.192 +	    	    route add -host $router dev $interface
   1.193 +	    	done
   1.194 +	    fi
   1.195 +
   1.196 +            for router in $new_routers; do
   1.197 +                route add default dev $interface gw $router $metric_arg
   1.198 +            done
   1.199 +        fi
   1.200 +
   1.201 +        if [ "$new_ip_address" != "$alias_ip_address" -a -n "$alias_ip_address" ];
   1.202 +            then
   1.203 +            ifconfig $interface:0- inet 0
   1.204 +            ifconfig $interface:0 inet $alias_ip_address $alias_subnet_arg
   1.205 +            route add -host $alias_ip_address $interface:0
   1.206 +        fi
   1.207 +
   1.208 +        make_resolv_conf
   1.209 +
   1.210 +        ;;
   1.211 +
   1.212 +    EXPIRE|FAIL|RELEASE|STOP)
   1.213 +        if [ -n "$alias_ip_address" ]; then
   1.214 +            # Turn off alias interface.
   1.215 +            ifconfig $interface:0- inet 0
   1.216 +        fi
   1.217 +
   1.218 +        if [ -n "$old_ip_address" ]; then
   1.219 +            # Shut down interface, which will delete routes and clear arp cache.
   1.220 +            ifconfig $interface inet 0
   1.221 +        fi
   1.222 +
   1.223 +        if [ -n "$alias_ip_address" ]; then
   1.224 +            ifconfig $interface:0 inet $alias_ip_address $alias_subnet_arg
   1.225 +            route add -host $alias_ip_address $interface:0
   1.226 +        fi
   1.227 +
   1.228 +        ;;
   1.229 +
   1.230 +    TIMEOUT)
   1.231 +        if [ -n "$alias_ip_address" ]; then
   1.232 +            ifconfig $interface:0- inet 0
   1.233 +        fi
   1.234 +
   1.235 +        ifconfig $interface inet $new_ip_address $new_subnet_arg \
   1.236 +            $new_broadcast_arg $mtu_arg
   1.237 +
   1.238 +        set -- $new_routers
   1.239 +        first_router="$1"
   1.240 +
   1.241 +        if ping -q -c 1 $first_router; then
   1.242 +            if [ "$new_ip_address" != "$alias_ip_address" -a \
   1.243 +                -n "$alias_ip_address" ]; then
   1.244 +                ifconfig $interface:0 inet $alias_ip_address $alias_subnet_arg
   1.245 +                route add -host $alias_ip_address dev $interface:0
   1.246 +            fi
   1.247 +	    
   1.248 +	    # point to point
   1.249 +	    if [ "$new_subnet_mask" == "255.255.255.255" ]; then
   1.250 +	    	for router in $new_routers; do
   1.251 +	    	    route add -host $router dev $interface
   1.252 +	    	done
   1.253 +	    fi
   1.254 +
   1.255 +            for router in $new_routers; do
   1.256 +                route add default dev $interface gw $router $metric_arg
   1.257 +            done
   1.258 +
   1.259 +            make_resolv_conf
   1.260 +        else
   1.261 +            # Changed from 'ifconfig $interface inet 0 down' - see Debian bug #144666
   1.262 +            ifconfig $interface inet 0
   1.263 +            exit_with_hooks 2 "$@"
   1.264 +        fi
   1.265 +
   1.266 +        ;;
   1.267 +esac
   1.268 +
   1.269 +exit_with_hooks 0