Project

General

Profile

Waking an OMV NAS on TVH server start/reboot

Added by Spencer Cummings over 5 years ago

So, I originally posted this as a question a few months back, and having gotten it working with the help of the OSMC forums thought I'd post the answer here in case anyone else was out there looking to do the same. My original post was this:

"I have a Pi running TVH, and an NFS mount to an OMV server to hold the recordings. I've noticed that if I restart the Pi when OMV server isn't up, TVH will write recordings locally into the mount folder...and all the existing recordings, (on the OMV file share), get moved to 'Removed Recordings'. If I reboot the Pi when the OMV server is running all is well, new recordings go to the OMV share and the existing recordings are back where they belong in 'Finished Recordings'. I figure that my best bet is to run the wol script, which is just a simple 'wakeonlan' command using the MAC of the OMV server, on startup/reboot of the Pi...mostly to save me having to remember to do things in the correct order! However, searching on how to do it gives me multiple options...rc.local, .bashrc, init.d tab, systemd, and crontab. Far too many choices for a noob like me :) Looking for some advice on the right way to add the script...or am I missing a trick in the config of the nfs mount I have in /etc/fstab? This is currently: IP:/PVR mnt/PVR nfs defaults 0 0"

The advice I got was to do the following:

1. Change the line in /etc/fstab to be as follows to bring the mount under the systemd automount system:

IP:/PVR mnt/PVR nfs  noauto,x-systemd.automount  0 0

2. TVH is using the System V init system, (as far as I know anyway), and the init file gets dynamically translated into a systemd .service file at system startup. You can use a systemd drop-in to alter a generated .service unit. I did this by adding a file named 'tvh.conf' into /etc/systemd/system/tvheadend.service.d/ containing the following:

[Unit]
After=mnt-PVR.mount network-online.target
Wants=mnt-PVR.mount network-online.target
[Service]
ExecStartPre=/home/hts/wol.sh

The wol.sh script is a simple 'wakeonlan' command to wake the OMV NAS box and then wait 15 seconds, more than enough time for it to spring into life. I use this same script in the 'Pre-processor command' to wake the OMV NAS prior to a recording starting. Since putting these changes in place I've not had any problems, it seems to have done the trick.

I can't take the credit for this, that goes to dillthedog over on the OSMC forums.