Search code examples
openwrt

How to add unnamed uci section if not exist?


I want to configure ipsec via uci (always ipsec[0]). Everything works correctly if ipsec section exists. I can modify ipsec using uci ipsec.@ipsec[0].type='tunnel'. But if ipsec section doesn't exist this command is not working. I want to add the ipsec section if not exist.


Solution

  • The only way I found is to use a shell script

    if ! uci -q show ipsec.@ipsec[0]
    then
        uci add ipsec ipsec
    fi