Philipp's picture

Hi everybody,

how can I setup the hostname within firstboot via inithooks?



Jeremy Davis's picture

Assuming that you are building via TKLDev then the appliance will inherit the hostname from the top level build code directory. I.e. if your buildcode is /turnkey/fab/products/foobar then the hostname will be 'foobar' by default.

If you are pre-seeding, then you can set the hostname by setting "HOSTNAME" in the pre-seed file. E.g.: a line that says 'HOSTNAME=barfoo'.

If you want it to be interactive, then you'll need to create a script to do that as there isn't an existing inithook to do that. If you're familiar with python, then you can leverage inithooks to create a new script that sets the hostname. Drop your new script into overlay/usr/lib/inithooks/bin/ and create a new (executable) firstboot script (in overlay/usr/lib/inithooks/firstboot.d/) that calls it. The existing 09hostname firstboot script might be a useful reference? And/or the Confconsole hostname plugin.

I hope that helps. If you need further clarifcation and guidance, please ask.

Add new comment