WOL with autofs

If I set up a video source using the Kodi-level NFS client mechanism, and if I activate the option Settings -> System -> Power saving -> Try to wakeup remote servers on access, then this seems to work as expected - if I browse into the source folder while the server is in sleep mode, the Vero 4K+ sends a WOL packet and wakes it up.

However, if the source is mounted at OS level using autofs, it doesn’t send a WOL packet (possibly because Kodi thinks the folder is in local storage, and it’s only at the OS level that it knows it’s a mounted remote NFS export).

Is it possible to get the Vero 4K+ to send a WOL packet under those circumstances?

Have a look at this: Odds and ends with a technical slant.: Linux autofs and Wake on Lan bodge.

I think that will do what you are looking for. I haven’t tested it since I don’t use WOL.

That would be correct, Kodi thinks they are local files.

@angry.sardine (or should I call you Bagpuss :wink: ) I got curious about this, so I setup one of my laptops to test WOL. If you can give me a few days, I think I can come up with a nice easy to setup solution for this. The idea I’m working on is to use a Python script instead of the shell script I linked, and will not require installing anything via apt. I’ve got the script so it can do the WOL, I just need to get it working with autofs now.

Yes, please. :slight_smile:

Gave you 9. :slight_smile: Did you make any progress on this?

Sorry, I was thinking of giving you an update. I had almost gave up on the idea as it seemed that the --timeout option didn’t work. After several days, I finally figured that one out.

So I have a basic WOL autofs script working, it just needs fine tuning now.

1 Like

@angry.sardine I have a basic python script working now that does the WOL (if needed), waits for the mount (smb or nfs) to become available and then does the mount. It’s a bit finicky right now. To help me understand it it will work for you, could you get me your auto.master and auto.maps so I can understand how you are using autofs and if the script will work for you? If you don’t want to share them here, please PM them to me.

/etc/auto.master :

#
+dir:/etc/auto.master.d                                  
#                                                        
# Include central master map if it can be found using    
# nsswitch sources.
#
# Note that if there are entries for /net or /misc (as
# above) in the included master map any keys that are the
# same will not be seen as the first read key seen takes 
# precedence.                                            
#
+auto.master
 /- /etc/auto.nfs.shares --timeout 15 browse

/etc/auto.nfs.shares :

/mnt/nicolas-pc/Interim 192.168.1.13:/Interim
/mnt/nicolas-pc/VideoE 192.168.1.13:/VideoE              
/mnt/nicolas-pc/VideoF 192.168.1.13:/VideoF
/mnt/nicolas-pc/QBTE 192.168.1.13:/QBTE                  
/mnt/nicolas-pc/QBTF 192.168.1.13:/QBTF

I’m afraid I don’t know where to find auto.maps :frowning_face:

That’s what I needed. One more question, are there files in the directories, or is everything in a subdirectory.

i.e. are there any files in /Interim, or is everything in directories under that like /Interim/x?

Note that my previous post initially went a bit wonky - I’ve edited it, and I think it’s correct now. (Formatted text needed some kicking when input from a mobile web browser).

There are likely to be both files and subfolders in all of those shares, I’m afraid. :slight_smile:

Unfortunately, what I’ve been able to get working will not allow files in the parent directory, only in sub directories. It seems to be a limitation of autofs that I haven’t been able to work around yet.

With that I have working, you would be able to access anything in a directory under /Interim, but not able to access files in /Interim.

That’s one of the reasons why it’s taken me some time to get back to you as I’ve been struggling with a way to mimic the /- way in autofs. For some reason when using a script with autofs the /- syntax that allows access to files in the parent directory does not work.

I will keep trying. I will have a script for you to test in the next few days (REALLY THIS TIME!!!) with that limitation.

:rofl:

Okay, thanks. :sunglasses:

:face_with_raised_eyebrow:

‘Is there anybody there?’ said the Traveller,
Knocking on the moonlit door;
And his horse in the silence champed the grasses
Of the forest’s ferny floor:
And a bird flew up out of the turret,
Above the Traveller’s head
And he smote upon the door again a second time;
‘Is there anybody there?’ he said.

I’m not that clued up on autofs, but this should do the trick: Google Translate

I hadn’t given up on the idea, but while I can send a WOL packet via an autofs script, it is not at all reliable. I’ve been testing my script for weeks and just can’t get reliable WOL working. Maybe 50% of the time I can get it to work.

So as of now, I’ve decided that the script just isn’t currently feasible. The only way I can see to do it would maybe build in a WOL feature in autofs, but that’s mostly written in C and my C is very rusty.

I’d like to bring this one up again, just in case anything has changed recently that might make a direct solution more feasible than it used to be (e.g. the fact that I’m now running Buster and 4.9 kernel, either of which could conceivably make a difference).

Recap of issue:

If you set up a Kodi level NFS source, you can have Kodi send a WOL packet to the server to bring it out of sleep mode if it isn’t responding. But if the NFS source is mounted via autofs then, as far as Kodi is concerned, the files are in a local folder; so it doesn’t know it needs to send a WOL packet. What I’d like is for the operating system or autofs to do the same job - if the remote NFS source isn’t responding, send a WOL packet.

There are a few suggestions around the web for getting WOL working with autofs, but my neglible Linux skills are not up to the task of translating them to an OSMC autofs setup.

For some time, as a work-around, I’ve been using the Kodi Callbacks add-on to send a WOL packet to the server every time I press any button on the remote. That’s a little wasteful - sometimes wakes up the server when it doesn’t need to - but it used to work okay. Unfortunately, since upgrading to the 4.9 kernel, Kodi Callbacks events generally don’t fire any more, so the work-around is no longer effective.

Can anyone solve this at the autofs level?

Yes it can be done - you can setup autofs to run a script and I’ve had that setup before (even to the point of it working out what server to wake up based on the directory you’re trying to access) where it would send the magic packet and then check if the target had woken up with a ping before passing back to autofs.

The sending of packets can get iffy depending on router/network setup though. I seem to remember sending it to my router and having that forward the packet across broadcast.

I’ll see if I can find the setup I had and simplify it but no promises. The other caveat is it was generic Linux rather than OSMC specific but I’m pretty sure I had it running on an RPi install of OSMC.

EDIT:

Actually, before I do that - was there a reason for avoiding the installation of new packages via apt before? In my case I used the wakeonlan command installed via apt. Autofs called ksh script which triggered wakeonlan and eventually returned the necessary mountpoint.

I’m currently unable to try this out myself but the autofs scripts that @eightiescalling mentions are described here: mount - Are there programmable automount/autofs hooks in linux/systemd? - Stack Overflow