[mythtv-users] Mythpower guinea pigs wanted... +[patch]
Christian Hoenig
me at christianhoenig.de
Mon Sep 1 20:59:06 EDT 2003
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Hi,
Calvin Harrigan wrote
> Over the weekend I've put together a little perl script to handle power
> management on a mythtv setup. Currently it permits the computer to
> autoboot and shutdown depending on it's recording schedule. I would
> like some folks to go through the docs, try it out and make any
> suggestions for improvement. I am hoping that it will be added to
> contrib directory at some point in the future.
I have a patch (for current CVS), which adds the ability to shutdown / wakeup
the myth-computer, in my privat CVS tree since a long time, now. I didn't
have too much time to finish it to Isaacs needs, but lately I worked on it
again and went more in Isaacs direction with it (I hope).
This patch does (exactly?) the same thing (and a little more), as your script
allows, but it would be an internal way to accomplish things. And the little
README.sdwu explains how to use it, hope that is not too complicated ;-).
Have a look at it, if you like :-)
Any feedback is highly appreciated!
@Isaac:
I intended to send you the patch within a month or so, so this one shouldn't
be the final one. Though it would be really nice if you could have a look at
it and comment on it again =).
The most important thing I changed since my last 'try' is, that it can handle
slavebackends now, too, and the settings stuff is where it (hopefully)
belongs. Unfortunately mythfrontend/main.cpp still misses to find out if
clienthost==backendhost, to allow or disallow user-shutdown dependendly.
thanks so far...
take care, have fun
/christian
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.2 (GNU/Linux)
iD8DBQE/U4jvmauZIX3ydQURApZGAJ0Wdp2Cgda2pX+b6CCkSEjWFgFWNgCgvQ74
kKnPjQcB/AD0AA7iM3BjEbQ=
=Y13u
-----END PGP SIGNATURE-----
-------------- next part --------------
A non-text attachment was scrubbed...
Name: sdwu.diff.20030901
Type: text/x-diff
Size: 24738 bytes
Desc: not available
Url : http://mythtv.org/pipermail/mythtv-users/attachments/20030901/55eaf7e2/sdwu.diff.bin
-------------- next part --------------
Here is a little description on how to use this addon (but be sure you
first run setup/setup to set the new settings):
There are diff'rent ways to accomplish the wakeup of your server using the
Shutdown/wakeup (sd/wu) stuff.
One way is to use the bios-clock to wakeup your masterbackend, another is to
use a 24/7 server to wakeup your backend using WakeOnLan (wol).
In the following I first explain how the shutdown part of sd/wu work with
its settings:
The scheduler keeps track of the idle-status of the servers.
The server is idle, when there is no recording starting within a given
timeperiod (setup/setup:"Max. wait for recording (min)"). If a recording
starts within that time, it simply waits for it, otherwise it is idle. Now it
stays idle for another amount of time (setup/setup:"Idle timeout (secs)")
before shuting down. After it idled for that time it calls the
'set wakeuptime command', passing the wakeuptime in 'wakeuptime format'
as $time, which should set the wakeuptime for the next recording. If you use
bios-clock wakeup you simply have to use your preferred tool here. If you use
WOL I discribe later how that can be accomplished.
Now it is ready to shutdown and tells all slavebackends to shutdown using the
'server halt command' and then shuts down itself using the same command.
At the time of the next recording, your server should wakeup and start
the recroding.
Using nvram tools for wakeup:
Since I can't use it, I don't know the details about that, but you can find
tools that support setting the bios alarms here:
http://sourceforge.net/projects/nvram-wakeup
http://www.malloc.de/tools/wakeup_clock.html
Using WOL to wakeup your MBE:
This is the way i use to wakeup my MBE. I have some little bash scripts which
help. Additionally I use 'nc' (netcat) to send the data from one to another
machine:
[in the following change $PORT and $SERVER to your local needs]
On my MBE I have a script that gets called as 'setwakeuptime command' which
looks like the follwing:
#! /bin/sh
echo $@ | nc $SERVER $PORT
'nc' is a little neat tool, that allows to cat text thru tcp/ip.
On my $SERVER I have (x)inetd listening on $PORT starting a little script which
cares about setting the atjob.
The following (changes) is necessary:
in /etc/*inetd.conf add:
mythwake stream tcp nowait mythtv /usr/sbin/tcpd /usr/local/bin/mythwake
in /etc/services add:
mythwake $PORT/tcp
/usr/local/bin/mythwake:
#! /bin/sh
#this should be a command to wake your server
WAKECMD="#!/bin/sh\n /usr/local/bin/wakeMBE"
#first we need to delete all wake jobs in queue
for JOB in `atq | cut -f 1` ; do
atrm $JOB;
done
#now we read the date from 'nc'
read date;
#now set the atjob
echo -e "$WAKECMD" | at $date ;
SECURITY WARNING:
Be sure, to secure $SERVER:$PORT from untrusted networks, because this
allows 3rd people to run arbitrary code on your server!
Now the wakeup part of sd/wu:
Again you have several options in distributing your
frontend/sql-server/master/slavebackends.
If you start your frontend, you can have it wakeup your sql server using wol
(see the sql-wakeup part of setup/setup).
* Then the frontend can start the masterbackend using wol (see the
backend-wakeup part of setup/setup).
* When the masterbackend is up, it can start all its slaves (using the
'wake slavebackends command').
* There is only a single command that is executed. This script should
contain all wakeup calls for your different slavebackends.
Tips/Tricks:
- If, for example, one of the slaves is your desktop computer, you could
simply use a little script as 'server halt command' which first calles
'/sbin/shutdown -t TIMEOUT' with a TIMEOUT you like to have to react,
then popup a window using *dialog asking for permision, and if the
user cancels the shutdown, simply call '/sbin/shutdown -c' .
More information about the mythtv-users
mailing list