wok view busybox/stuff/udhcp.script @ rev 19065

Take care on root in post_install
author Pascal Bellard <pascal.bellard@slitaz.org>
date Thu Apr 21 09:45:48 2016 +0200 (2016-04-21)
parents d83d24e3aa16
children 05ed2662f295
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 /bin/grep -qe '\(:.* /\|httpfs\|nfs\|smbfs\|ncp\|coda\)' /proc/mounts
15 }
17 logger "$0 interface=$interface ip=$ip broadcast=$broadcast subnet=$subnet router=$router domain=$domain dns=$dns $@"
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 netfs || /sbin/ifconfig $interface 0.0.0.0
25 for i in /etc/ipdown.d/*; do
26 [ -x $i ] && $i $interface
27 done
28 ;;
30 renew|bound)
31 /sbin/ifconfig $interface $ip $BROADCAST $NETMASK
33 if [ -n "$router" ] ; then
34 echo "deleting routers"
35 while route del default gw 0.0.0.0 dev $interface 2>/dev/null; do
36 :
37 done
39 metric=0
40 for i in $router ; do
41 route add default gw $i dev $interface metric $((metric++)) 2>/dev/null
42 done
43 fi
45 echo -n > $RESOLV_CONF
46 [ -n "$domain" ] && echo search $domain >> $RESOLV_CONF
47 for i in $dns ; do
48 echo adding dns $i
49 echo nameserver $i >> $RESOLV_CONF
50 done
51 [ "$1" == "bound" ] && for i in /etc/ipup.d/*; do
52 [ -x $i ] && $i $interface $ip $dns
53 done
54 ;;
55 esac
57 exit 0