[mythtv] [PATCH] shutdown/wakeup
Christian Hoenig
me at christianhoenig.de
Fri Oct 10 21:41:17 EDT 2003
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Hi,
as of request in #mythtv I hereby resend my shutdown/wakeup patch.
This patch allows the mythbackend(s) to automatically shutdown and wakeup (ie.
by using WOL or any bios wakeup tool) and so work like a normal VCR.
It also allows the frontend to wakeup the mysqlserver and/or the backend(s)
using WOL.
If there's something to fix in that patch I'm definitely willing to do so.
And feedback is very welcome :-)
take care, have fun
/christian
EDDK
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.3 (GNU/Linux)
iD8DBQE/hv1YmauZIX3ydQURAslxAJ4jkeeY+U4ue/WK7FN0EL0xJL6qbgCg0HK+
gPUEnIs3aHC7dHu0mYJEUTw=
=gaKA
-----END PGP SIGNATURE-----
-------------- 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' .
-------------- next part --------------
A non-text attachment was scrubbed...
Name: diff.sdwu
Type: text/x-diff
Size: 27727 bytes
Desc: not available
Url : http://mythtv.org/pipermail/mythtv-dev/attachments/20031010/7782de3a/diff.bin
More information about the mythtv-dev
mailing list