UCI is Fairly Useless

In the GitHUB post (above last linked one) uci set web. ... .roles was used and it worked (so no need for replace_list or set_list). Unfortunately it also wiped out any other settings for those roles in the modem, say the guest setting. That approach wasn't useful with 'web.ruleset_main.rules='.

As it is my script will add a new section but will not update it if it exists. (I don't think if ... fi blocks are reasonable on most lines.)

I'm interested in any workarounds without wrapping most lines in if ... fi (unless maybe as part of a subroutine). Is the -m option useful?

I still think default operation should be no duplicates.

UCI is cool but it blindly messes up config files. So you don't have to be a newbie to need Failsafe Mode after uci [via Luci] mashes up the network configs.

Indeed, being able to sort entries, have no more duplicate entries and roll back updates, would be killer features. But achieving these might require UCI complying with a higher data model/schema?

Until then, just be carefull what you typo.

If you need to compare 2 uci files just do:

uci show -c path1 package1 | sort >/tmp/temp && uci show -c path2 package2 | sort | diff /tmp/temp -

This also works to compare a subset, like a specific config section
I find "uci show" quite useful - does not exist with ini files :wink:

I agree, but then it should not be called add_list. As I said, if you want idempotent behavior, precede your add operation with a matching delete operation.

Agree, worth a try.

Hmmm, unfortunately archived on a Windows computer.

So...?

  • Just copy
  • or network
  • install the proper shell
  • or LiveCD

You seem to be creating roadblocks.

To be fair, some of the points raised are to improve the comparability of produced configurations and it makes sense to not require special tooling for diffing plaintext files.

2 Likes

But, as far as I know there is no out-of-the-shelf diff tool in windows.
So, special tools are required in any case.

But the main problem with my solution is that it requires the uci binary to begin with.

@flywire: Maybe you could backup your configuration files directly in "uci show" format, generated in the router then transferred to Windows?

Powershell has diff tool

diff (cat file1) (cat file2)

The developers don't control the storage medium. Perhaps I misunderstood why the archive ended up on a Windows storage.

Config normally saved with https://github.com/Ansuel/tch-nginx-gui/blob/master/decompressed/gui_file/www/docroot/modals/gateway-modal.lp local function export_config() (starts at line 71). I haven't identified the actual command yet.

File compare software shouldn't matter (I prefer np++).

It's probably niche stuff, not normal operation needed by every application, but I had to do that some times.

I've used my system to deal with modifying entries by name, or by the content of the entry itself, without knowing the node ID. Like "find the mount point /aaa/bb/cc and change its option to enabled in the config".

Doing the same with UCI alone is not really possible as I don't know the node number thing of the mount point I'm looking for beforehand.

And if I need to filter UCI output to find the node first I might as well do it all manually in the script anyway.

I've also used manual scripting for batch operations on multiple nodes where I don't know the node or name beforehand. Like changing all DNS servers on multiple interfaces at once, or things like that.
I mean it's just a sed to replace a string with another in a text file.

I think having a uci searchID "keyword" that returns the ID thing I should use to edit that entry would solve that.

Something like

# uci searchID "/aaa/bbb/ccc"

with output

# 0

if it is in fstab.@mount[0]

Or multiple numbers if it is in multiple places.

This way I can just do


for i in $( uci searchID xxx ) ; do

<uci command to do stuff>

done

to have the script do batch operations

Solved

Link above is https://notepad-plus-plus.org/community/topic/12950/compare-plugin-is-back/20

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.