Projects: SlimServer ‘Server Power Control’ Plugin

September 4, 2008

The following code is for slimserver 6.5.1 only. The new squeezebox server software is not supported by this code, however there are plugins written by others that provide the same functionality. This post is left here only for reference.

*** 7/10/10 – Check out the plugins section of the slimdevices forum, where Gordon Harris has taken on this project and improved it considerably! ***

Link: http://forums.slimdevices.com/showthread.php?t=48521

Slim logo

My Slimdevices Slimserver runs on a old power hungry Pentium III 800 MHz which I prefer not to left running when I’m not using it. Shutting the thing down was either a trip into the garage, or a terminal server remote login via another networked computer (hopefully still running) to log it off!

the plugin
I have thus written a plugin to avoid this messing about. I know there are similar plugins about based on running batch files, or automated from inactivity timeouts – but I wanted something a little bit more direct 🙂

The Slimserver 6.5.1 code is for Windows machines and force closes other applications except Slimserver which is (hopefully) shutdown correctly. The Linux / Mac talented among you may suggest changes for those platforms.

use
Once installed, you will find a “Server Power Control” entry in the Squeezebox unit’s displayed plugins list. Clicking right, you have the choice of shutting down or restarting the server. Clicking right from here will do the selected action in 3 seconds (which also blanks the display) unless you navigate back. If a track is playing, it will remain playing from the players buffer – no big issue.

installation
The perl module file ‘PowerCtrl.pm’ should be placed in Slimserver’s plugin directory, and Slimserver restarted.

notes
Uses the Win32 API method, Win32::InitiateSystemShutdown

*** 7/10/10 – The following code is here only for reference. It will not work with current releases of Squeezebox Server. Please view the forum link at the top of this post! ***

Download the file here -> (4.5kB, GPL License).


Updated 24th April 2007

Slimserver 7 update / Win32

Here is the PowerCtrl plugin modified by Gordon Harris to work with Slimserver 7. Unzip the file into the server\Slim\Plugin folder. (The files need to end up in server\Slim\Plugin\PowerCtrl)

*** 7/10/10 – The following code is here only for reference. It will not work with current releases of Squeezebox Server. Please view the forum link at the top of this post! ***

Download the file here -> (2.7kB zip, GPL License).


Slimserver 7 update / Linux

And here is Gordon’s modifications which makes this plugin work with Slimserver 7 on linux. This version is linux only and won’t work with Win32.

Install the contents to /usr/local/slimserver/Plugins/PowerCtrl

Manually delete the /usr/local/slimserver/Cache/plugin-data.yaml file.

As root, add the slimserver user to the /etc/shutdown.allow file:
touch /etc/shutdown
echo “slimserver” >>/etc/shutdown

edit the /etc/sudoers file:
Comment out the line with: Defaults requiretty

Add:

%slimserver ALL=NOPASSWD:/sbin/shutdown -h now
%slimserver ALL=NOPASSWD:/sbin/shutdown -r now

restart slimserver and voilà!

*** 7/10/10 – The following code is here only for reference. It will not work with current releases of Squeezebox Server. Please view the forum link at the top of this post! ***

Download the file here -> (2.6kB zip, GPL License).

Advertisements