hopefully fix duplicate ppp instances (#895)
[openwrt/svn-archive/archive.git] / package / base-files / default / sbin / ifdown
index 50d59d1df8160d0bcb188313860926756ef0b649..26d0e626d2dde9bb02e076efafa53b769ad41a89 100755 (executable)
@@ -12,6 +12,14 @@ debug "### ifdown $cfg ###"
 config_get proto "$cfg" proto
 [ -z "$proto" ] && { echo "interface not found."; exit; }
 
+config_get iface "$cfg" device
+[ "$proto" = "static" ] && {
+       env -i ACTION="ifdown" INTERFACE="$config" DEVICE="$iface" PROTO=static /sbin/hotplug "iface" &
+}
+
+# call interface stop handler
+( type "stop_interface_$proto" ) >/dev/null 2>/dev/null && eval "stop_interface_$proto '$cfg'"
+
 # make sure all locks are removed
 for lock in "/var/lock/dhcp-$iface" "/var/lock/ppp-$iface"; do
        [ -f "$lock" ] && {
@@ -22,7 +30,7 @@ done
 
 # kill active ppp daemon and other processes
 config_get ifname "$cfg" ifname
-pids="$(cat /var/run/${ifname}.pid /var/run/ppp-${cfg}.pid 2>/dev/null)"
+pids="$(head -n1 -q /var/run/${ifname}.pid /var/run/ppp-${cfg}.pid 2>/dev/null)"
 for pid in $pids; do 
        [ -d "/proc/$pid" ] && {
                kill $pid