Powersaving in MythTV setups:

Well to behonest, MythTV depending on your backend isn't cheap (unless you build a low-power MBE) and again depending on which type of tunercard you have in your backend.  But with a little configuration you'll be able to use ACPI for  controlling your MBE. There's a lot more of that here http://www.mythtv.org/wiki/ACPI_Wakeup , but since my MBE couldn't run S4 - and safe rtc for longer than a day, then I needed to add some more configuration to make it work, so I'll using my router for this setup!

Settings on MBE:

First you'll need to check if your netcard supports Wakeonlan:
# ethtool eth0
Settings for eth0:
Supported ports: [ TP MII ]
Supported link modes:   10baseT/Half 10baseT/Full
100baseT/Half 100baseT/Full
Supports auto-negotiation: Yes
Advertised link modes:  10baseT/Half 10baseT/Full
100baseT/Half 100baseT/Full
Advertised auto-negotiation: Yes
Speed: 100Mb/s
Duplex: Full
Port: MII
PHYAD: 1
Transceiver: internal
Auto-negotiation: on
Supports Wake-on: pumbg
Wake-on: d
Current message level: 0x00000001 (1)
Link detected: yes
Under Supports Wake-on:  your should see a g, which is based on magic packets. to set wake-up type, use ethtool and set the wake-on to g with this command:
# ethtool -s eth0 wol g
Afterwards you can use ethtool eth0 - and see if your setting have changed to the rigth type.

Settings on Frontends:

On the frontends we need to wake up the maincore, before starting mythtv - and then wait for MBE to be up and running and ready, before starting mythfrontend. So basicly this means:
Installing wakeonlan on the different frontends:
apt-get install wakeonlan
This install the packages needed on the frontend for wakeonlan. So Basicly we'll need a script for waking up the MBE during bootproces.
#! /bin/sh
# MAC address of backend
SERVER_MAC=xx:xx:xx:xx:xx:xx
#
case "$1" in
start)
# Issue wakeonlan at intervals until our own network interface
#  is active and the magic packet is successfully sent.
#
until /usr/bin/wakeonlan $SERVER_MAC > /dev/null 2>&1 ; do
sleep 1
done
;;
*)
esac
exit 0
The change the permissions and add for bootprocess with these commands:
$ chmod +x /etc/init.d/wol
$ update-rc.d wol defaults
Now this scripts run on the frontend and wakes up the masterbackend. Now it should autologin and start mythfrontend. Since I've allready described my autologin, it's the command here need for changing. Since I'm running Fluxbox on the frontends, it's the file /home/myth/.fluxbox/startup, where we add the line, before the : exec fluxbox & linie:
exec /usr/bin/mythfe.sh &
Then create the script /usr/bin/mythfe.sh and afterwards remember to change the permission so it's executeable afterwards.
/usr/bin/mythfestart.sh:
#! /bin/bash
# IP address of backend
SERVER_IP=xxx.xxx.xxx.xxx
# SERVER_MAC=xx:xx:xx:xx:xx:xx
# Could optionally send a wakeup packet here, if
#  a) it is decided that the early-running script above is not needed, or
#  b) to cover the rare case that backend was shutting down when first one sent
#
# Use mythTV status port as backend connectivity test
until [ -n "`telnet $SERVER_IP 6544 |grep -i connected`" ]; do
sleep 3
done
# start frontend
mythfrontend &
exit 0
If everything goes as planned, your frontend starts with waking up the MBE and waits for the MBE to be ready, before starting up the mythfrontend client. You can try it by shutting down te MBE server, and the reboot your FE, and see if its working as planned.

Configuring MythTV MBE:

Remark: this is only for a dedicated Backend system. Not Combined MBE/FE setup.

On the MBE you'll need to make some changes for shutting down the server but allso, see if any planned schedules are comming up and when to shutdown and wakeup the MBE. The easiest way is to use ACPI and therefor we'll need to make sure our BIOS supports this, and you can see this information in your kernel.log file:

$ grep -i rtc /var/log/kern.log
RTC can wake from S4
...
rtc0: alarms up to one month

This tells us, that the MBE can be wake up from S4 state and therefor a timestamp can be written. Here's my problem - I cannot use this! since my MBE only supports alarms up to one day.

Disabling Hardwareclock:

Disabling the hardwareclock on Debian, is quite easy. Add the following line to the file /etc/default/rcS

HWCLOCKACCESS=no

Now the machine are ready to configure MythTV - to use our setups.

Integrating into mythtv-setup:

Select the backend's "General" options and on the "Shutdown/Wakeup Options" page, make the following settings:

  • Block shutdown before client connected: (checked, if you run frontend and backend on 1 machine. Do not check if you do not automatically start the front end, and want the system to shut down after an automatic recording.)
  • Idle shutdown timeout (secs): 1200 (if you set this to 0, it will disable auto shutdown)
  • Max. wait for recording (min): 120
  • Startup before rec. (secs): 660 (If you have not disabled the occasional disk check on boot, make this time long enough to complete the boot & disk check before the recording should start)
  • Wakeup time format: yyyyMMddhhmm
  • Command to set Wakeup Time: sudo sh -c "/usr/bin/setwakeup.sh  $time"
  • Server halt command: sudo shutdown -h now   (some systems may need "sudo shutdown -P now" instead (-h may cause system to restart))
  • Pre Shutdown check-command: (leave this blank)

The create the script /usr/bin/setwakeup.sh and add these lines:

#!/bin/bash
echo $1 > /tmp/wakeup.txt
echo "shutdown from mythtv will wake up at $@" >> /var/log/mythtv/mythbackend.log
scp /tmp/wakeup.txt root@ROUTERIP:/tmp/wakeup.txt
exit 0
# EOF

Change the permission on the script:

$ chmod +x /usr/bin/setwakeup.sh

and add the lines for the user mythtv using visudo command:

%mythtv ALL = NOPASSWD: /sbin/shutdown, /bin/sh, /usr/bin/setwakeup.sh

This will allow our myth user to make the changes etc during shutdown of the MBE. Now you're ready to use MythTV but saving power at the same time!

On the Router I did added the follwinging files:

/usr/bin/wakebackend.sh

now11=`date  "+%Y%m%d%H%M"`
echo "checking for wake up at $now11" > /tmp/wakeup.log
if [ ! -f /tmp/wakeup.txt ]
then
exit
fi
read wakeupat < /tmp/wakeup.txt
if [ "$wakeupat" -lt "$now11" ]
then
/usr/bin/wakecore.sh
rm /tmp/wakeup.txt
echo "woke up mythtv $now11" >> /tmp/wakeup.log
fi

/usr/bin/wakecore.sh

#!/bin/bash

wakeonlan 00:24:E8:43:C0:10

# EOF

And added a crontabjob - like this:

*/2 * * * * /usr/bin/wakebackend.sh


This gives me a usage for powersaving - but allso waking up my Backend from but timescheduled recordings, or whenever a frontend is tuned on somewhere in my house! :-) MISSA Like!!!!