comgt: add support of using device symlinks.
[openwrt/openwrt.git] / package / network / utils / comgt / files / directip.sh
index d82805278c98ecbd02a8fe222b1e2062303effd9..381bfb000075d4fdfe1d2024d3af6a1e80ee9b47 100644 (file)
@@ -15,17 +15,19 @@ proto_directip_init_config() {
        proto_config_add_string "auth"
        proto_config_add_string "username"
        proto_config_add_string "password"
+       proto_config_add_defaults
 }
 
 proto_directip_setup() {
        local interface="$1"
        local chat devpath devname
 
-       local device apn pincode ifname auth username password
-       json_get_vars device apn pincode auth username password
+       local device apn pincode ifname auth username password $PROTO_DEFAULT_OPTIONS
+       json_get_vars device apn pincode auth username password $PROTO_DEFAULT_OPTIONS
 
        [ -n "$ctl_device" ] && device=$ctl_device
 
+       device="$(readlink -f $device)"
        [ -e "$device" ] || {
                proto_notify_error "$interface" NO_DEVICE
                proto_set_available "$interface" 0
@@ -80,6 +82,7 @@ proto_directip_setup() {
        json_add_string name "${interface}_4"
        json_add_string ifname "@$interface"
        json_add_string proto "dhcp"
+       proto_add_dynamic_defaults
        ubus call network add_dynamic "$(json_dump)"
 
        json_init
@@ -87,6 +90,7 @@ proto_directip_setup() {
        json_add_string ifname "@$interface"
        json_add_string proto "dhcpv6"
        json_add_string extendprefix 1
+       proto_add_dynamic_defaults
        ubus call network add_dynamic "$(json_dump)"
 
        return 0