--- /dev/null
+[ ifup = "$ACTION" ] && {
+ uci set "/var/state/network.$INTERFACE.up=1"
+ [ -z "$DEVICE" ] || {
+ uci set "/var/state/network.$INTERFACE.ifname=$DEVICE"
+ }
+}
mkdir -p /var/run
mkdir -p /var/log
mkdir -p /var/lock
+ mkdir -p /var/state
touch /var/log/wtmp
touch /var/log/lastlog
ln -s /tmp/resolv.conf.auto /tmp/resolv.conf
# if we're called for the bridge interface itself, don't bother trying
# to create any interfaces here. The scripts have already done that, otherwise
# the bridge interface wouldn't exist.
- [ "br-$config" = "$iface" ] && return 0;
-
- [ -f "$iface" ] && return 0;
+ [ "br-$config" = "$iface" -o -f "$iface" ] && return 0;
ifconfig "$iface" 2>/dev/null >/dev/null && {
# make sure the interface is removed from any existing bridge and brought down
[ -z "$ip6addr" ] || $DEBUG ifconfig "$iface" add "$ip6addr"
[ -z "$gateway" ] || $DEBUG route add default gw "$gateway"
[ -z "$bcast" ] || $DEBUG ifconfig "$iface" broadcast "$bcast"
- [ -z "$dns" -o -f /tmp/resolv.conf.auto ] || {
+ [ -z "$dns" ] || {
for ns in $dns; do
- echo "nameserver $ns" >> /tmp/resolv.conf.auto
+ grep "$ns" /tmp/resolv.conf.auto 2>/dev/null >/dev/null || {
+ echo "nameserver $ns" >> /tmp/resolv.conf.auto
+ }
done
}
config_load network
exit
}
+
+# remove the interface's network state
+FILE=/var/state/network.$$
+grep -v "^config_set '$1' " /var/state/network > "$FILE"
+mv "$FILE" /var/state/network
+
include /lib/network
scan_interfaces
config_get proto $ifc proto
[ "$proto" = "dhcp" ] || continue
-
+ [ ifup = "$1" ] && {
+ uci set "/var/state/network.$ifc.ipaddr=$ip"
+ uci set "/var/state/network.$ifc.netmask=${subnet:-255.255.255.0}"
+ uci set "/var/state/network.$ifc.dnsdomain=$domain"
+ uci set "/var/state/network.$ifc.dns=$dns"
+ uci set "/var/state/network.$ifc.gateway=$router"
+ }
env -i ACTION="$1" INTERFACE="$ifc" DEVICE="$ifname" PROTO=dhcp /sbin/hotplug-call iface
done
}
#!/bin/sh
-[ -z "$6" ] || env -i ACTION="ifdown" INTERFACE="$6" DEVICE="$1" PROTO=ppp /sbin/hotplug-call "iface"
+PPP_IFACE="$1"
+PPP_TTY="$2"
+PPP_SPEED="$3"
+PPP_LOCAL="$4"
+PPP_REMOTE="$5"
+PPP_IPPARAM="$6"
+export PPP_IFACE PPP_TTY PPP_SPEED PPP_LOCAL PPP_REMOTE PPP_IPPARAM
+[ -z "$PPP_IPPARAM" ] || {
+ env -i ACTION="ifdown" INTERFACE="$PPP_IPPARAM" DEVICE="$PPP_IFACE" PROTO=ppp /sbin/hotplug-call "iface"
+
+ # remove the interface's network state
+ FILE=/var/state/network.$$
+ grep -v "^config_set '$PPP_IPPARAM' " /var/state/network > "$FILE"
+ mv "$FILE" /var/state/network
+}
[ -d /etc/ppp/ip-down.d ] && {
for SCRIPT in /etc/ppp/ip-down.d/*
#!/bin/sh
-[ -z "$6" ] || env -i ACTION="ifup" INTERFACE="$6" DEVICE="$1" PROTO=ppp /sbin/hotplug-call "iface"
+PPP_IFACE="$1"
+PPP_TTY="$2"
+PPP_SPEED="$3"
+PPP_LOCAL="$4"
+PPP_REMOTE="$5"
+PPP_IPPARAM="$6"
+export PPP_IFACE PPP_TTY PPP_SPEED PPP_LOCAL PPP_REMOTE PPP_IPPARAM
+[ -z "$PPP_IPPARAM" ] || env -i ACTION="ifup" INTERFACE="$PPP_IPPARAM" DEVICE="$PPP_IFACE" PROTO=ppp /sbin/hotplug-call "iface"
+[ -z "$PPP_IPPARAM" -o -z "$PPP_LOCAL" ] || {
+ uci set "/var/state/network.$PPP_IPPARAM.ipaddr=$PPP_LOCAL"
+ uci set "/var/state/network.$PPP_IPPARAM.gateway=$PPP_REMOTE"
+}
+
[ -d /etc/ppp/ip-up.d ] && {
for SCRIPT in /etc/ppp/ip-up.d/*