wok-6.x view busybox/stuff/udhcp.script @ rev 23740

updated xa (2.3.9 -> 2.3.10)
author Hans-G?nter Theisgen
date Fri May 01 11:08:45 2020 +0100 (2020-05-01)
parents cc3ce981e201
children
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 \
19 subnet=$subnet ipv6prefix=$ipv6prefix router=$router domain=$domain dns=$dns \
20 fqdn=$fqdn mask=$mask lease=$lease tz=$tz tz_name=$tz_name sname=$sname $@"
22 skip="$(sed "/skipdhcpip=/!d;s/.*skipdhcpip=\([^ ]*\).*/\1/" </proc/cmdline)"
23 case ",${skip:-X}," in *,${ip:-$ipv6},*) exit 0;; esac
25 case "$1" in
26 deconfig)
27 if ! netfs; then
28 ifconfig $interface 0.0.0.0
29 ip -6 addr flush $DEV
30 fi
31 for i in /etc/ipdown.d/*; do
32 [ -x $i ] && $i $interface
33 done
34 ;;
36 renew|bound)
37 ipv6mask=${ipv6prefix#*/}
38 ip=${ip:-$ipv6}
39 if [ ${ip/:/} = $ip ]; then
40 ifconfig $interface $ip $BROADCAST $NETMASK
41 v6=""
42 else
43 ip -6 addr add $ip/${ipv6mask:-64} $DEV
44 v6="-A inet6"
45 fi
47 if [ -n "$router" ] ; then
48 while route del default gw 0.0.0.0 $DEV ; do :; done
49 [ -n "$v6" ] && ip -6 route flush $DEV
50 m=0
51 for i in $router ; do
52 route $v6 add default gw $i $DEV metric $((m++))
53 done
54 fi 2>/dev/null
56 echo -en ${domain:+search $domain \\n} > $RESOLV_CONF
57 for i in $dns ; do
58 echo nameserver $i
59 done >> $RESOLV_CONF
60 if [ "$1" = "bound" ] ; then
61 [ -n "$tz" ] && echo $tz > /etc/TZ
62 for i in /etc/ipup.d/*; do
63 [ -x $i ] && $i $interface $ip $dns
64 done
65 fi
66 ;;
67 esac
69 exit 0