You are not logged in.

#1 2021-01-24 21:10:19

expatiate-orangutans
Member
Registered: 2019-07-11
Posts: 6

Automatically running a custom script in archiso

I've installed arch quite a few times now, and next time around I'd like to simplify & automate the install. Partly because I tend not to explore all the options I'd otherwise want to because doing the install isn't automateable & repeatable.

I've never built a custom archiso image, but I found [ https://git.archlinux.org/archiso.git/ ] and the build instructions look simple enough. So assuming I can cut an image without difficulty, here's what I'd like to do.

0. Write a shell script which does something, such as running

iwctl <some args>
timedatectl set-ntp true

(i.e. the steps under https://wiki.archlinux.org/index.php/In … _internet)

1. Build an image.
2. Boot a machine with that image.
3. Afer the boot process finishes doing everything else it normally does, it runs my script.
4. Now when I autologin as root in the live env, I'm already on wifi & the clock is already updated.

I probably want to do more things than just connect to the internet, but this is just to make it more concrete.

So what's a reasonable way to do this? One way I see is to follow the instructions at [ https://wiki.archlinux.org/index.php/Ar … temd_units ] for enabling gpm.service, by replacing it with just-run-my-script.service which is of Type=oneshot, and which I would add at archiso:/configs/releng/airootfs/etc/systemd/system/. Does this sound like a good way of doing this? Is there a better & simpler way?

Offline

#2 2021-01-24 21:54:57

qinohe
Member
From: Netherlands
Registered: 2012-06-20
Posts: 1,494

Re: Automatically running a custom script in archiso

The ISO live system basically follows the same rules a normal system does, so yes it's possible.
Which also means anything you would like your live system to do once it started follows that same logic.
It doesn't matter if you build an ISO with a complete X environment or an installer that should start once you booted the Live system, everything follows the same logic as would a system installed on your HD.
Have a look at https://wiki.archlinux.org/index.php/Archiso (or maybe you did already;-)

Offline

#3 2021-01-25 09:12:07

nl6720
The Evil Wiki Admin
Registered: 2016-07-02
Posts: 596

Re: Automatically running a custom script in archiso

expatiate-orangutans wrote:

That repo is not updated anymore. Archiso now lives on Arch's GitLab: https://gitlab.archlinux.org/archlinux/archiso/.

If you didn't need to configure iwd for Wi-Fi, you could simply use the official ISO and boot with the (currently undocumented) script= parameter. E.g.:

script=http://example.com/my-script.sh

You can read what it does in https://gitlab.archlinux.org/archlinux/ … _script.sh.
Since you need Wi-Fi, then the instructions in https://wiki.archlinux.org/index.php/Ar … _using_iwd should work.

As for running commands, you can use a oneshot service or you can edit airootfs/root/.zlogin to launch you script. Or many other ways.

Offline

Board footer

Powered by FluxBB