In some projects (e.g. babeld) is important how sections are ordered. The arrangement represents at the end e.g. the passing through different rules.
Currently I'm doing this:
uci add babeld filter
uci set babeld.@filter[-1].type='redistribute'
uci set babeld.@filter[-1].ip=$1
uci set babeld.@filter[-1].local='true'
uci set babeld.@filter[-1].action='deny'
This just appends to a config file and results that the rules never apply.
Is there another way?
If you don't use
uci add you can just overwrite any currently existing filter using something like:
uci set babeld.@filter["$n"].type='redistribute'
uci set babeld.@filter["$n"].ip=$1
uci set babeld.@filter["$n"].local='true'
uci set babeld.@filter["$n"].action='deny'
You may also want to look at this: https://openwrt.org/docs/guide-developer/config-scripting
Thanks a lot. I know that I can use
set, but I want somehow to automatically add that to the front. Maybe I can extend
Maybe you could contribute to the patch which would implement
uci --insert add (a-la iptables -I option): use normal add, get n -- the number of matching sections, in the loop for i in n to 1 copy section options from [i-1] to [i] and delete options from .
Once you do uci --insert add, you can then write the new values to @filter.
UPDATE: Strike that, do what the post below says.
Did you try
uci reorder <config>.<section>=<position> ? Add a new config and move it to the top? Never tried it though.
This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.