You are not logged in.
Hi,
I am currently setting up a script which automatically goes through the installation process of Arch Linux. Currently I am at the stage where I want to run some systemd commands, namely:
hostnamectl set-hostname ...
localectl set-locale LANG=...
localectl set-keymap ...
timedatectl set-ntp true
timedatectl set-timezone ...
To run commands inside the bootstrapped container I use arch-chroot. The problem I am experiencing, however, is that these commands only run with a bus connection. This connection is not present at this stage of the installation process (surprisingly, systemctl does not require a bus connection):
[root@archiso ~]# arch-chroot /mnt hostnamectl set-hostname foo
Failed to create bus connection: No such file or directory
I am aware that for each of these commands there is a more low-level alternative that I could resort to, e.g. echo the hostname to /etc/hosts instead of using hostnamectl. However, I would like to use the aforementioned systemd wrappers if possible. I would also like to avoid (re)booting to the container to create a bus connection since that would be awkward to do in a scripting solution (I also checked systemd-nspawn).
Is there any way to execute those commands in the container at the very first boot?
Cheers
Last edited by STaRDoGG (2016-01-01 13:10:28)
Offline
Why not place a script in the chroot that executes those commands? Then you could do something like
arch-chroot /mnt /bin/bash -c /my_install_script.sh
Not sure if this works, though. But I guess it would be a lot more elegant than chroot'ing into and out of an environment for each command.
Offline
Not sure if this works, though.
Doesn't work.
Offline
I am aware that for each of these commands there is a more low-level alternative that I could resort to...
Resort to? What do you think those fancy tools end up doing? I don't understand your insistence on needing an extra layer here.
Offline
Try systemd-nspawn
Offline
Why not place a script in the chroot that executes those commands? Then you could do something like
arch-chroot /mnt /bin/bash -c /my_install_script.sh
Not sure if this works, though. But I guess it would be a lot more elegant than chroot'ing into and out of an environment for each command.
This could be simplified to:
arch-chroot /mnt /my_install_script
Doesn't work.
Here it does.
Are you sure that your script is located at /mountpoint/scriptname and called as /scriptname?
Offline
Here it does.
Are you sure that your script is located at /mountpoint/scriptname and called as /scriptname?
The script runs of course. The missing bus connection problem remains though.
[root@archiso ~] echo "hostnamectl set-hostname foo" > /mnt/my_install_script
[root@archiso ~] chmod o+x /mnt/my_install_script
[root@archiso ~] arch-chroot /mnt /my_install_script
Failed to create bus connection: No such file or directory
Last edited by STaRDoGG (2016-01-02 13:50:23)
Offline
Like you mentioned yourself, if you had echod the hostname to /etc/hostname you would be done right now. It's even how it's recommended in the installation guide. The same goes for the rest of the commands (I'm not entirely sure about the ntp one but I dare guess that's just enabling a systemd service).
You're not doing anything wrong by doing it that way. I agree with Scimmia. It's easier, takes less time and you can probably boast about it at birthday parties. What more could you possibly wish for?
Offline
Like you mentioned yourself, if you had echod the hostname to /etc/hostname you would be done right now.
I'm currently doing it that way and it's not a big deal. I was just wondering if it is possible to use the systemd wrappers for t his purpose at the very first boot.
Offline
Doesn't sound impossible. You could try starting a D-Bus daemon. There seems to be a systemd abstraction for that: /usr/lib/systemd/user/dbus.service
But I wouldn't be surprised if they might as well want to use the message bus for something if they require it (checking if systemd-unicornd is free tonight?) so maybe you'll need to launch other things too.
For science, I guess. :-)
Offline