2 [ -z "$1" ] && echo "Error: should be run by udhcpc" && exit 1
6 RESOLV_CONF
="/tmp/resolv.conf.auto"
9 [ -n "$ifc" ] ||
return
10 uci_revert_state
"$1" "$2" "$3" "$4"
11 uci_set_state
"$1" "$2" "$3" "$4"
14 set_classless_routes
() {
17 while [ -n "$1" -a -n "$2" -a $max -gt 0 ]; do
18 [ ${1##*/} -eq 32 ] && type=host ||
type=net
19 echo "udhcpc: adding route for $type $1 via $2"
20 route add
-$type "$1" gw
"$2" dev
"$interface"
37 old_ip
="$(uci_get_state network "$ifc" ipaddr)"
38 old_broadcast
="$(uci_get_state network "$ifc" broadcast)"
39 old_subnet
="$(uci_get_state network "$ifc" netmask)"
42 [ "$ip" != "$old_ip" ] \
43 ||
[ "${broadcast:-+}" != "$old_broadcast" ] \
44 ||
[ "${subnet:-255.255.255.0}" != "$old_subnet" ] && {
45 echo "udhcpc: ifconfig $interface $ip netmask ${subnet:-255.255.255.0} broadcast ${broadcast:-+}"
46 ifconfig
$interface $ip netmask
${subnet:-255.255.255.0} broadcast
${broadcast:-+}
48 change_state network
"$ifc" ipaddr
"$ip"
49 change_state network
"$ifc" broadcast
"${broadcast:-+}"
50 change_state network
"$ifc" netmask
"${subnet:-255.255.255.0}"
56 change_state network
"$ifc" lease_gateway
"$router"
57 old_router
="$(uci_get_state network "$ifc" gateway)"
58 user_router
="$(uci_get network "$ifc" gateway)"
59 user_metric
="$(uci_get network "$ifc" metric)"
60 [ -n "$user_router" ] && router
="$user_router"
63 [ -n "$router" ] && [ "$router" != "0.0.0.0" ] && [ "$router" != "255.255.255.255" ] && [ "$router" != "$old_router" ] && {
64 echo "udhcpc: setting default routers: $router"
68 route add default gw
$i ${user_metric:+metric $user_metric} dev
$interface
69 valid_gw
="${valid_gw:+$valid_gw|}$i"
72 eval $
(route
-n |
awk '
73 /^0.0.0.0\W{9}('$valid_gw')\W/ {next}
74 /^0.0.0.0/ {print "route del -net "$1" gw "$2";"}
77 change_state network
"$ifc" gateway
"$router"
80 # CIDR STATIC ROUTES (rfc3442)
81 [ -n "$staticroutes" ] && set_classless_routes
$staticroutes
82 [ -n "$msstaticroutes" ] && set_classless_routes
$msstaticroutes
85 old_dns
=$
(uci_get_state network
"$ifc" dns
)
86 old_domain
=$
(uci_get_state network
"$ifc" dnsdomain
)
87 user_dns
=$
(uci_get
"network.$ifc.dns")
88 [ -n "$user_dns" ] && dns
="$user_dns"
90 [ -n "$dns" ] && [ "$dns" != "$old_dns" -o -n "$user_dns" ] && {
91 echo "udhcpc: setting dns servers: $dns"
94 [ -n "$domain" ] && [ "$domain" != "$old_domain" ] && {
95 echo "udhcpc: setting dns domain: $domain"
96 sed -i -e "${old_domain:+/^search $old_domain$/d; }/^search $domain$/d" "${RESOLV_CONF}"
97 echo "search $domain" >> "${RESOLV_CONF}"
98 change_state network
"$ifc" dnsdomain
"$domain"
102 [ -n "$ifc" ] ||
return
105 change_state network
"$ifc" lease_server
"$serverid"
106 change_state network
"$ifc" lease_acquired
"$(sed -ne 's![^0-9].*$!!p' /proc/uptime)"
107 change_state network
"$ifc" lease_lifetime
"$lease"
108 [ -n "$ntpsrv" ] && change_state network
"$ifc" lease_ntpsrv
"$ntpsrv"
109 [ -n "$timesvr" ] && change_state network
"$ifc" lease_timesrv
"$timesvr"
110 [ -n "$hostname" ] && change_state network
"$ifc" lease_hostname
"$hostname"
111 [ -n "$timezone" ] && change_state network
"$ifc" lease_timezone
"$timezone"
115 env
-i ACTION
="$1" INTERFACE
="$ifc" DEVICE
="$ifname" PROTO
=dhcp
/sbin
/hotplug-call iface
121 for ifc
in $interfaces __default
; do
122 if [ "$ifc" = __default
]; then
124 [ -n "$applied" ] && continue
126 config_get ifname
"$ifc" ifname
127 [ "$ifname" = "$interface" ] ||
continue
129 config_get proto
"$ifc" proto
130 [ "$proto" = "dhcp" ] ||
continue
136 ifconfig
"$interface" 0.0.0.0
138 env
-i ACTION
="ifdown" INTERFACE
="$ifc" DEVICE
="$ifname" PROTO
=dhcp
/sbin
/hotplug-call iface
140 config_get device
"$ifc" device
141 config_get ifname
"$ifc" ifname
142 config_get aliases
"$ifc" aliases
143 uci_revert_state network
"$ifc"
144 [ -n "$device" ] && uci_set_state network
"$ifc" device
"$device"
145 [ -n "$ifname" ] && uci_set_state network
"$ifc" ifname
"$ifname"
146 [ -n "$aliases" ] && uci_set_state network
"$ifc" aliases
"$aliases"
150 setup_interface update
159 [ -f /etc
/udhcpc.user
] && .
/etc
/udhcpc.user
This page took 0.051563 seconds and 5 git commands to generate.