fix ppp related bug in the network scripts
[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 . /etc/functions.sh
4 include network
5
6 RESOLV_CONF="/tmp/resolv.conf"
7
8 hotplug_event() {
9 scan_interfaces
10 for ifc in $interfaces; do
11 config_get ifname $ifc ifname
12 [ "$ifname" = "$interface" ] || continue
13
14 config_get proto $ifc proto
15 [ "$proto" = "dhcp" ] || continue
16
17 env -i ACTION="$1" INTERFACE="$ifname" PROTO=dhcp /sbin/hotplug iface
18 done
19 }
20
21 case "$1" in
22 deconfig)
23 ifconfig $interface 0.0.0.0
24 hotplug_event ifdown
25 ;;
26 renew|bound)
27 ifconfig $interface $ip \
28 netmask ${subnet:-255.255.255.0} \
29 broadcast ${broadcast:-+}
30
31 if [ -n "$router" ] ; then
32 echo "deleting routers"
33 while route del default gw 0.0.0.0 dev $interface >&- 2>&- ; do :; done
34
35 for i in $router ; do
36 echo "adding router $i"
37 route add default gw $i dev $interface
38 done
39 fi
40
41 echo -n > $RESOLV_CONF
42 ${domain:+echo search $domain} >> $RESOLV_CONF
43 for i in $dns ; do
44 echo "adding dns $i"
45 echo "nameserver $i" >> $RESOLV_CONF
46 done
47
48 hotplug_event ifup
49
50 # user rules
51 [ -f /etc/udhcpc.user ] && . /etc/udhcpc.user
52 ;;
53 esac
54
55 exit 0
This page took 0.045022 seconds and 5 git commands to generate.