For the usage of a local backup host, I defined the following scenario, which could also be used for a printer server or any other type of host, which shouldn’t run 24/7, but:
- The host should be able to be woken up manually by a special signal on the LAN, i.e., it should be capable of WOL. (This is only a hardware issue)
- If it is woken up, it should run at least for 30 minutes before trying to shutdown again.
- It shouldn’t shut down while certain processes are running, such as a backup, i.e., it should be capable of a shutdown-lock. If the lock is removed, it might shutdown.
- The host shouldn’t shut down as long as a certain client, e.g. a backup client, is (still) up and running (pingable)
- If the criteria above aren’t hurt, the host should finally shut down.
And here’s the shell-script which implements the above. It’s enough to have it run every five minutes. The “echoes” are only interesting for debugging purposes.