A SleepProxyClient implementation
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
debian
.gitignore
00_sleepproxyclient
README.md
checkSleep.sh
sleepproxyclient.py
sleepproxyclient.sh

README.md

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.12 (GNU/Linux)

mQINBFQB8swBEACxZT6StXBncZpc5mFyxIW8iGAFtcvBP+D3QD2cr6krFWTjYNdZ
0a79dA1IypgGxUdLeBVTiSsHFV3FJm4i1WLO2cVTMCUyrH5ENTC1GYPVP7BnVmhM
1ue2jWhkmSzSwbt6+VR2Bkix7mAiCqbkbxEkKT6BVeE9tC1UEJT4QxRUtNttgRc4
LTtbIkIX74HDfAI87F/ByC5naS/PEf4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D
hr1QEQ60S+bVK7EaWu/nwQqcn3sUXDpqamdYWRKLZBZK8D5JNsGt6QVCOVuE9ml1
bjSzyxcpKfbvtnEcqz69yLR/Kn+lwcibWJ7EHoXndJ4JGttMCv9usxqb3EqnHT9j
c5lKkRHAJM729vs9Vrfl0LdLcUhc7lPkeMZXYtZ0L/SmihWzltjUT3sFLlC9W9Cn
Xk9evVBI5pglqBnLfBTbMTal7tZGIdl/ObxUxajP2T81dZ1E6OKSx/tswmqUALg=
=lRed
-----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