For my daemon, I mounted (several) remote read-only WebDAV folders¹ as "sources" to periodically pull files from. Let $SOURCE be one of them for this question's sake.
Before blindly using $SOURCE, I feel it'd be a good idea to check if the mount is still operational, as WebDAV is not known for superior stability, so checking at mount-time¹ is already done, it might also "break" later².
The following ideas don't seem to fit me:
- Testing for presence of a known remote file:
$SOURCEis not necessarily controlled by me - Testing for presence of anything at all:
$SOURCEmight as well be empty, so there'd be false negatives - Checking output of
mount | grep " $SOURCE ": Can't this produce false positives on netdevs? - Checking result of
mountpoint -q "$SOURCE": Same about false positives?
More:
The check should avoid using inappropriate amounts of network bandwidth and memory. So additionally curling the DAV mounted at $SOURCE and checking for differences in the entire file/folder structure should obviously solve my problem, but also blows up that requirement in any possible way.
The check should work in either bash³+"basic linux stuff" or microperl. Bloating is bad for routers.
I know davfs2 uses a cache. What if it's mounted, the structure is cached and then the connect fails? Wouldn't I end up with tons of empty files in $SOURCE?
¹ I invoke davfs2 from a script. Heard you want me to be precise.
² Actually, my daemon should primarily be deployed in dynamic-IP environments at 24/7 use, so the sources will experience daily internet reconnects.
³ busybox's ash, to be precise again.