chiark / gitweb /
units: rework systemd-nspawn@.service unit
authorLennart Poettering <lennart@poettering.net>
Mon, 29 Dec 2014 11:38:26 +0000 (12:38 +0100)
committerLennart Poettering <lennart@poettering.net>
Mon, 29 Dec 2014 16:00:05 +0000 (17:00 +0100)
- Unescape instance name so that we can take almost anything as instance
  name.

- Introduce "machines.target" which consists of all enabled nspawns and
  can be used to start/stop them altogether

- Look for container directory using -M instead of harcoding the path in
  /var/lib/container

Makefile.am
units/machines.target [new file with mode: 0644]
units/systemd-nspawn@.service.in

index e1e08430863bb60ff45ac5a9cbc4e2b756f28907..28d2e4b53fbfdc7808490d30ffe55f1104417f6d 100644 (file)
@@ -549,6 +549,7 @@ nodist_systemunit_DATA = \
        units/initrd-udevadm-cleanup-db.service \
        units/initrd-switch-root.service \
        units/systemd-nspawn@.service \
+       units/machines.target \
        units/systemd-update-done.service
 
 if HAVE_UTMP
diff --git a/units/machines.target b/units/machines.target
new file mode 100644 (file)
index 0000000..99618a1
--- /dev/null
@@ -0,0 +1,17 @@
+#  This file is part of systemd.
+#
+#  systemd is free software; you can redistribute it and/or modify it
+#  under the terms of the GNU Lesser General Public License as published by
+#  the Free Software Foundation; either version 2.1 of the License, or
+#  (at your option) any later version.
+
+[Unit]
+Description=Containers
+Documentation=man:systemd.special(7)
+Requires=basic.target
+Conflicts=rescue.service rescue.target
+After=basic.target rescue.service rescue.target
+Before=multi-user.target
+
+[Install]
+WantedBy=multi-user.target
index e3eaa53239df2802019e9c01ded87af5c5455cc2..02d663dd24526e0bf1a2ac2772e23d179a9501f1 100644 (file)
@@ -6,11 +6,13 @@
 #  (at your option) any later version.
 
 [Unit]
-Description=Container %i
+Description=Container %I
 Documentation=man:systemd-nspawn(1)
+PartOf=machines.target
+Before=machines.target
 
 [Service]
-ExecStart=@bindir@/systemd-nspawn --quiet --keep-unit --boot --link-journal=try-guest --directory=/var/lib/container/%i
+ExecStart=@bindir@/systemd-nspawn --quiet --keep-unit --boot --link-journal=try-guest --machine=%I
 KillMode=mixed
 Type=notify
 RestartForceExitStatus=133
@@ -18,4 +20,4 @@ SuccessExitStatus=133
 Delegate=yes
 
 [Install]
-WantedBy=multi-user.target
+WantedBy=machines.target