Setting MythTV Backend Shutdown/Wakeup Options
|
The MythBackend server, along with its many varied duties, is responsible for controlling when the computer will shutdown and wakeup again. The server must be completely idle, with no pending jobs, upcoming recordings, or connected MythFrontends before it will initiate a computer shutdown. As it is shutting down, it will request that it be reawakened again if there are any upcoming recordings.
MythTVSetup
The program mythtvsetup is used to configure the
MythBackend. One of the pages in this configuration defines how
the computer will be shutdown and awakened. Select 1. General
from the main screen of mythtvsetup program, and then press
the button labeled "Next" four times or until the page labeled
Shutdown/Wakeup Options appears:
Startup command: /usr/bin/wakeuptest.sh $status &This field contains a command to be executed whenever MythBackend is started. The token
$statusis replaced with either the word "auto" or "user", indicating how the computer was awakened.In this example we have added the command
wakeuptest.sh, which has the following contents:#!/bin/sh # $1 is $status with value of 'auto' or 'user' if [ "$1" == "auto" ]; then sleep 30 killall mythfrontend fiThis example tests
$statusvariable to see if MythBackend was started manually, or automatically as a result of a scheduled recording. If started automatically, then the script kills MythFrontend to allow for shutdown after the recording is finished.This is useful on computers that are combination frontend/backend and need to startup MythFrontend without user intervention. However, a better solution is to start MythWelcome instead, and require the user to manually launch MythFrontend, thereby making this little script and the field on this form unnecessary.
Block shutdown before client connected If this box is checked then MythgBackend will wait for at least one MythFrontend connection before allowing an automatic shutdown. Of course, the MythFrontend will also have to disconnect for the shutdown to proceed. This is intended to keep backend computers from prematurely shutting down before a remote frontend computer has even booted.
This option must NOT be used in any environment where the backend computer must be allowed to wakeup and shutdown automatically.
Idle shutdown timeout (secs): 300Once the backend server goes "idle", and there are no connected MythFrontends, the computer can be safely shutdown. This value specifies a delay of seconds before shutdown. Without this option, or the Block shutdown before client connected checkbox (above) the server may shutdown before a client MythFrontend gets connected. In the example given here, there is a delay of 300 seconds, or five minutes, before shutdown.
Max. wait for recording (min): 25When the backend server is idle it could be shutdown. However, if a recording is scheduled to start in the near future, the computer may be shutdown only to be shortly restarted. This field specifies a window prior to a recording in which shutdown would be prohibited.
Startup before rec. (secs): 300Wakes the computer up prior to the start of a scheduled recording. The time, specified in seconds, should be greater than the time it takes to boot the computer. In the example shown; 300 seconds is equal to five minutes.
Wakeup time format: hh:mm yyyy-MM-ddThis is the format of the
$timeparameter as passed to /usr/bin/setwakeup.sh described below. The format can be any that is acceptable by the date command. The format shown in the example here is preferable as it reflects what is expected by/proc/acpi/wakeup
Command to set Wakeup Time: sudo /usr/bin/setwakeup.sh $timeThis field names the program that will be used to set the time at which the system will wakeup for scheduled recordings. Note that MythWelcome has a separate configuration that specifies the program that will set daily wakeup alarms. However, both configurations may point to the same program name. In this field,
$timeis replaced with the "time to wakeup" when the named program is executed. The format of this time data is specified by the Wakeup time format field (see above).The
/usr/bin/setwakeup.shprogram needs root privileges to operate properly. Therefore it needs to be added to the sudoers list. Edit the file/etc/sudoersand add/usr/bin/setwakeup.shto the list of files that are assigned toCmnd_Alias MYTHDORA. It should look similar to the following:Cmnd_Alias MYTHDORA= /usr/bin/setwakeup.sh, ...
Server halt command: mythshutdown --shutdownThe command executed to shutdown the Master backend and the Slave backends.
Pre Shutdown check-command: mythshutdown --checkThe command executed immediately before server shutdown as a test to see if a shutdown can be performed. This is a way for outside programs to have a say in whether the server should be shutdown. The default here is to call the "check" operation of the
mythshutdowncommand. You can add other conditions by adding a wrapper around this command along with additional tests. An example would be to allow for uPnP player to signal that it is still streaming files.

