wok annotate busybox/stuff/udhcp.script @ rev 16452
Add: SkypeFreak
author | Aleksej Bobylev <al.bobylev@gmail.com> |
---|---|
date | Sat Apr 19 12:42:09 2014 +0300 (2014-04-19) |
parents | 15a917692a49 |
children | 15e6c6910ee3 |
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@12152 | 14 /bin/grep -qe '\(:.* /\|httpfs\|nfs\|smbfs\|ncp\|coda\)' /proc/mounts |
pascal@10926 | 15 } |
pascal@10926 | 16 |
pascal@12153 | 17 logger "$0 interface=$interface ip=$ip broadcast=$broadcast subnet=$subnet router=$router domain=$domain dns=$dns $@" |
pascal@12153 | 18 |
pascal@1770 | 19 case "$1" in |
pascal@1770 | 20 deconfig) |
pascal@10926 | 21 netfs || /sbin/ifconfig $interface 0.0.0.0 |
pascal@1770 | 22 for i in /etc/ipdown.d/*; do |
pascal@4544 | 23 [ -x $i ] && $i $interface |
pascal@1770 | 24 done |
pascal@1770 | 25 ;; |
pascal@1770 | 26 |
pascal@1770 | 27 renew|bound) |
pascal@1770 | 28 /sbin/ifconfig $interface $ip $BROADCAST $NETMASK |
pascal@1770 | 29 |
pascal@1770 | 30 if [ -n "$router" ] ; then |
pascal@1770 | 31 echo "deleting routers" |
pascal@12152 | 32 while route del default gw 0.0.0.0 dev $interface 2>/dev/null; do |
pascal@1770 | 33 : |
pascal@1770 | 34 done |
pascal@1770 | 35 |
pascal@1770 | 36 metric=0 |
pascal@1770 | 37 for i in $router ; do |
pascal@12152 | 38 route add default gw $i dev $interface metric $((metric++)) 2>/dev/null |
pascal@1770 | 39 done |
pascal@1770 | 40 fi |
pascal@1770 | 41 |
pascal@1770 | 42 echo -n > $RESOLV_CONF |
pascal@1770 | 43 [ -n "$domain" ] && echo search $domain >> $RESOLV_CONF |
pascal@1770 | 44 for i in $dns ; do |
pascal@1770 | 45 echo adding dns $i |
pascal@1770 | 46 echo nameserver $i >> $RESOLV_CONF |
pascal@1770 | 47 done |
pascal@4544 | 48 [ "$1" == "bound" ] && for i in /etc/ipup.d/*; do |
pascal@4544 | 49 [ -x $i ] && $i $interface $ip $dns |
pascal@1770 | 50 done |
pascal@1770 | 51 ;; |
pascal@1770 | 52 esac |
pascal@1770 | 53 |
pascal@1770 | 54 exit 0 |