On Sat, 2021-03-13 at 08:49 -0500, Jonathan Billings wrote:
On Mar 12, 2021, at 19:05, Ed Greshko <ed.greshko(a)greshko.com>
wrote:
>
> I don't think systemd was meant to solve these sorts of issues
Honestly, systemd is more equipped to handle this kind of issue than any init system
before it. Being able to attach dependencies in a .mount unit to a .service unit is
something that would have required a bunch of hacks or the autofs service.
I use a network filesystem every day that has a .mount unit that requires a .service to
be launched before it can be mounted (kAFS, see kafs-utils package). It isn’t as
complicated as the usb power on/off, but not outside of the realm of possibility.
I modified the .mount and .service files from kasf-client, and added a
.automount file. I also commented out the appropriate line in
/etc/fstab.
# cat raid.mount
[Unit]
Description=External raid mount
ConditionPathExists=/raid
Wants=dock.service
[Mount]
What=none
Where=/raid
Type=ext4
[Install]
WantedBy=local-fs.target
# cat dock.service
[Unit]
Description=Power the dock up or down
After=local-fs.target
DefaultDependencies=no
[Service]
Type=oneshot
#ExecStartPre=/sbin/modprobe -q kafs
ExecStart=/usr/local/bin/dock up
ExecStop=/usr/local/bin/dock down
# cat raid.automount
[Unit]
Description=Automount /raid
[Automount]
Where=/raid
TimeoutIdleSec=300
[Install]
WantedBy=multi-user.target
I then rebooted:
# findmnt /raid
# # systemctl list-units|egrep dock\|raid
raid-check.timer loaded active waiting Weekly RAID setup health check (not relevant
here)
So nothing I did appears to have had any effect. The
/usr/local/bin/dock script, which logs its activity, is not being
called. The raid.automount is not running, and attempting to access the
/raid directory does nothing. There is nothing related to either 'dock'
or 'raid' in the journal.
I assume there must be a basic error here, but I'm at a loss.
poc