wok-current rev 20068
busybox/udhcpc6: update script (again)
author | Pascal Bellard <pascal.bellard@slitaz.org> |
---|---|
date | Sat Sep 23 16:49:43 2017 +0200 (2017-09-23) |
parents | 78a25960b7ef |
children | 265e84f3feb6 |
files | busybox/stuff/udhcp.script |
line diff
1.1 --- a/busybox/stuff/udhcp.script Sat Sep 23 15:53:27 2017 +0200 1.2 +++ b/busybox/stuff/udhcp.script Sat Sep 23 16:49:43 2017 +0200 1.3 @@ -8,6 +8,7 @@ 1.4 RESOLV_CONF="/etc/resolv.conf" 1.5 [ -n "$broadcast" ] && BROADCAST="broadcast $broadcast" 1.6 [ -n "$subnet" ] && NETMASK="netmask $subnet" 1.7 +DEV="dev $interface" 1.8 1.9 netfs() 1.10 { 1.11 @@ -16,14 +17,14 @@ 1.12 1.13 logger "$0 interface=$interface ip=$ip ipv6=$ipv6 broadcast=$broadcast subnet=$subnet ipv6prefix=$ipv6prefix router=$router domain=$domain dns=$dns fqdn=$fqdn $@" 1.14 1.15 -skip=$(sed "/skipdhcpip=/!d;s/.*skipdhcpip=\([^ ]*\).*/\1/" </proc/cmdline) 1.16 -[ -n "$skip" ] && case "$ip" in $skip*) exit 0;; esac 1.17 +skip="$(sed "/skipdhcpip=/!d;s/.*skipdhcpip=\([^ ]*\).*/\1/" </proc/cmdline)" 1.18 +case " $skip " in *\ $ip\ *) exit 0;; esac 1.19 1.20 case "$1" in 1.21 deconfig) 1.22 if !netfs; then 1.23 ifconfig $interface 0.0.0.0 1.24 - ip -6 addr flush dev $interface 1.25 + ip -6 addr flush $DEV 1.26 fi 1.27 for i in /etc/ipdown.d/*; do 1.28 [ -x $i ] && $i $interface 1.29 @@ -31,37 +32,30 @@ 1.30 ;; 1.31 1.32 renew|bound) 1.33 - ipv6prefix=${ipv6prefix:-/64} 1.34 - [ -n "$ip" ] && if [ ${ip/:/} == $ip ]; then 1.35 + ipv6mask=${ipv6prefix#*/} 1.36 + [ -n "$ip" ] || ip=$ipv6 1.37 + if [ ${ip/:/} == $ip ]; then 1.38 ifconfig $interface $ip $BROADCAST $NETMASK 1.39 else 1.40 - ip -6 addr add ${ip}/${ipv6prefix#*/} dev $interface 1.41 + ip -6 addr add $ip/${ipv6mask:-64} $DEV 1.42 fi 1.43 - [ -n "$ipv6" ] && ip -6 addr add ${ipv6}/${ipv6prefix#*/} dev $interface 1.44 1.45 if [ -n "$router" ] ; then 1.46 - echo "deleting routers" 1.47 - while route del default gw 0.0.0.0 dev $interface 2>/dev/null; do 1.48 + while route del default gw 0.0.0.0 $DEV ; do 1.49 : 1.50 done 1.51 - [ ${ip/:/} != $ip ] && ip -6 route flush dev $interface 1.52 - 1.53 + t= 1.54 + [ ${ip/:/} != $ip ] && t="-A inet6" && ip -6 route flush $DEV 1.55 metric=0 1.56 for i in $router ; do 1.57 - if [ ${ip/:/} == $ip ]; then 1.58 - route add default gw $i dev $interface metric $((metric++)) 1.59 - else 1.60 - route -A inet6 add default gw $i dev $interface metric $((metric++)) 1.61 - fi 1.62 - done 2>/dev/null 1.63 - fi 1.64 + route $t add default gw $i $DEV metric $((metric++)) 1.65 + done 1.66 + fi 2>/dev/null 1.67 1.68 - echo -n > $RESOLV_CONF 1.69 - [ -n "$domain" ] && echo search $domain >> $RESOLV_CONF 1.70 + echo -en ${domain:+search $domain \\n} > $RESOLV_CONF 1.71 for i in $dns ; do 1.72 - echo adding dns $i 1.73 - echo nameserver $i >> $RESOLV_CONF 1.74 - done 1.75 + echo nameserver $i 1.76 + done >> $RESOLV_CONF 1.77 [ "$1" == "bound" ] && for i in /etc/ipup.d/*; do 1.78 [ -x $i ] && $i $interface $ip $dns 1.79 done