Ich habe ein kleines Problem mit einem selbstdefinierten systemd-target unter Debian Sid. Zunächst ein paar Systeminformationen:
Code: Alles auswählen
root@server:~# uname -a
Linux server 4.6.0-1-amd64 #1 SMP Debian 4.6.4-1 (2016-07-18) x86_64 GNU/Linux
root@server:~# systemd --version
systemd 231
+PAM +AUDIT +SELINUX +IMA +APPARMOR +SMACK +SYSVINIT +UTMP +LIBCRYPTSETUP +GCRYPT +GNUTLS +ACL +XZ -LZ4 +SECCOMP +BLKID +ELFUTILS +KMOD +IDN
root@server:~#
Systemd möchte ich nun folgermaßen einsetzen. Gemäß der Beschreibung im Arch Wiki unter https://wiki.archlinux.org/index.php/Rs ... Automation habe ich einen rsnapshot@.service eingerichtet und mein selbst erstelltes target als Abhängigkeit eingetragen und per After-Direktive dafür gesorgt, dass das target gestartet ist, bevor rsnapshot startet.
Code: Alles auswählen
root@server:~# cat /etc/systemd/system/rsnapshot@.service
[Unit]
Description=rsnapshot (%I) backup
Requires=vm-snaphots.target
After=vm-snaphots.target
[Service]
Type=oneshot
ExecStart=/usr/bin/rsnapshot -c /etc/rsnapshot.conf %I
root@server:~#
Code: Alles auswählen
root@server:/etc/systemd/system# cat vm-snapshots.target
[Unit]
Description=Grant access to all VM images as filesystem
StopWhenUnneeded=yes
root@server:/etc/systemd/system#
Code: Alles auswählen
root@server:/etc/systemd/system# cat access-qcow2-fs@.service
[Unit]
Description=Grant access to a read-only snapshot of %I's qcow2 drive
[Service]
Type=oneshot
RemainAfterExit=true
ExecStart=/opt/access-qcow2-fs.sh start %I
ExecStop=/opt/access-qcow2-fs.sh stop %I
[Install]
WantedBy=vm-snapshots.target
root@server:/etc/systemd/system#
Code: Alles auswählen
root@server:/etc/systemd/system# systemctl enable access-qcow2-fs@newvm
Das target funktioniert auch insofern, als dass ich es direkt aufrufen kann:
Code: Alles auswählen
root@server:/etc/systemd/system# systemctl status vm-snapshots.target
● vm-snapshots.target - Grant access to all VM images as filesystem
Loaded: loaded (/etc/systemd/system/vm-snapshots.target; static; vendor preset: enabled)
Active: inactive (dead)
Aug 06 20:32:00 server systemd[1]: Stopped target Grant access to all VM images as filesystem.
Aug 06 20:35:18 server systemd[1]: Reached target Grant access to all VM images as filesystem.
Aug 06 20:35:18 server systemd[1]: vm-snapshots.target: Unit not needed anymore. Stopping.
Aug 06 20:35:18 server systemd[1]: Stopped target Grant access to all VM images as filesystem.
Aug 06 22:05:00 server systemd[1]: Reached target Grant access to all VM images as filesystem.
Aug 06 22:05:00 server systemd[1]: vm-snapshots.target: Unit not needed anymore. Stopping.
Aug 06 22:05:00 server systemd[1]: Stopped target Grant access to all VM images as filesystem.
Aug 08 20:54:48 server systemd[1]: Reached target Grant access to all VM images as filesystem.
Aug 08 20:54:48 server systemd[1]: vm-snapshots.target: Unit not needed anymore. Stopping.
Aug 08 20:54:48 server systemd[1]: Stopped target Grant access to all VM images as filesystem.
root@server:/etc/systemd/system#
Code: Alles auswählen
root@server:/etc/systemd/system# systemctl start rsnapshot@daily
Failed to start rsnapshot@daily.service: Unit vm-snaphots.target not found.
root@server:/etc/systemd/system#
Code: Alles auswählen
systemctl daemon-reload
Freue mich über Tipps!