make network scripts more robust, prevent multiple instances of pppd and udhcpc for...
[openwrt-10.03/.git] / package / ppp / files / ppp.sh
index 343223af1b96e41330242a9e3471cb6dc564eab6..133400509ceba52dffdf5766864964b410df361c 100644 (file)
@@ -7,6 +7,11 @@ scan_ppp() {
 
 start_pppd() {
        local cfg="$1"; shift
+       
+       # make sure only one pppd process is started
+       local pid="$(cat /var/run/ppp-${cfg}.pid 2>/dev/null)"
+       [ -d "/proc/$pid" ] && grep pppd "/proc/$pid/cmdline" 2>/dev/null >/dev/null && return 0
+
        config_get device "$cfg" device
        config_get unit "$cfg" unit
        config_get username "$cfg" username