Hi all,
Just thought I'd share a few scripts I wrote and packaged up as a docker for auto sleeping/waking up a Plex server. This docker, called WakerUp works in the following scenario:
You have a stand-alone Plex server running on Linux (preferably Ubuntu).
You have a firewall/router capable of logging firewall accesses to a file or syslog server.
Your Plex server can be remotely woken up via a Wake-On-Lan magic packet.
You can ssh into your Plex server.
If so, then WakerUp will run on your Unraid system as a docker container, and it will remotely monitor your Plex server for activity via the Plex API. If it detects inactivity, it will sleep the Plex server via ssh after a suitable interval. Once the server is asleep, WakerUp will continue monitoring the log, looking for accesses in the firewall log for things like port 32400 (the Plex network port), although the exact search string is configurable, and will send the sleeping Plex a WOL packet to wake it up, and then repeat the whole sleep/wakeup process indefinitely.
Since my Plex server also serves files over NFS, I needed a way to trigger scans on my library for new items every now and then (since the auto-detect of file system changes doesn't work over NFS), so WakerUp will also trigger library scans at regular, user-configurable intervals when the server is awake.
Everything is open-source: You can find the documentation and source here: https://github.com/virantha/wakerup
To install, you just add https://github.com/virantha/docker-containers into your Docker templates repository list:
And then add a new Docker container called 'wakerup':
The settings are explained in the README in the source repository, but should be fairly straightforward. You shouldn't have to do any configuration on your Plex server, as WakerUp will take care of setting up ssh keys, and installing pm-utils on the server. Once installed, check your docker log to make sure it looks something like the following:
Let me know if anyone finds this useful or if you have any questions!