wok-next rev 1770

busybox udhcpc/zcip: call /etc/ip*.d scripts
author Pascal Bellard <pascal.bellard@slitaz.org>
date Wed Nov 26 18:02:56 2008 +0000 (2008-11-26)
parents a85ffe1b42a5
children 5379cbc00d16
files busybox/receipt busybox/stuff/udhcp.script busybox/stuff/zcip.script
line diff
     1.1 --- a/busybox/receipt	Wed Nov 26 11:51:02 2008 +0000
     1.2 +++ b/busybox/receipt	Wed Nov 26 18:02:56 2008 +0000
     1.3 @@ -61,7 +61,7 @@
     1.4      mkdir -p $fs/etc/modprobe.d
     1.5      # Udhcpc stuff.
     1.6      mkdir -p $fs/usr/share/udhcpc
     1.7 -    cp $src/examples/udhcp/simple.script \
     1.8 +    cp stuff/udhcp.script \
     1.9      $fs/usr/share/udhcpc/default.script
    1.10      chmod +x $fs/usr/share/udhcpc/default.script
    1.11      # ZeroConf stuff.
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/busybox/stuff/udhcp.script	Wed Nov 26 18:02:56 2008 +0000
     2.3 @@ -0,0 +1,46 @@
     2.4 +#!/bin/sh
     2.5 +
     2.6 +# udhcpc script edited by Tim Riker <Tim@Rikers.org>
     2.7 +
     2.8 +[ -z "$1" ] && echo "Error: should be called from udhcpc" && exit 1
     2.9 +
    2.10 +RESOLV_CONF="/etc/resolv.conf"
    2.11 +[ -n "$broadcast" ] && BROADCAST="broadcast $broadcast"
    2.12 +[ -n "$subnet" ] && NETMASK="netmask $subnet"
    2.13 +
    2.14 +case "$1" in
    2.15 +	deconfig)
    2.16 +		/sbin/ifconfig $interface 0.0.0.0
    2.17 +		for i in /etc/ipdown.d/*; do
    2.18 +			[ -e $i ] && . $i $interface
    2.19 +		done
    2.20 +		;;
    2.21 +
    2.22 +	renew|bound)
    2.23 +		/sbin/ifconfig $interface $ip $BROADCAST $NETMASK
    2.24 +
    2.25 +		if [ -n "$router" ] ; then
    2.26 +			echo "deleting routers"
    2.27 +			while route del default gw 0.0.0.0 dev $interface ; do
    2.28 +				:
    2.29 +			done
    2.30 +
    2.31 +			metric=0
    2.32 +			for i in $router ; do
    2.33 +				route add default gw $i dev $interface metric $((metric++))
    2.34 +			done
    2.35 +		fi
    2.36 +
    2.37 +		echo -n > $RESOLV_CONF
    2.38 +		[ -n "$domain" ] && echo search $domain >> $RESOLV_CONF
    2.39 +		for i in $dns ; do
    2.40 +			echo adding dns $i
    2.41 +			echo nameserver $i >> $RESOLV_CONF
    2.42 +		done
    2.43 +		for i in /etc/ipup.d/*; do
    2.44 +			[ -e $i ] && . $i $interface $ip $dns
    2.45 +		done
    2.46 +		;;
    2.47 +esac
    2.48 +
    2.49 +exit 0
     3.1 --- a/busybox/stuff/zcip.script	Wed Nov 26 11:51:02 2008 +0000
     3.2 +++ b/busybox/stuff/zcip.script	Wed Nov 26 18:02:56 2008 +0000
     3.3 @@ -3,7 +3,15 @@
     3.4  [ "$1" = "init" ] && exit 0
     3.5  [ -n "$ip" ] || exit 1
     3.6  case "$1" in
     3.7 -config)		exec ifconfig $interface $ip netmask 255.255.0.0 up;;
     3.8 -deconfig)	exec ifconfig $interface down;;
     3.9 +config)		ifconfig $interface $ip netmask 255.255.0.0 up
    3.10 +		for i in /etc/ipup.d/*; do
    3.11 +			[ -e $i ] && . $i $interface $ip
    3.12 +		done
    3.13 +		;;
    3.14 +deconfig)	ifconfig $interface down
    3.15 +		for i in /etc/ipdown.d/*; do
    3.16 +			[ -e $i ] && . $i $interface
    3.17 +		done
    3.18 +		;;
    3.19  *)		exit 1;;
    3.20  esac