Sorry, forgot reply-to list.

On 19.05.2020 13:23, Jeonghum Joh wrote:
Thank you!

But I have another question :

   config zone
           option name       wan
           list   network          'wan'
           list   network          'wan6'
+        list   network          'wwan'
           option input            REJECT
           option output           ACCEPT
           option forward          REJECT

Above is part of /etc/config/firewall.
And as you see, I'd like to add new interface wwan into zone wan.
How can I write uci command script for this?

Thank you very much!
Jeonghum

Here is an untested snippet I found in an old uci-defaults script of mine.

----8<----
#!/bin/sh
. /lib/functions.sh

lanzone_var=""
wanzone_var=""

find_firewall_zones () {
        local config="$1"
        local zone_name

        config_get zone_name "$config" name

        if [ "$zone_name" == "lan" ]
        then
                lanzone_var="$config"
        elif [ "$zone_name" == "wan" ]
        then
                wanzone_var="$config"
        fi

        return 0
}

config_load firewall
config_foreach find_firewall_zones zone

uci -q add_list firewall.${wanzone_var}.network='wwan'
---->8----

I don't think I actually used this, I wrote it because I thought I might need it and it followed the same pattern as manipulating network.vlan sections. I do know it doesn't work in my current device script, although I attempted to fix that error in the code above. Consider it a hint.

In addition, I've not mentioned 'uci commit' or commands to reload configuration/services, which you probably also want to add in these scripts.

Regards,
Magnus Kroken

_______________________________________________
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel

Reply via email to