[systemd-devel] Orchestrating a shutdown immediately after boot

Kerrick Staley kerrick at kerrickstaley.com
Mon Jul 8 00:08:29 PDT 2013


I'd like my system to:
1. boot
2. run a command
3. shut down

I've implemented step 2 in a .service file [1], but I can't figure out how
to automatically shut the system down once it's finished. shutdown.target
conflicts with all services that don't set DefaultDependencies=false (which
is most of them), so it seems I'm out of luck—there is no way to specify a
target that requires both multi-user.target and shutdown.target. Is there
some way to handle this situation?

N.B. This is all running in an LXC; the overarching goal is to sandbox the
command so it can't affect the rest of the system.

- Kerrick

[1] If it's useful, the .service file is as follows:
[Unit]
Description=Sandboxed Checkerbox command
After=multi-user.target

[Service]
User=user
Type=simple
ExecStart=/bin/sh -c '/home/user/cmd </home/user/stdin >/home/user/stdout
2>/home/user/stderr'

[Install]
WantedBy=multi-user.target
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/systemd-devel/attachments/20130708/d98a977b/attachment.html>


More information about the systemd-devel mailing list