Run script on first boot

I am using torizoncore-builder, but there are a few things I will proably have to do via scripts on first boot:

  • change permission of the volume folders bound to the containers
  • detect if an SD card is present and format it

I suppose the best solution is to use a shell script which runs on first boot and then deletes itself or renders itself inactive by setting a flag.

Since there are several mechanisms to do this, I am wondering what is the recommended way for torizon?

  • cronjob
  • /etc/rc.local
  • init.d
  • systemd

Thanks,
Andreas

Greetings @amueller,

Ultimately all of these are perfectly capable of running a simple script. I guess the question is more so if you require any specific features.

For example if you want a bit more control on the script then I’m partial to systemd. Since with systemd you can construct a service with dependencies/checks on other services, as well as get logging from the service for debugging/error checking.

If you just want to execute a simple script and nothing more than the init.d approach would be just fine.

As as side-note though if you ever plan to use the OTA feature with Torizon, then the only information that is persistent is /etc and /var. Though I believe most of these methods use /etc so they should be OTA safe, though do keep this in mind.

Best Regards,
Jeremias

I got it working using systemd.

Perfect glad to hear you got a solution that works for you.

Best Regards,
Jeremias