wok rev 7145

Add udhcpc6-fake
author Pascal Bellard <pascal.bellard@slitaz.org>
date Sat Nov 06 16:08:43 2010 +0100 (2010-11-06)
parents da9081c3c915
children d871301c2874
files udhcpc6-fake/receipt udhcpc6-fake/stuff/etc/dhclient-script udhcpc6-fake/stuff/etc/dhclient.conf udhcpc6-fake/stuff/sbin/udhcpc
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/udhcpc6-fake/receipt	Sat Nov 06 16:08:43 2010 +0100
     1.3 @@ -0,0 +1,16 @@
     1.4 +# SliTaz package receipt.
     1.5 +
     1.6 +PACKAGE="udhcpc6-fake"
     1.7 +VERSION="1.0"
     1.8 +CATEGORY="network"
     1.9 +SHORT_DESC="Temporary? udhcpc fake for ipv6 support."
    1.10 +MAINTAINER="pascal.bellard@slitaz.org"
    1.11 +WEB_SITE="http://www.isc.org/products/DHCP/"
    1.12 +DEPENDS="dhcp6-client"
    1.13 +
    1.14 +# Rules to gen a SliTaz package suitable for Tazpkg.
    1.15 +genpkg_rules()
    1.16 +{
    1.17 +	cp -a stuff/* $fs
    1.18 +}
    1.19 +
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/udhcpc6-fake/stuff/etc/dhclient-script	Sat Nov 06 16:08:43 2010 +0100
     2.3 @@ -0,0 +1,266 @@
     2.4 +#!/bin/ash
     2.5 +
     2.6 +# dhclient-script for Linux. Dan Halbert, March, 1997.
     2.7 +# Updated for Linux 2.[12] by Brian J. Murrell, January 1999.
     2.8 +# Modified for Debian.  Matt Zimmerman and Eloy Paris, December 2003
     2.9 +# Modified to remove useless tests for antiquated kernel versions that
    2.10 +# this doesn't even work with anyway, and introduces a dependency on /usr
    2.11 +# being mounted, which causes cosmetic errors on hosts that NFS mount /usr
    2.12 +# Andrew Pollock, February 2005
    2.13 +# Modified to work on point-to-point links. Andrew Pollock, June 2005
    2.14 +# Modified to support passing the parameters called with to the hooks. Andrew Pollock, November 2005
    2.15 +
    2.16 +# The alias handling in here probably still sucks. -mdz
    2.17 +
    2.18 +make_resolv_conf() {
    2.19 +    if [ -n "$new_domain_name" -o -n "$new_domain_name_servers" ]; then
    2.20 +        # Find out whether we are going to mount / rw
    2.21 +        exec 9>&0 </etc/fstab
    2.22 +        rootmode=rw
    2.23 +        while read dev mnt type opts dump pass junk; do
    2.24 +            [ "$mnt" != / ] && continue
    2.25 +            case "$opts" in
    2.26 +                ro|ro,*|*,ro|*,ro,*)
    2.27 +                   rootmode=ro
    2.28 +                   ;;
    2.29 +                 esac
    2.30 +         done
    2.31 +         exec 0>&9 9>&-
    2.32 + 
    2.33 +        # Wait for /etc/resolv.conf to become writable
    2.34 +        if [ "$rootmode" = "rw" ]; then
    2.35 +            while [ ! -w /etc ]; do
    2.36 +                sleep 1
    2.37 +            done
    2.38 +        fi
    2.39 +
    2.40 +        local new_resolv_conf=/etc/resolv.conf.dhclient-new
    2.41 +        rm -f $new_resolv_conf
    2.42 +        if [ -n "$new_domain_name" ]; then
    2.43 +            echo search $new_domain_name >>$new_resolv_conf
    2.44 +        else # keep 'old' search/domain scope
    2.45 +            egrep -i '^ *[:space:]*(search|domain)' /etc/resolv.conf >> $new_resolv_conf
    2.46 +        fi
    2.47 +        if [ -n "$new_domain_name_servers" ]; then
    2.48 +                   for nameserver in $new_domain_name_servers; do
    2.49 +                       echo nameserver $nameserver >>$new_resolv_conf
    2.50 +            done
    2.51 +        else # keep 'old' nameservers
    2.52 +            sed -n /^\w*[Nn][Aa][Mm][Ee][Ss][Ee][Rr][Vv][Ee][Rr]/p /etc/resolv.conf >>$new_resolv_conf
    2.53 +        fi
    2.54 +        chown root.root $new_resolv_conf
    2.55 +        chmod 644 $new_resolv_conf
    2.56 +        mv -f $new_resolv_conf /etc/resolv.conf
    2.57 +    fi
    2.58 +}
    2.59 +
    2.60 +run_hook() {
    2.61 +    local script="$1"
    2.62 +    local exit_status
    2.63 +    shift	# discard the first argument, then the rest are the script's
    2.64 +
    2.65 +    if [ -f $script ]; then
    2.66 +        . $script "$@"
    2.67 +    fi
    2.68 +
    2.69 +
    2.70 +    if [ -n "$exit_status" ] && [ "$exit_status" -ne 0 ]; then
    2.71 +        logger -p daemon.err "$script returned non-zero exit status $exit_status"
    2.72 +        save_exit_status=$exit_status
    2.73 +    fi
    2.74 +
    2.75 +    return $exit_status
    2.76 +}
    2.77 +
    2.78 +run_hookdir() {
    2.79 +    local dir="$1"
    2.80 +    local exit_status
    2.81 +    shift	# See run_hook
    2.82 +
    2.83 +    if [ -d "$dir" ]; then
    2.84 +        for script in $(run-parts --list $dir); do
    2.85 +            run_hook $script "$@" || true
    2.86 +            exit_status=$?
    2.87 +        done
    2.88 +    fi
    2.89 +
    2.90 +    return $exit_status
    2.91 +}
    2.92 +
    2.93 +# Must be used on exit.   Invokes the local dhcp client exit hooks, if any.
    2.94 +exit_with_hooks() {
    2.95 +    exit_status=$1
    2.96 +
    2.97 +    # Source the documented exit-hook script, if it exists
    2.98 +    if ! run_hook /etc/dhcp3/dhclient-exit-hooks "$@"; then
    2.99 +        exit_status=$?
   2.100 +    fi
   2.101 +
   2.102 +    # Now run scripts in the Debian-specific directory.
   2.103 +    if ! run_hookdir /etc/dhcp3/dhclient-exit-hooks.d "$@"; then
   2.104 +        exit_status=$?
   2.105 +    fi
   2.106 +
   2.107 +    exit $exit_status
   2.108 +}
   2.109 +
   2.110 +set_hostname() {
   2.111 +    local current_hostname=$(hostname)
   2.112 +    if [ -z "$current_hostname" -o "$current_hostname" = "(none)" ]; then
   2.113 +        hostname "$new_host_name"
   2.114 +    fi
   2.115 +}
   2.116 +
   2.117 +if [ -n "$new_broadcast_address" ]; then
   2.118 +    new_broadcast_arg="broadcast $new_broadcast_address"
   2.119 +fi
   2.120 +if [ -n "$old_broadcast_address" ]; then
   2.121 +    old_broadcast_arg="broadcast $old_broadcast_address"
   2.122 +fi
   2.123 +if [ -n "$new_subnet_mask" ]; then
   2.124 +    new_subnet_arg="netmask $new_subnet_mask"
   2.125 +fi
   2.126 +if [ -n "$old_subnet_mask" ]; then
   2.127 +    old_subnet_arg="netmask $old_subnet_mask"
   2.128 +fi
   2.129 +if [ -n "$alias_subnet_mask" ]; then
   2.130 +    alias_subnet_arg="netmask $alias_subnet_mask"
   2.131 +fi
   2.132 +if [ -n "$new_interface_mtu" ] && [ $new_interface_mtu -ge 575 ]; then
   2.133 +    mtu_arg="mtu $new_interface_mtu"
   2.134 +fi
   2.135 +if [ -n "$IF_METRIC" ]; then
   2.136 +    metric_arg="metric $IF_METRIC"	# interfaces(5), "metric" option
   2.137 +fi
   2.138 +
   2.139 +
   2.140 +# The action starts here
   2.141 +
   2.142 +# Invoke the local dhcp client enter hooks, if they exist.
   2.143 +run_hook /etc/dhcp3/dhclient-enter-hooks
   2.144 +run_hookdir /etc/dhcp3/dhclient-enter-hooks.d
   2.145 +
   2.146 +# Execute the operation
   2.147 +case "$reason" in
   2.148 +    MEDIUM|ARPCHECK|ARPSEND)
   2.149 +        # Do nothing
   2.150 +        ;;
   2.151 +    PREINIT)
   2.152 +        # The DHCP client is requesting that an interface be
   2.153 +        # configured as required in order to send packets prior to
   2.154 +        # receiving an actual address. - dhclient-script(8)
   2.155 +
   2.156 +        if [ -n "$alias_ip_address" ]; then
   2.157 +            # Bring down alias interface. Its routes will disappear too.
   2.158 +            ifconfig $interface:0- inet 0
   2.159 +        fi
   2.160 +        ifconfig $interface inet 0 up
   2.161 +
   2.162 +        # We need to give the kernel some time to get the interface up.
   2.163 +        sleep 1
   2.164 +        ;;
   2.165 +    BOUND|RENEW|REBIND|REBOOT)
   2.166 +
   2.167 +        set_hostname
   2.168 +        
   2.169 +        if [ -n "$old_ip_address" -a -n "$alias_ip_address" -a \
   2.170 +             "$alias_ip_address" != "$old_ip_address" ]; then
   2.171 +            # Possible new alias. Remove old alias.
   2.172 +            ifconfig $interface:0- inet 0
   2.173 +        fi
   2.174 +
   2.175 +        if [ -n "$old_ip_address" -a \
   2.176 +             "$old_ip_address" != "$new_ip_address" ]; then
   2.177 +            # IP address changed. Bringing down the interface will delete all routes,
   2.178 +            # and clear the ARP cache.
   2.179 +            ifconfig $interface inet 0
   2.180 +
   2.181 +        fi
   2.182 +
   2.183 +        if [ -z "$old_ip_address" -o "$old_ip_address" != "$new_ip_address" -o \
   2.184 +            "$reason" = "BOUND" -o "$reason" = "REBOOT" ]; then
   2.185 +
   2.186 +            ifconfig $interface inet $new_ip_address $new_subnet_arg \
   2.187 +                $new_broadcast_arg $mtu_arg
   2.188 +
   2.189 +	    # point to point
   2.190 +	    if [ "$new_subnet_mask" == "255.255.255.255" ]; then
   2.191 +	    	for router in $new_routers; do
   2.192 +	    	    route add -host $router dev $interface
   2.193 +	    	done
   2.194 +	    fi
   2.195 +
   2.196 +            for router in $new_routers; do
   2.197 +                route add default dev $interface gw $router $metric_arg
   2.198 +            done
   2.199 +        fi
   2.200 +
   2.201 +        if [ "$new_ip_address" != "$alias_ip_address" -a -n "$alias_ip_address" ];
   2.202 +            then
   2.203 +            ifconfig $interface:0- inet 0
   2.204 +            ifconfig $interface:0 inet $alias_ip_address $alias_subnet_arg
   2.205 +            route add -host $alias_ip_address $interface:0
   2.206 +        fi
   2.207 +
   2.208 +        make_resolv_conf
   2.209 +
   2.210 +        ;;
   2.211 +
   2.212 +    EXPIRE|FAIL|RELEASE|STOP)
   2.213 +        if [ -n "$alias_ip_address" ]; then
   2.214 +            # Turn off alias interface.
   2.215 +            ifconfig $interface:0- inet 0
   2.216 +        fi
   2.217 +
   2.218 +        if [ -n "$old_ip_address" ]; then
   2.219 +            # Shut down interface, which will delete routes and clear arp cache.
   2.220 +            ifconfig $interface inet 0
   2.221 +        fi
   2.222 +
   2.223 +        if [ -n "$alias_ip_address" ]; then
   2.224 +            ifconfig $interface:0 inet $alias_ip_address $alias_subnet_arg
   2.225 +            route add -host $alias_ip_address $interface:0
   2.226 +        fi
   2.227 +
   2.228 +        ;;
   2.229 +
   2.230 +    TIMEOUT)
   2.231 +        if [ -n "$alias_ip_address" ]; then
   2.232 +            ifconfig $interface:0- inet 0
   2.233 +        fi
   2.234 +
   2.235 +        ifconfig $interface inet $new_ip_address $new_subnet_arg \
   2.236 +            $new_broadcast_arg $mtu_arg
   2.237 +
   2.238 +        set -- $new_routers
   2.239 +        first_router="$1"
   2.240 +
   2.241 +        if ping -q -c 1 $first_router; then
   2.242 +            if [ "$new_ip_address" != "$alias_ip_address" -a \
   2.243 +                -n "$alias_ip_address" ]; then
   2.244 +                ifconfig $interface:0 inet $alias_ip_address $alias_subnet_arg
   2.245 +                route add -host $alias_ip_address dev $interface:0
   2.246 +            fi
   2.247 +	    
   2.248 +	    # point to point
   2.249 +	    if [ "$new_subnet_mask" == "255.255.255.255" ]; then
   2.250 +	    	for router in $new_routers; do
   2.251 +	    	    route add -host $router dev $interface
   2.252 +	    	done
   2.253 +	    fi
   2.254 +
   2.255 +            for router in $new_routers; do
   2.256 +                route add default dev $interface gw $router $metric_arg
   2.257 +            done
   2.258 +
   2.259 +            make_resolv_conf
   2.260 +        else
   2.261 +            # Changed from 'ifconfig $interface inet 0 down' - see Debian bug #144666
   2.262 +            ifconfig $interface inet 0
   2.263 +            exit_with_hooks 2 "$@"
   2.264 +        fi
   2.265 +
   2.266 +        ;;
   2.267 +esac
   2.268 +
   2.269 +exit_with_hooks 0
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/udhcpc6-fake/stuff/etc/dhclient.conf	Sat Nov 06 16:08:43 2010 +0100
     3.3 @@ -0,0 +1,1 @@
     3.4 +request subnet-mask, broadcast-address, time-offset, routers, static-routes, domain-name,    domain-name-servers, host-name, ntp-servers;
     4.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.2 +++ b/udhcpc6-fake/stuff/sbin/udhcpc	Sat Nov 06 16:08:43 2010 +0100
     4.3 @@ -0,0 +1,14 @@
     4.4 +#/bin/sh
     4.5 +
     4.6 +INTERFACE=eth0
     4.7 +while [ -n "$1" ]; do
     4.8 +	[ "$1" == "-i" ] && INTERFACE=$2
     4.9 +	shift
    4.10 +done
    4.11 +
    4.12 +exec /usr/sbin/dhclient -e IF_METRIC=100 \
    4.13 +	-pf /var/run/dhclient.$INTERFACE.pid \
    4.14 +	-lf /var/lib/dhcp3/dhclient.$INTERFACE.leases \
    4.15 +	-cf /etc/dhclient.conf \
    4.16 +	-sf /etc/dhclient-script \
    4.17 +	$INTERFACE