Interface was hardcoded, (cut/paste from the testing openwrt machine)
[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 echo "deleting routers"
32 while route del default gw 0.0.0.0 dev $interface ; do :; done
33 for i in $router ; do
34 route add default gw $i dev $interface
35 done
36 fi
37 fi
38
39 echo -n > $RESOLV_CONF
40 ${domain:+echo search $domain} >> $RESOLV_CONF
41 for i in $dns ; do
42 echo adding dns $i
43 echo nameserver $i >> $RESOLV_CONF
44 done
45
46 hotplug_event ifup
47
48 # user rules
49 [ -f /etc/udhcpc.user ] && . /etc/udhcpc.user
50 ;;
51 esac
52
53 exit 0
This page took 0.062001 seconds and 5 git commands to generate.