wok annotate busybox/stuff/udhcp.script @ rev 19712

podofo: disble lua
author Pascal Bellard <pascal.bellard@slitaz.org>
date Wed Feb 15 17:57:05 2017 +0100 (2017-02-15)
parents d83d24e3aa16
children 05ed2662f295
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@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@10926 24 netfs || /sbin/ifconfig $interface 0.0.0.0
pascal@1770 25 for i in /etc/ipdown.d/*; do
pascal@4544 26 [ -x $i ] && $i $interface
pascal@1770 27 done
pascal@1770 28 ;;
pascal@1770 29
pascal@1770 30 renew|bound)
pascal@1770 31 /sbin/ifconfig $interface $ip $BROADCAST $NETMASK
pascal@1770 32
pascal@1770 33 if [ -n "$router" ] ; then
pascal@1770 34 echo "deleting routers"
pascal@12152 35 while route del default gw 0.0.0.0 dev $interface 2>/dev/null; do
pascal@1770 36 :
pascal@1770 37 done
pascal@1770 38
pascal@1770 39 metric=0
pascal@1770 40 for i in $router ; do
pascal@12152 41 route add default gw $i dev $interface metric $((metric++)) 2>/dev/null
pascal@1770 42 done
pascal@1770 43 fi
pascal@1770 44
pascal@1770 45 echo -n > $RESOLV_CONF
pascal@1770 46 [ -n "$domain" ] && echo search $domain >> $RESOLV_CONF
pascal@1770 47 for i in $dns ; do
pascal@1770 48 echo adding dns $i
pascal@1770 49 echo nameserver $i >> $RESOLV_CONF
pascal@1770 50 done
pascal@4544 51 [ "$1" == "bound" ] && for i in /etc/ipup.d/*; do
pascal@4544 52 [ -x $i ] && $i $interface $ip $dns
pascal@1770 53 done
pascal@1770 54 ;;
pascal@1770 55 esac
pascal@1770 56
pascal@1770 57 exit 0