Skip to content

vrischmann/naspm

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

35 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

naspm

Dead simple "power management" for my NAS.

Overview

I would like to keep my NAS shut down when not needed, but since I use it remotely I can't always start it by pressing a physical button.

Something already exists for this, it's called Wake-on-LAN and fortunately my NAS supports it. This only works when connected on the LAN and I regularly need my NAS when I'm outside the house, so we need to somehow have a device that is connected both to the LAN and the internet and ask that device to send the WoL packet.

There are multiple ways to do this but my solution was to leverage Tailscale: almost every device I have joins my personal tailnet and I can connect to any device from anywhere. On that tailnet I have a router running Linux which is always on and so I can use it to send the WoL packet.

So this covers waking up the NAS if it's shutdown, but what about shutting it down ? Well this is easy: just make it execute poweroff somehow. My NAS is also part of my tailnet and I can trivially connect to it to power it off.

What this is

This program is an implementation of what I described above, tailored made for me so that I can wake up and shutdown my NAS with a simple UI usable on my phone.

There's a single binary that is intended to be run as a background service on each device. It provides the HTTP APIs necessary for everything to work.

There are three modes in which it can work:

  • sleeper mode
  • waker mode
  • ui mode

One particularity of this program is that it uses the tsnet package to create dedicated tailscale machines and then only exposes a HTTP server on the tailscale interface.

Sleeper mode

This is the mode that must be run on the NAS. It provides a single HTTP endpoint that calls poweroff.

Waker mode

This is the mode that must be run on the router. It provides a single HTTP endpoint that calls wol to send the WoL packet.

UI mode

This is the mode that must be run on my server. It provides a dead simple form with two buttons: "Wake up" and "Sleep". These buttons will trigger an HTTP request to the endpoints I talked about above.

The following diagram shows the final deployment and request flow: Untitled-2022-09-22-1437

About

Simple power management for my NAS.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published