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' *
(https://github.com/Freifunk-Spalter/packages/issues/18#issuecomment-679139414)

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.

#!/bin/sh
cd /etc/config
for F in *
do
        echo
        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
done

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

2 Likes

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 rollback.sh 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: )

2 Likes

Did u remove the link? :confused:

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

1 Like