wok view busybox/stuff/udhcp.script @ rev 20069

busybox/udhcpc6: update script (again)
author Pascal Bellard <pascal.bellard@slitaz.org>
date Sat Sep 23 17:21:58 2017 +0200 (2017-09-23)
parents 3437359e0ac3
children 121612c89805
line source
1 #!/bin/sh
3 # udhcpc script edited by Tim Riker <Tim@Rikers.org>
5 [ -z "$1" ] && echo "Error: should be called from udhcpc" && exit 1
7 [ "$subnet" == "255.255.255.255" ] && subnet="255.255.0.0" # qemu/ipv6 weirdness
8 RESOLV_CONF="/etc/resolv.conf"
9 [ -n "$broadcast" ] && BROADCAST="broadcast $broadcast"
10 [ -n "$subnet" ] && NETMASK="netmask $subnet"
11 DEV="dev $interface"
13 netfs()
14 {
15 grep -qe '\(:.* /\|httpfs\|nfs\|smbfs\|ncp\|coda\)' /proc/mounts
16 }
18 logger "$0 interface=$interface ip=$ip ipv6=$ipv6 broadcast=$broadcast subnet=$subnet ipv6prefix=$ipv6prefix router=$router domain=$domain dns=$dns fqdn=$fqdn $@"
20 skip="$(sed "/skipdhcpip=/!d;s/.*skipdhcpip=\([^ ]*\).*/\1/" </proc/cmdline)"
21 case " $skip " in *\ ${ip:-$ipv6}\ *) exit 0;; esac
23 case "$1" in
24 deconfig)
25 if !netfs; then
26 ifconfig $interface 0.0.0.0
27 ip -6 addr flush $DEV
28 fi
29 for i in /etc/ipdown.d/*; do
30 [ -x $i ] && $i $interface
31 done
32 ;;
34 renew|bound)
35 ipv6mask=${ipv6prefix#*/}
36 ip=${ip:-$ipv6}
37 if [ ${ip/:/} == $ip ]; then
38 ifconfig $interface $ip $BROADCAST $NETMASK
39 else
40 ip -6 addr add $ip/${ipv6mask:-64} $DEV
41 fi
43 if [ -n "$router" ] ; then
44 while route del default gw 0.0.0.0 $DEV ; do :; done
45 t=
46 [ ${ip/:/} != $ip ] && t="-A inet6" && ip -6 route flush $DEV
47 metric=0
48 for i in $router ; do
49 route $t add default gw $i $DEV metric $((metric++))
50 done
51 fi 2>/dev/null
53 echo -en ${domain:+search $domain \\n} > $RESOLV_CONF
54 for i in $dns ; do
55 echo nameserver $i
56 done >> $RESOLV_CONF
57 [ "$1" == "bound" ] && for i in /etc/ipup.d/*; do
58 [ -x $i ] && $i $interface $ip $dns
59 done
60 ;;
61 esac
63 exit 0