update busybox menuconfig to 1.1.1, should fix the "missing reboot" bug
[openwrt.git] / package / base-files / default / usr / share / udhcpc / default.script
1 #!/bin/sh
2 [ -z "$1" ] && echo "Error: should be run by udhcpc" && exit 1
3
4 RESOLV_CONF="/tmp/resolv.conf"
5
6 hotplug_event() {
7 nvram show 2>&- | grep _proto=dhcp | {
8 while :; do
9 read FOO
10 [ -z "$FOO" ] && break
11 FOO="${FOO%%_*}"
12 [ "$(nvram get ${FOO}_ifname)" = "${interface}" ] || continue
13 env -i ACTION="$1" INTERFACE="${FOO}" PROTO=dhcp /sbin/hotplug iface
14 done
15 }
16 }
17
18 case "$1" in
19 deconfig)
20 ifconfig $interface 0.0.0.0
21 hotplug_event ifdown
22 ;;
23 renew|bound)
24 ifconfig $interface $ip \
25 netmask ${subnet:-255.255.255.0} \
26 broadcast ${broadcast:-+}
27
28 if [ -n "$router" ] ; then
29
30 if [ "$router" != "$(route -n | grep '^0.0.0.0' | grep $interface | awk '{ print $2 }')" ] ; then
31 while route del default gw 0.0.0.0 dev $interface 2>&- ; do
32 echo "removing old default route"
33 done
34 for i in $router ; do
35 route add default gw $i dev $interface
36 done
37 fi
38 fi
39
40 echo -n > $RESOLV_CONF
41 ${domain:+echo search $domain} >> $RESOLV_CONF
42 for i in $dns ; do
43 echo adding dns $i
44 echo nameserver $i >> $RESOLV_CONF
45 done
46
47 hotplug_event ifup
48
49 # user rules
50 [ -f /etc/udhcpc.user ] && . /etc/udhcpc.user
51 ;;
52 esac
53
54 exit 0
This page took 0.062417 seconds and 5 git commands to generate.