OpenWrt Forum Archive

Topic: Is there a method for generating default config files?

The content of this topic has been archived on 4 Apr 2018. There are no obvious gaps in this topic, but there may still be some posts missing at the end.

Let us say that I have an OpenWRT running right now and I would like to know what the default config files generated at boot would look like. Is there a way to do that without harming the running system? I do not want to reboot or change the current config.

It would be nice to be able to generate just individual files, like /etc/config/wireless, but creating a new default directory somewhere would be fine too.

The config files are generated in a distributed way, and the exact methods depend on the platform and router. So, there is no single place with all default files.

For most routers the following things are valid:
(assuming normal squashfs + jffs2 overlay filesystem, mac80211 based wifi etc.)

* There is no backup copy of settings for packages installed by the user via opkg. Those settings are just in /etc/config
* For most of the packages included in the firmware image, the original settings can be found in /rom/etc/config directory
* /etc/config/network is generated by a script at the first boot after flash. No config file copy anywhere.
* /etc/config/wireless is similarly generated at the first boot. But you can re-generate the defaults with "wifi detect" command if you first delete or rename /etc/config/wireless . (The script first checks that there are no settings, so you really need to remove the existing settings file to see the output of the script. )

That's what I was afraid of. Thanks Hynman.

At least wifi detect is pretty uniform across platforms.

One additional hint:
You can use this script to quickly compare your current settings against the defaults in /rom

#!/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

If you have LuCI installed - you could use its "settings back-up" feature.
There will be a *.tar.gz file with all your current settings.
Opening it on another host (with WinZIP or similar) you could inspect each and every configuration file on your router.

Hope that helps.

(Last edited by booBot on 22 Mar 2016, 09:44)

The discussion might have continued from here.