1

I am configuring a router running OpenWRT, but I am struggling to understand how to use the uci command (Unified Configuration Interface) to inspect an existing configuration file. I would like to automate this configuration in a shell script.

Take for example the firewall configuration at /etc/config/firewall which is 195 long, so a bit difficult to inspect with cat.

There are various rules, take the first one with:

root@OpenWrt:/etc/config# grep -B1 -A6 'Allow-DHCP-Renew' /etc/config/firewall
config rule
    option name     Allow-DHCP-Renew
    option src      wan
    option proto        udp
    option dest_port    68
    option target       ACCEPT
    option family       ipv4

root@OpenWrt:/etc/config# 

I can inspect the various fields of this first rule (@rule[0]) e.g. the field name with:

root@OpenWrt:/etc/config# uci get firewall.@rule[0].name
Allow-DHCP-Renew
root@OpenWrt:/etc/config# 

But I can not see the whole rule as output, I've tried with uci get firewall.@rule[0].* but it's not the right syntax.

There is no manual for uci (man uci), so I am not sure where to find the information on how to use that command.

Is this "group get" possible at all?

0

Ehm... Just found out I need to use uci show instead of uci get, see below for an example:

root@OpenWrt:/etc/config# uci show firewall.@rule[0]
firewall.cfg0592bd=rule
firewall.cfg0592bd.name='Allow-DHCP-Renew'
firewall.cfg0592bd.src='wan'
firewall.cfg0592bd.proto='udp'
firewall.cfg0592bd.dest_port='68'
firewall.cfg0592bd.target='ACCEPT'
firewall.cfg0592bd.family='ipv4'
root@OpenWrt:/etc/config#

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.