The most appropriate way to run a script on firstboot and after fw updates?

I have a device running my self-compiled firmware (typically master), and I wand to persist some changes that would otherwise get lost after fw updates (even with the "keep configuration" option checked). The most important changes are some services I added to /etc/init.d. Should I write an installation script that checks for the services and reinstall them if they don't exist, and call my script in my rc.local? Will changes I made to rc.local persist over a firmware update (assuming I opted to keep my configuration)?

If it's just about retaining files (not elf binaries, but scripts or configuration) over sysupgrades, the answer would be /etc/sysupgrade.conf. If you really need them to be available after firstboot, you need to look into uci-defaults scripting.

3 Likes

Ah, this seems to be the thing I'm looking for. I've placed /etc/init.d/MyService into the list for now, hopefully that will be enough to make this service persist. The actual binaries are installed on an external device, so all I really need is getting this config to stick. Thank you.

Depending of what you'll need to do...

/lib/preinit/myScript
/etc/init.d/myService
/etc/uci-defaults/myScript

look for my own task at my GIT; https://github.com/erdoukki/vrac/tree/master/openwrt in files, or in this topic; How to automate upgrade?

1 Like
1 Like

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.