UCI often commit

How are you?
I have an issue, my every 5 minutes I check if my network DNS server is up and is changing the he.net dynamic updates (so if the DNS in my network is off), it updates the he.net dynamic DNS.
But for now, every 5 minutes I change the network DNS servers as well, (if using a public DNS server or use my local network DNS).

Now my question is where those the UCI configs are in the NAND (of course I am in overlay with ext4), I know the /etc/config is in my HDD with overlay ext-root, but that actual UCI configs that are generated from the /etc/config, but I can understand that if the generated /etc/config/* in UCI is in the EEPROM or NAND, then commiting into UCI has wear leveling, and that's bad.

So then I have to change my scripts if the dns has changed or not changed, but so far it has problems with the booting and even though my local network DNS is up, it is still thinking the DNS is down, so I solved it that every dynamic DNS update (every 5 minutes) it commits the current DNS (local dhcp DNS, ipv6 DNS, router wan dns and some redirect as well to show like there is under maintenance to so that my domains are available, but not my server, hanem from my router with nginx).

So, given I have ext-rot, is using uci commit every 5 minutes , is it using in the NAND/EEPROM or it is using in the ext-root uci configurations.

Because if i uci commit every 5 minutes and even though I have ext-root, the uci config is in the NAND/EEPROM, then it will be weared and that is bad.

Does it anyone know how it works, because I dont wanto wear uci if it is really in the NAN/EEPROM.

Thanks so much!

You can also consider not committing at all. A mere uci set is enough to make the change visible to services. The not-yet committed changes are staged in /tmp/.uci (a tmpfs mount) and vanish after a reboot.

1 Like

hello @jow!

thanks so much!
last question, after i use lua to change the settings, do i have to use reload_config or that is not required, because reload form the nand/eeprom?
so just x:set(etc, etc, etc) is enough and do not use reload_config and then it will be awesome and working?

You need to perform the following steps:

require "uci"

x = uci.cursor()
x:set("conf", "sect", "opt", "value")  -- this sets the value in the cursor instance
x:save("conf")                         -- this saves the cursor state to /tmp/.uci/conf
--x:commit("conf")                     -- that would commit changes from /tmp/.uci/conf to /etc/config/conf,
                                       -- but it is not required

os.execute('/sbin/reload_config')      -- apply changes

testing, because without save it was not updating,
i test now with save, it that is works, then i am happy,
thanks @jow joy!

ok, it is working, awesome!
but @jow, how can i get rid of this:

Now it keeps showing me that I have unsaved changes.

If I change something with LUCI, i will commit then, that's all?
Because LUCI uses commit I suppose.
So I guess, it will be not a problem, because I will rarely change the LUCi settings, and just a few commits like this.
Is that right?

Sorry for the lots of questions!

Yep, that is correct.

I think you can query a specific DNS from a script, without changing the default DNS for all the system, or touching any configuration file: try to execute nslookup [host] [server].

@jow, it works. it shows the I have unsaved changes, but after reload_config, the router senses the update and it works.

@eduperez yes, i am already using the nslookup, exactly for this, for caching if there was a DNS change, but my bash source $DIR/lib caches if there was a new DNS update, but since i use the $DIR/lib multiple times, the 2nd time it thinks is already updated, so i still have to work it out with a library when is us using the same lib within a script in a script, so that I don't have to execute a few scripts, just because of this :soccer:

thanks you guys so much for helping!