ppp: Extend uci datamodel with persistency sypport
[openwrt/openwrt.git] / package / network / services / ppp / files / ppp.sh
index 2a7e76b7fe2c3a092f8f7eea8437d41bb02f5e5d..f8b04dec9fd60605136039092c65cc0a9ba20f02 100755 (executable)
@@ -79,13 +79,16 @@ ppp_generic_init_config() {
        proto_config_add_int mtu
        proto_config_add_string pppname
        proto_config_add_string unnumbered
        proto_config_add_int mtu
        proto_config_add_string pppname
        proto_config_add_string unnumbered
+       proto_config_add_boolean persist
+       proto_config_add_int maxfail
+       proto_config_add_int holdoff
 }
 
 ppp_generic_setup() {
        local config="$1"; shift
        local localip
 
 }
 
 ppp_generic_setup() {
        local config="$1"; shift
        local localip
 
-       json_get_vars ipv6 demand keepalive keepalive_adaptive username password pppd_options pppname unnumbered
+       json_get_vars ipv6 demand keepalive keepalive_adaptive username password pppd_options pppname unnumbered persist maxfail holdoff
        if [ "$ipv6" = 0 ]; then
                ipv6=""
        elif [ -z "$ipv6" -o "$ipv6" = auto ]; then
        if [ "$ipv6" = 0 ]; then
                ipv6=""
        elif [ -z "$ipv6" -o "$ipv6" = auto ]; then
@@ -98,6 +101,12 @@ ppp_generic_setup() {
        else
                demand=""
        fi
        else
                demand=""
        fi
+       if [ -n "$persist" ]; then
+               [ "${persist}" -lt 1 ] && persist="nopersist" || persist="persist"
+       fi
+       if [ -z "$maxfail" ]; then
+               [ "$persist" = "persist" ] && maxfail=0 || maxfail=1
+       fi
        [ -n "$mtu" ] || json_get_var mtu mtu
        [ -n "$pppname" ] || pppname="${proto:-ppp}-$config"
        [ -n "$unnumbered" ] && {
        [ -n "$mtu" ] || json_get_var mtu mtu
        [ -n "$pppname" ] || pppname="${proto:-ppp}-$config"
        [ -n "$unnumbered" ] && {
@@ -129,7 +138,8 @@ ppp_generic_setup() {
                ${autoipv6:+set AUTOIPV6=1} \
                nodefaultroute \
                usepeerdns \
                ${autoipv6:+set AUTOIPV6=1} \
                nodefaultroute \
                usepeerdns \
-               $demand maxfail 1 \
+               $demand $persist maxfail $maxfail \
+               ${holdoff:+holdoff "$holdoff"} \
                ${username:+user "$username" password "$password"} \
                ${connect:+connect "$connect"} \
                ${disconnect:+disconnect "$disconnect"} \
                ${username:+user "$username" password "$password"} \
                ${connect:+connect "$connect"} \
                ${disconnect:+disconnect "$disconnect"} \