wok-current view busybox/stuff/udhcp.script @ rev 20065

busybox/udhcpc6: update script
author Pascal Bellard <pascal.bellard@slitaz.org>
date Sat Sep 23 13:11:28 2017 +0200 (2017-09-23)
parents 15e6c6910ee3
children 22fbe02a8c96
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"
12 netfs()
13 {
14 grep -qe '\(:.* /\|httpfs\|nfs\|smbfs\|ncp\|coda\)' /proc/mounts
15 }
17 logger "$0 interface=$interface ip=$ip ipv6=$ipv6 broadcast=$broadcast subnet=$subnet ipv6prefix=$ipv6prefix router=$router domain=$domain dns=$dns fqdn=$fqdn $@"
19 skip=$(sed "/skipdhcpip=/!d;s/.*skipdhcpip=\([^ ]*\).*/\1/" </proc/cmdline)
20 [ -n "$skip" ] && case "$ip" in $skip*) exit 0;; esac
22 case "$1" in
23 deconfig)
24 if !netfs; then
25 ifconfig $interface 0.0.0.0
26 ip -6 addr flush dev $interface
27 fi
28 for i in /etc/ipdown.d/*; do
29 [ -x $i ] && $i $interface
30 done
31 ;;
33 renew|bound)
34 if [ ${ip/:/} == $ip ];
35 ifconfig $interface $ip $BROADCAST $NETMASK
36 else
37 ip -6 addr add ${ip}/${ipv6prefix#*/} dev $interface
38 fi
40 if [ -n "$router" ] ; then
41 echo "deleting routers"
42 while route del default gw 0.0.0.0 dev $interface 2>/dev/null; do
43 :
44 done
45 [ ${ip/:/} != $ip ] && ip -6 route flush dev $interface
47 metric=0
48 for i in $router ; do
49 if [ ${ip/:/} == $ip ]; then
50 route add default gw $i dev $interface metric $((metric++))
51 else
52 route -A inet6 add default gw $i dev $interface metric $((metric++))
53 fi
54 done 2>/dev/null
55 fi
57 echo -n > $RESOLV_CONF
58 [ -n "$domain" ] && echo search $domain >> $RESOLV_CONF
59 for i in $dns ; do
60 echo adding dns $i
61 echo nameserver $i >> $RESOLV_CONF
62 done
63 [ "$1" == "bound" ] && for i in /etc/ipup.d/*; do
64 [ -x $i ] && $i $interface $ip $dns
65 done
66 ;;
67 esac
69 exit 0