Gentoo Archives: gentoo-amd64

From: Marc Joliet <marcec@×××.de>
To: gentoo-amd64@l.g.o
Subject: Re: [gentoo-amd64] Systemd migration: opinion and questions
Date: Sat, 14 Mar 2015 13:02:23
Message-Id: 20150314140216.009128b9@marcec.fritz.box
In Reply to: Re: [gentoo-amd64] Systemd migration: opinion and questions by Marc Joliet
1 Am Sun, 1 Mar 2015 19:20:02 +0100
2 schrieb Marc Joliet <marcec@×××.de>:
3
4 [...]
5 > But actually, while putting off finishing this email, I came to the realisation
6 > that I could of course use WantedBy= in [Install], and following that idea I
7 > ended up with the following [Unit] and [Install] sections:
8 >
9 > [Unit]
10 > Description=Run hourly backups (timer)
11 > Requisite=media-MARCEC_BACKUP.mount
12 > BindsTo=media-MARCEC_BACKUP.mount
13 > After=media-MARCEC_BACKUP.mount
14 >
15 > [Install]
16 > WantedBy=timers.target
17 > WantedBy=media-MARCEC_BACKUP.mount
18 >
19 > So the mount point and the timer both depend on each other (with the mount unit
20 > starting first), so the mount tries to start the timer and vice versa, but only
21 > the timer fails if the mount point doesn't exist. And the BindsTo sees to it
22 > that the timer disappears if the mount does. Preliminary tests show that it
23 > works: unmounting with udiskie shows that the backup timer disappears, and it
24 > re-appears after mounting the file system again.
25 >
26 > I'll have to see what the behaviour is during a cold boot. The Requisite
27 > dependency on the mount point *should* make the Restart line in the
28 > corresponding service obsolete, since the WantedBy should make the timer start
29 > once the mount point shows up. I could probably alternatively use
30 > ConditionPathIsMountPoint instead, but I think I prefer the timer failing.
31 [...]
32
33 Just FYI: I undid that fairly quickly since BindsTo is a superset of Requires,
34 thus systemd waits for 1m30s for the mount point to show up. Ouch.
35
36 --
37 Marc Joliet
38 --
39 "People who think they know everything really annoy those of us who know we
40 don't" - Bjarne Stroustrup