[systemd-devel] How to run *ctl command using systemd-nspawn

Lennart Poettering lennart at poettering.net
Wed Apr 17 08:09:07 PDT 2013


On Tue, 16.04.13 09:11, Koen Kooi (koen at dominion.thruhere.net) wrote:

> Hi,
> 
> To help with flashing the onboard eMMC of a 100000 boards I'm using systemd-nspawn to run package postinstall scripts that generate UUIDs and some other things and it's working great for that! Every board now has a unique value in /etc/machine-id instead it being empty and systemd randomizing it on startup.
> 
> What doesn't work however is something like this:
> 
> 	systemd-nspawn -D ${PART2MOUNT} /usr/bin/timedatectl set-timezone Europe/Paris
> 
> or this:
> 
> 	systemd-nspawn -D ${PART2MOUNT} /usr/bin/hostnamectl set-hostname BeagleBoneBlack
> 
> I know I can run the lowlevel 'ln -sf <zoneinfo> /etc/timezone' or echo the name into /etc/hostname, but I'd like to use the *ctl commands because they work and have error handling built-in. 
> it looks like I would need -b to get the *ctl commands to work, but -b
> doesn't support running single commands and exiting.

timedatectl is just a frontend to timedated. So, without running
timedated inside of the container this is not going to be easy to do.

"systemctl enable" OTOH also can do the unit file changes on the client
side, since we really needed that for chroot(), and the bits it does are
more than just a creating a symlink here or there...

Now, I am not totally against making some "timedatectl" comamnds work
without timedated, but let's just say that it's not really that high on
the top of my list...

I see the use of it, but OTOH "ln" is not thaaat bad to use, and writing
these files with something that isn't timedatectl is absolutely OK the
files are supported stable ABI.

Lennart

-- 
Lennart Poettering - Red Hat, Inc.


More information about the systemd-devel mailing list