wok-current annotate busybox/stuff/udhcp.script @ rev 20486

perl: force arch
author Pascal Bellard <pascal.bellard@slitaz.org>
date Fri Oct 26 10:09:53 2018 +0200 (2018-10-26)
parents e03da3e76528
children 02c70d036ea0
rev   line source
pascal@1770 1 #!/bin/sh
pascal@1770 2
pascal@1770 3 # udhcpc script edited by Tim Riker <Tim@Rikers.org>
pascal@1770 4
pascal@1770 5 [ -z "$1" ] && echo "Error: should be called from udhcpc" && exit 1
pascal@1770 6
pascal@10926 7 [ "$subnet" == "255.255.255.255" ] && subnet="255.255.0.0" # qemu/ipv6 weirdness
pascal@1770 8 RESOLV_CONF="/etc/resolv.conf"
pascal@1770 9 [ -n "$broadcast" ] && BROADCAST="broadcast $broadcast"
pascal@1770 10 [ -n "$subnet" ] && NETMASK="netmask $subnet"
pascal@20068 11 DEV="dev $interface"
pascal@1770 12
pascal@10926 13 netfs()
pascal@10926 14 {
pascal@20065 15 grep -qe '\(:.* /\|httpfs\|nfs\|smbfs\|ncp\|coda\)' /proc/mounts
pascal@10926 16 }
pascal@10926 17
pascal@20070 18 logger "$0 interface=$interface ip=$ip ipv6=$ipv6 broadcast=$broadcast \
pascal@20070 19 subnet=$subnet ipv6prefix=$ipv6prefix router=$router domain=$domain dns=$dns \
pascal@20070 20 fqdn=$fqdn mask=$mask lease=$lease tz=$tz tz_name=$tz_name sname=$sname $@"
pascal@12153 21
pascal@20068 22 skip="$(sed "/skipdhcpip=/!d;s/.*skipdhcpip=\([^ ]*\).*/\1/" </proc/cmdline)"
pascal@20070 23 case ",${skip:-X}," in *,${ip:-$ipv6},*) exit 0;; esac
pascal@19065 24
pascal@1770 25 case "$1" in
pascal@1770 26 deconfig)
pascal@20072 27 if ! netfs; then
pascal@20065 28 ifconfig $interface 0.0.0.0
pascal@20068 29 ip -6 addr flush $DEV
pascal@20065 30 fi
pascal@1770 31 for i in /etc/ipdown.d/*; do
pascal@4544 32 [ -x $i ] && $i $interface
pascal@1770 33 done
pascal@1770 34 ;;
pascal@1770 35
pascal@1770 36 renew|bound)
pascal@20068 37 ipv6mask=${ipv6prefix#*/}
pascal@20069 38 ip=${ip:-$ipv6}
pascal@20068 39 if [ ${ip/:/} == $ip ]; then
pascal@20065 40 ifconfig $interface $ip $BROADCAST $NETMASK
pascal@20070 41 v6=""
pascal@20065 42 else
pascal@20068 43 ip -6 addr add $ip/${ipv6mask:-64} $DEV
pascal@20070 44 v6="-A inet6"
pascal@20065 45 fi
pascal@1770 46
pascal@1770 47 if [ -n "$router" ] ; then
pascal@20069 48 while route del default gw 0.0.0.0 $DEV ; do :; done
pascal@20070 49 [ -n "$v6" ] && ip -6 route flush $DEV
pascal@20070 50 m=0
pascal@1770 51 for i in $router ; do
pascal@20070 52 route $v6 add default gw $i $DEV metric $((m++))
pascal@20068 53 done
pascal@20068 54 fi 2>/dev/null
pascal@1770 55
pascal@20068 56 echo -en ${domain:+search $domain \\n} > $RESOLV_CONF
pascal@1770 57 for i in $dns ; do
pascal@20068 58 echo nameserver $i
pascal@20068 59 done >> $RESOLV_CONF
pascal@20071 60 if [ "$1" == "bound" ] ; then
pascal@20071 61 [ -n "$tz" ] && echo $tz > /etc/TZ
pascal@20071 62 for i in /etc/ipup.d/*; do
pascal@20071 63 [ -x $i ] && $i $interface $ip $dns
pascal@20071 64 done
pascal@20071 65 fi
pascal@1770 66 ;;
pascal@1770 67 esac
pascal@1770 68
pascal@1770 69 exit 0