Automatically merge old and new config files after sysupgrade?

Actually, all config files get an `-opkg' extension if they are not upgraded. Is there any way to merge these configs automatically? If a conflict occurs, always take the latest option for a config value from a config file.

Merging configuration over the upgrade

Maybe we could do following:

  1. The uci defaults are in /rom/etc/uci-defaults and the config is under /rom/etc/config
  2. Copy the default config to cp -r /rom/etc/config /tmp/config
  3. Run the uci defaults on the /tmp/config (not sure I have to test this, but maybe something like uci -c /tmp/config or some (-p or -P option)
  4. Do a diff with diffutils diff /tmp/config /etc/config > changes.patch

Hmmm, maybe we could do something with sed -i 's/uci/uci -c \/tmp\/config/g' *

That did not work. :frowning:

Further I found a script to compare uci configs in the openwrt forum archive. But I can not find the forum post anymore.

cd /etc/config
for F in *
        echo "===== $F ====="
        uci -c /rom/etc/config export $F >/tmp/$F.default 2>/dev/null
        case $? in 0) ;; *) echo '>> no default in /rom <<' ;; esac
        uci export $F >/tmp/$F.current
        diff /tmp/$F.default /tmp/$F.current
        rm -f /tmp/$F.default /tmp/$F.current

Maybe diff is better with diff -a -b -d /rom/etc/config/dhcp /etc/config/dhcp


Thank u! :smiley:

Any idea how can I get the config after a firstboot? I need to get the diff after the uci-default scripts were applied.

This is a bit of a hassle:

  1. Make a complete file-level backup.
  2. Perform factory reset.
  3. Make another backup.
  4. Restore the backup from step 1.
  5. Diff between 1 and 3.
1 Like

Thought about this, too.
But between 2 and 3 is a reboot. Actually, I want to do this at some remote AP, so I need some automation to get back to the first backup automatically.

1 Like

your welcome to give my a try... beta and very messy but gives you some ideas... ( will be integrating some of the master @vgaetera 's work into it, thanyou! :flamingo: )


Did u remove the link? :confused:

you can find it in the rtfs.tar.gz on the top post here ...

1 Like