Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

General question: How can we autorun that start script to be run on first boot? #64

Open
TheSashmo opened this issue Sep 16, 2021 · 1 comment

Comments

@TheSashmo
Copy link

TheSashmo commented Sep 16, 2021

First of all thanks for this, I love it.

Is there a way to first that start script, or any other script, to run on that first boot? Ideally the hostname and other tools to be ready to go after X or so minutes, then I know the device is up and has all that I need. For example disable screen blanking and other small configurations.

I've been using a disk image to do my cloning, but I find that is not ideal as I make changes over time, and then I need to do the disk image again and a few steps in between.

Suggestions?

@netson
Copy link
Owner

netson commented Sep 17, 2021

I do not know if the installer can run any scripts on first boot, but that may be something to look into. If not, it would probably come down to creating a systemd unit file which runs your script after the userspace has been loaded, but that would require some work on the preseed file and require you to put a whole bunch of commands in the late_command.

Now that I think of it, I assume your first boot is always done by the initially created user? Maybe you could source a custom script in the .bash_rc file, which would make it run on first logon; it would then have to remove itself again once completed to avoid running it on every logon, but it could work.

Maybe some other users have a better solution?

edit: Just remembered there's a thing called cloud-init, which maybe exactly what you are looking for:
https://help.ubuntu.com/community/CloudInit

Also, depending on what it is you are trying to do, you may be better off using tools such as Ansible to configure your server/instance; it is what I have been using for the last 4-5 years and performs approx. 850 tasks depending on the specific use-case for that server (webserver, database, etc). If you're just trying to load your ssh keys for login etc, then cloud-init will do the trick just fine!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants