53c8faf3169bc0a63cce9d8ae86567b158b9bf8a
[openwrt.git] / package / base-files / files / 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 /lib/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="$ifc" DEVICE="$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 [ -n "$dns" ] && {
42 echo -n > $RESOLV_CONF
43 ${domain:+echo search $domain} >> $RESOLV_CONF
44 for i in $dns ; do
45 echo "adding dns $i"
46 echo "nameserver $i" >> $RESOLV_CONF
47 done
48 }
49
50 hotplug_event ifup
51
52 # user rules
53 [ -f /etc/udhcpc.user ] && . /etc/udhcpc.user
54 ;;
55 esac
56
57 exit 0
This page took 0.064483 seconds and 3 git commands to generate.