ImageBuilder: How to preserve a config file when settings are not saved

Thanks, that was very informative and helpful. The use case I am solving is one where the wireless settings would not be known (i.e. may have a customized password by somebody else), and I do not want to create an image per device.

The device id sniffing is interesting, but wouldn't work for what I am trying to accomplish - I am sure pulling them from the firmware to set some defaults that match a sticker is useful for a staging, rather than upgrading script.

Using the "keep wireless, drop other config" strategy, I think you are suggesting a modification to how the "preserve settings" works in an attended upgrade, where I would choose to force install the DSA image, and select save settings, knowing that it will only save wireless, due to the proposed ideas for modification. Looks straightforwads, thanks.

I had been looking closely at some uci-scripts that call functions like config_load xxx as well, to do some migrations and preservation of things, and I think at some point I might be able to something like below, maybe a 10_keepwireless

I am not sure about the sequencing, and when the old configuration is available to be loaded, and stored in the new configuration. With your your MAC reading script the firmware values are always there, if the device partition is accessible. With sysupgrade, I am wondering if the load_config functions always load the old configuration during a sysupgrade? How do you differentiate between uci-defaults scripts operating on the old router configuration or the new image configuration. Is it sequence 1_ vs 99_ or is there a folder location for this stuff. There are a lot of places for uci-defaults browsing the imagebuilder folder structure. Maybe /target/root/etc/uci-defaults

It seems my example could be loading old_key and saving new_key as I intend, but maybe it would just load new, modify it, and save new, like a script that is just updating the syntax of the default settings to be platform specific.

config_load wireless 
config_get current_password wifi-iface.@wifi-iface[0].key 
uci set wireless.@wifi-iface[0].key="$current_password" 
uci commit wireless

credit seems due for the silent typo avoiding partner I had draft up that example unmodified>: ChatGPT [write a script to be used in an openwrt firmware image's uci-defaults folder that uses "config_load wireless" to lookup the existing wifi-iface password during a sysupgrade and save it using "uci commit wireless"]

So I can't help myself; As I write that, >:ChatGPT [what is the correct folder location to place the previous script withing the openwrt imagebuilder folder struction in order for it to load the value from the device that is being upgraded prior to replacing the firmware and configuration]

The correct location to place the script within the OpenWrt ImageBuilder folder structure would be in the "package/base-files/files/etc/uci-defaults" folder. This folder is where the UCI default configuration files are stored, which are executed during the system startup and during a firmware upgrade. By placing the script in this folder, it will be executed during the firmware upgrade process and the wireless password will be saved before the new firmware and configuration are applied.

Off to test some stuff out