[LEDE-DEV] How do I run a script once after factory installation?
John Crispin
john at phrozen.org
Fri Sep 16 05:35:30 PDT 2016
On 16/09/2016 14:14, J Mo wrote:
>
> 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?
not really. that would be device specific
> 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?
there are these
target/linux/brcm63xx/base-files/etc/uci-defaults/09_fix_crc
target/linux/brcm47xx/base-files/etc/uci-defaults/09_fix_crc
target/linux/bcm53xx/base-files/etc/uci-defaults/09_fix_crc
target/linux/ramips/base-files/etc/uci-defaults/09_fix-seama-header
target/linux/ar71xx/base-files/etc/uci-defaults/09_fix-trx-header
which all do essentially do what you want but for different platforms
> 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.
More information about the Lede-dev
mailing list