Flash router w/o settings - create a script for config?

Hi, despite my kind of cryptic topic what I try to do is:

  • backup my settings to be used with a script. especially vpn config (router running a openvpn server, I don't want to repeat that process)

  • flash the latest davidc502 build without keeping my settings, getting a clean build.

  • run the script to put in openvpn settings, wlan, switch and so on settings

My first hit researching was this;

if you flash your device regularly, preferably consider unchecking “Keep Settings” every time you flash the router and instead create a custom installation script for your customization. Example: config-openwrt.sh script.

Thanks in advance :slight_smile:

The most trivial solution would be to create a script, containing all UCI-cmds to modify the generic image. Upload the script to /tmp after flash, and run. Reboot. Done (assuming, you did not forget final "uci commit" in your script :-).

Ok, I kind of know what you mean, but would that mean a lot of "copy pasting" for me to create this type of script? for instance the different keys/textstrings that openvpn create, would that be 1 uci cmd, or several?

I'll look into it, but I was thinking extracting for instance etc/config/ and somehow use a command to update router based on the info from /config, from /opevpn and so on.. :slight_smile: Less work?

You can also copy a customized, working /etc/config/network, /etc/config/openvpn etc. to a flashed, generic device, to overwrite the default configuration.

Lot of other possibilities, depending on, whether it is an operation, to be done once in a while, to just one device, OR a high-volume activity, copying the config to a lot of devices.

Ok, yes that's what I'm looking for. Feeling a little stupid now...

Click "Generate archive" to download a tar archive of the current configuration files.

When I look at the the content in that .rar file, it seems to contain all config I would need to be back on track with a generic device?

edit: I've not tested this because openvpn setup process was really a struggle last time, not sure if putting in the vpn config will be enough to have it actually working?

I doubt it. I suspect special rules required for firewall, or routing.