[LEDE-DEV] How do I run a script once after factory installation?

J Mo jmomo at jmomo.net
Fri Sep 16 05:14:41 PDT 2016


The router device that I'm currently working on has some goofy failover 
system where it has two roofs filesystems (UBI) on it's NAND flash.

A special partition has a "upgrade-in-progress" bit that gets set and I 
need to flip it back to 0x0 after a successful system bootup. If I 
don't, the bootcmd program in u-boot detects the bit, assumes an 
upgrade/installation failure, and fails back to the old/previous rootfs.

Currently, this only affects factory installations installed from the 
OEM web UI upgrade tool, but I might like to make sysupgraded 
installations use it. I am not sure yet if I want to bother supporting it.

Thus, this needs to happen only once after the system has been 
upgraded/installed by a factory installation, and optionally a 
sysupgrade installation.

So my questions are:

1.) Is there a way to determine if the current boot was from a factory 
install vs sysupgrade?

2.) Where is the appropriate place to do a run-once kind of thing? Like 
/etc/uci-defaults/ or sysupgrade's restore_config function. This would 
be an S99-like task; run at the very end of the boot process once we are 
sure the system has booted successfully.

Any examples anyone can point me to of anything similar before I 
re-invent something that might already exist?

If this had to run on every single boot, even non-upgrade boots, I could 
probably work with that by checking if the upgrade-in-progress bit is 
even set, but I figured I would ask if I could do a "run once after 
factory install" kind of thing first.

Thanks in advance





More information about the Lede-dev mailing list