> if I understood you correctly you propose to run a script in the background to check for
> the condition I am interested in (is the nfs server available?) and do the changes accordingly.
If by "do the changes" you mean mount the shares.
> In fact I am doing this at the moment. But I think its an ugly hack and thought a better solution
> should be possible with systemd only. E.g. in my case I have to check the availabilty of the server
> every some seconds (same as in your script), while in fact it does need to be checked only in the
> case the share is to be mounted. That would be much more elegant and efficient.
On Demand might work for your use case, where I assume you have
control over whatever is demanding access to the resource.
I've not used it, but autofs seems to have what are termed
"executable maps", which might be coerced into running a ping
script that, if it fails, aborts the mounting operation.
But I can't see the point in the system waiting until you
want a share before it attempts to see if it's there and
mounts it. What does it gain you? It's not like a USB stick,
where the system doesn't even know it exists until plugged in.
I would want the shares to be there, ready when I reference
them. That's efficient for the user. I couldn't care less
about the machine making such an efficiency saving.
On Demand wouldn't work with the example I showed. If I select
Roku Media Player on the TV, the streaming port, 8200, has to
be available already, or the TV won't display that host.
Mounting a new directory at that time, and then restarting the
server, would kick the Player off that host, and make you
have to connect to it again.
> Seems systemd is still not used very much actively. I mean most people run it, but they dont write
> their own stuff for it. When looking for information on shell scripts, I normally find the solution
> on google after 1 min. In case of systemd I googled a long time with no result and even posting to
> different mailing lists/forums did not help.
I'm not sure what writing stuff for it includes. Usually I don't
have to do much more than copy a /lib file to /etc and tweak it.
If I needed a new one, I'd just copy and modify the one that
looked closest to what I wanted (programming by example).
As for shell scripts, do you mean those in /etc/init.d/?
In the past, I found that distributions varied so much in
how they were written that most "solutions" were outdated
or didn't match up with the scripts in Debian. Even if you
understood some of these scripts, others were just as opaque
at first sight, because it's difficult to enforce a standard
on them.
There's a fair quantity of systemd man pages now:
$ find /usr/share/man/man* -name \*systemd\* | wc -l
187
$
and I found the
http://0pointer.de Systemd for Administrators
a very useful introduction in the early days (available by the
time jessie was released) when man pages were thinner on the
ground, IIRC.
Cheers,
David.