Am Sun, 1 Mar 2015 19:20:02 +0100 schrieb Marc Joliet <mar...@gmx.de>:
[...] > But actually, while putting off finishing this email, I came to the > realisation > that I could of course use WantedBy= in [Install], and following that idea I > ended up with the following [Unit] and [Install] sections: > > [Unit] > Description=Run hourly backups (timer) > Requisite=media-MARCEC_BACKUP.mount > BindsTo=media-MARCEC_BACKUP.mount > After=media-MARCEC_BACKUP.mount > > [Install] > WantedBy=timers.target > WantedBy=media-MARCEC_BACKUP.mount > > So the mount point and the timer both depend on each other (with the mount > unit > starting first), so the mount tries to start the timer and vice versa, but > only > the timer fails if the mount point doesn't exist. And the BindsTo sees to it > that the timer disappears if the mount does. Preliminary tests show that it > works: unmounting with udiskie shows that the backup timer disappears, and it > re-appears after mounting the file system again. > > I'll have to see what the behaviour is during a cold boot. The Requisite > dependency on the mount point *should* make the Restart line in the > corresponding service obsolete, since the WantedBy should make the timer start > once the mount point shows up. I could probably alternatively use > ConditionPathIsMountPoint instead, but I think I prefer the timer failing. [...] Just FYI: I undid that fairly quickly since BindsTo is a superset of Requires, thus systemd waits for 1m30s for the mount point to show up. Ouch. -- Marc Joliet -- "People who think they know everything really annoy those of us who know we don't" - Bjarne Stroustrup
pgpAKM1wzODGg.pgp
Description: Digitale Signatur von OpenPGP