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

Lennart Poettering lennart at poettering.net
Wed Apr 17 10:03:31 PDT 2013


On Wed, 17.04.13 17:36, Zbigniew Jędrzejewski-Szmek (zbyszek at in.waw.pl) wrote:

> > we could add a generator to systemd which looks for "systemd.run=" or so
> > on the kernel cmdline and simply generates throw-away unit files from
> > that, that runs the specified command(s) and triggers a shutdown
> > afterwards... Would that work for you?
> > 
> > i.e. you'd then call:
> > 
> > systemd-nspawn -bD /srv/foobar \
> >                systemd.run='/usr/bin/timedatectl set-timezone Europe/Paris' \
> >                systemd.run='/usr/bin/timedatectl set-hostname BeagleBoneBlack'
> > 
> > and so on...
> > 
> > I think that would be reasonably pretty?
>
> An alternative idea: let's a tool which waits until startup is finished.
> (Unless I'm mistaken, there's dbus support with StartupFinished, but
> not a ready tool which waits.)

well, but watching dus from the outside is kinda hard, since we don't
know when the socket is up. THis would become easier with kdbus, (where
the bus would be created very early on in PID1 and would be visible
outside), but there still would be a small window, where dbus wouldn't
be accessible...

> Then one would inject into the container, wait for it to return,
> and then inject other commands.
> 
> The advantage would be in better error handling and scriptability.

But you'd have a process in the container that would be kinda foreign,
wouldn't even be in the container's cgroup, would inherit all kind of
weird stuff from the outside...

Lennart

-- 
Lennart Poettering - Red Hat, Inc.


More information about the systemd-devel mailing list