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