Is there a way to trigger a custom script after sysupgrade (with Attended Sysupgrade)?

Hi All,

I'm not sure if this has been asked before but I hope somebody can point me in the right direction.

Setup:

  • Attended Sysupgrade
  • Hotplug enabled/installed - not sure if this can help
  • Flash Drive (auto-mounted)
  • Additional customization in flash drive

Todo:

  • Custom script to install additional configuration and additional user-installed packages

What I'm trying to do:

  • Auto-run (if possible), the custom script after the sysupgrade is done to do additional setup and install additional packages not available in the openwrt repo

Question:

  1. Is even the Autorun possible?
  2. Can somebody point me in the right direction to do this if possible?

Not really.

On the one hand auc can't allow injecting custom (not provided by OpenWrt's repositories) packages/ scripts, as this would open the door to command injection attacks against the auc servers - on the other hand, sysupgrade drops to a very limited initramfs like environment to commence the upgrade, what isn't covered for by basefiles' sysupgrade support simply isn't available at that stage (and there isn't any 'plugin' infrastructure beyond that, nor really any means for more complex functionality beyond $WRITE_IMAGE and $REBOOT, the network is down at that point anyways, and what isn't in the image, simply won't be reachable anymore).

At some point you will have to build from source (or at least run the imagebuilder yourself, injecting your own packages/ scripts).

I don't actually want to inject custom scripts inot auc but more of trigger a script after the reboot (after sysupgrade is done).

I think I saw a hotplug via the opkg extra scripts to restore packages. I'm not sure if this is sufficient or near what I'm thinking of.

I use the normal rc.local script to install packages on reboot; It will be triggert on every reboot, but on already installed packages it doesn't do anything.

1 Like

You should use uci-defaults for that. Despite their name, those scripts provide generic run-once functionality.

1 Like

What/which commands do you run to install the packages?

Thanks.. will check this out