Skip to content

jtbarrett/SleepProxyClient

 
 

Repository files navigation

A SleepProxyClient implementation

About

Wake on Demand (http://support.apple.com/kb/HT3774) is great. It enables an unused device to go to sleep while keeping the announced MDNS (Zeroconf) services alive. Just access one of the services and the device will be woken up again.

These scripts enables your Non-Apple server (or NAS) to save energy by going to sleep if it's currently not in use. But it will be instantly woken up again by the SleepProxyServer using Wake on Lan (WOL) if one of it's services is requested. See http://en.wikipedia.org/wiki/Bonjour_Sleep_Proxy for more details.

Requirements

To get this running, a SleepProxyServer on your local network is required. If present, it will announce itself via MDNS as _sleep-proxy._udp. Such a server is included in many Apple devices like its network products "Time Capsule" and "AirPort Express". But an Apple TV or any Mac running 10.6 or above can be turned into a sleep proxy server too.

Status

SleepProxyClient is pretty stable and ready for everyday use. Please report issues to make it even more stable.

Setup / Install

Requirements

  • python
  • dnspython (http://www.dnspython.org)
  • and other usefull python modules
  • avahi-browse (to discover the sleep proxy and local services)
  • pm-utils or similar power management tools

In addition it has to be possible to wake the host via Wake on LAN from sleep.

Install

SleepProxyClient works out of the box on Debian/Ubuntu. It should be quite easy to install SPC on other Linux distributions and UNIX/BSD systems too.

Linux

On Debian/Ubuntu just install the deb-package available from the repository:

  • Get and add the public key for this repo:
echo '-----BEGIN PGP PUBLIC KEY BLOCK-----
Version: GnuPG v1.4.10 (GNU/Linux)
 
mQENBFAzopoBCACoGg5JRZifLTUQE6C+OVZq3bjZSK3BX5bYC8xkL+NohUDM2hy3
ORkEVqMClp69VagfnoETsiI67QD3KMVm8gcRdsZ+Sz3gkiiSWkSCYBehZw9w1/xA
KJ6Fd7O6WG3Ejs0VTPONxPIZs5LISBqXlj4ihePWXSjni6ct/dRWrhsZpQ7wXa/p
QudsGio04C2MvN/+YK5PqVT2Xs2nD3V0YuNTUWC5QrCABDZaM5p4uN+kPgw5qQV2
Mx72QkxaRptkNQTuCvuZjRXLGV0rft6sdRjMcY4HJTAeCcX1KAbEsfjmPguAv/bt
KGPzuQPNs8CrS63Hc8mEAtH84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z9T8D0SkiYXR48x
R/kQutxv4TfKOgAD7G8Q9LnqGkgJjJGd7xcP+wbAjEgRZuHgrJ28YE3fr1xgnvAk
TT7oQXuqESu/MT4DwK5FUpDuuZ47cWLptbZK1HaF8zZKl8WFC8P2XhXCRVft7nHH
na0OvdOFvvbKErd0S4un9rEGDNBKJQeXA6Puy8LPGm7A1y1CC+IsrAJx5QtBmQ1D
YUSFNfplfBXer+J0qpOwzGEH0N4O/bEGqgApbK3c3aJBpLcdt3VtW/Bjf1TvkowR
mPkuyVP2h+K+
=kSu4
-----END PGP PUBLIC KEY BLOCK-----' | apt-key add -
  • Add the repository
echo 'deb http://repo.weinlein.info unstable main' >>/etc/apt/sources.list
  • Update apt and install the package
apt-get update
apt-get install sleepproxyclient

Other operating systems

SleepProxyClient was tested on Linux but should work on other operating systems too.
The only Linux specific dependency pm-utils should be easily replaceable by other OS-specific power management tools like apmd on BSD. Just ensure the suspend-script (sleepproxyclient.sh) is called before suspending the system.

Configuration

Services

All locally announced services will be discovered via avahi-browse. There is no manual configuration needed anymore.

Setup auto-sleep

Create your own or use the included checkSleep.sh script. The checkSleep script needs to be called periodically to be able to suspend the host by it's own. This can be done by creating a cronjob via crontab:

*/8 * * * * /bin/bash /usr/share/sleepproxyclient/scripts/checkSleep.sh

This job causes the checkSleep.sh to be called every 8 minutes. Since two successfully calls are required to suspend the host it will take at least 16 minutes until the suspend is done.

Tuning some parameters

Some more parameters can be adjusted to fit your needs:

  • List of network interfaces
    By default all interfaces are used. This can be changed by enabling this option.

  • TTL (Time to live)
    The TTL controls the life time of the mDNS announcement. After this period the sleep client will be woken up be the sleep proxy server again. The default value is 2 hours.

These settings can be configured via /etc/default/sleepproxyclient

What's inside

  • 00_sleepproxyclient
    This hook will be installed to /etc/pm/sleep.d/ and called by pm-utils before going to sleep. This script will call sleepproxyclient.sh and is actually calling the sleepproxyclient scripts.

  • checkSleep.sh
    Is an example script to show how to actually suspend the host. It does some checks to determine if the host is currently in use or not. It will suspend the host after two successfully calls by pm-suspend. This script is designed to be periodically called by a cronjob. To be able to do some more advanced checks take a look at other projects like https://github.com/OMV-Plugins/autoshutdown/. Just configure them to call pm-suspend instead of shutdown to activate your SleepProxyClient.

Support this project

Support this project by contributing some code, creating issues or by clicking the flattr-button - Thanks!

Flattr this

About

A SleepProxyClient implementation

Resources

Stars

Watchers

Forks

Packages

No packages published