Difference between revisions of "Wake On LAN Router"

From MythTV Official Wiki
Jump to: navigation, search
(Setting up MythWelcome)
(Setting up MythWelcome)
Line 38: Line 38:
 
For the shutdown  command I use /sbin/poweroff.  Your command may be different.
 
For the shutdown  command I use /sbin/poweroff.  Your command may be different.
  
[[Image:mythwelcomesetup.jpg]]
+
[[Image:mythwelcomesetup86.jpg]]
  
 
== OpenWRT ==
 
== OpenWRT ==

Revision as of 12:56, 11 December 2006

WAKE-ON-LAN HOWTO with Linksys WRT54G Router (not finished, will be done by dec 15, k?)

Many MythTV users would prefer to have their Myth Backend shutdown when not recording. Attempting to use NVRAM Wakeup and ACPI may have failed. An easy alternative is to use Wake On Lan, in which another computer (or the router) sends a packet over ethernet to the Myth backend machine waking it up. The benefit is almost no extra packages or difficult configs to set up on the Myth box. Another bonus is that you can convert your Linksys router into something more familiar and usefull, a little Linux box.


This HOWTO covers setting up the MythBackend system, using MythWelcome, and a Linksys router or other that supports OpenWRT, to shutdown the Myth Backend when it is idle, and to wake it up again in time for the next recording. You can do something similar with any other 24/7 box you may have on your network. This HOWTO will not duplicate the other HOWTOs about waking up Myth and using MythWelcome, and will only partially cover installing OpenWRT on a router. You should read about all of these on your own.

Understanding Mythtv Wakeup Support and MythWelcome

You may want to read these first:

Myth Official Doc on Shutdown/Wakeup

Wiki entry on using Shutdown/Wakeup with NVRAM wakeup

MythWelcome HOWTO . MythWelcome will shutdown your box when not in use. We will hook into Mythwelome in this HOWTO.

ACPI Wakeup An alternative to this method and to to NVRAM Wakeup

Setting up the MythTV Backend

Run mythtvsetup on the master backend. On the Shutdown/Wakeup Options page you need to set the idle timeout in seconds, I use 1200 or 15 minutes. If the Myth backend is not flagging, transcoding or recording, then the Myth box will shutdown. The next config is Max wait for recording, which means the backend will not shutdown if a recordins is coming up in this many minutes. Set it to whatever you like.

The startup before recording (Seconds) is the important one for this HOWTO. A cron job will be running on the router every ten minutes, although you could do it more often. It will check if the time to wake up the backend has passed and it will wake it up. Therefore, I have to set the backend to wake up more than 10 minutes before a recording starts or else I may miss it. If your system also takes some time to boot you have to add in more time for that. Fifteen minutes or 900 seconds would be a good value. Make sure the idle time is longer.

I do not check "Block shutdown before client connected" since my box is a frontend and backend. The rest of the values are defaults.

Mythtvsetup86.jpg

Setting up MythWelcome

MythWelcome is a nice tool that integrates into the Myth Wakeup/Startup. It has a HOWTO on the wiki. This is where your own script will be called to write a file to the router containing the wakeup time.

From an X konsole or shell, run mythwelcome --setup.

MythWelcome is expecting to call the program NVRM Wakeup, but you can fill in any program name you like. In the NVRAM Wakeup command, fill in /usr/share/my_mythwakeup.sh

For the shutdown command I use /sbin/poweroff. Your command may be different.

File:Mythwelcomesetup86.jpg

OpenWRT

OpenWRT is a Linux distribution for embedded devices. You can flash it to overwrite the firmware on several different routers by Buffalo, Linksys, Asus and others. See the OpenWRT page for details:

OpenWRT main page


I already had a Linksys WRT54G Version 1.1, which can be flashed to OpenWRT. You can still buy supported routers from on line retailers such as Egghead, or try your local Craigslist.

If you decide to install OpenWRT, it is quite easy to set up, but please spend some time reading a few different sources before you do it to avoid turing your router into a $50 paperweight.

Once OpenWRT is installed you first telnet to it to set up a password, after the initial telnet, you will use ssh to connect to it like a normal linux box. In the shell you will use commands to set up cron jobs, or install new packages. OpenWRT comes with ipkg, similar to apt or yum, for managing installs.

Make sure you install the correct package for your router, and I recommend squash fs since it may later help you if mess up your installation and need to recover.

Install instructions for OpenWRT and the main docs are here:

[White Russion 5 by router]

[OpenWrt docs]

Additional Packages for OpenWRT

In addition to the standard OpenWRT (White Russian 5) you need to install the wol package and the ntp client package. This is simple to do using the package manager ipkg. You will need to configure a cron job, ntp, and copy a public key from your Myth backend to the router for password-less scp copying. These are very easy using the following HOWTOs from the OpenWRT wiki.


Additional package from OpenWRT are found here:

[http://downloads.openwrt.org/whiterussian/packages/]

from this page download:

wol_0.7.1-1_mipsel.ipk

ntpclient_2003_194-2_mipsel.ipk

You can use ipkg to install from the url or copy the ipk files to your router and install locally.

Please read this for setting up NTP client and set your timezone before installing the ntp client.

[Please read this for setting up NTP client and set your timezone ]

Set up cron and verify that it works:

[Cron Instructions on the OpenWRT wiki]


and finally, setting up the key for scp/open ssh. You generate the keys on the Myth box and then you copy the key to the router and add them to dropbear:

[How to generate and add keys]


Optional, but good to have, a very nice web interface for the router.

[WebIf2 for openWRT ]]

Install wol on Router and and Test it

wol is an official additonal/optional package. You can install WOL on the router from the shell. do:

ipkg install http://downloads.openwrt.org/whiterussian/packages/wol_0.7.1-1_mipsel.ipk

The download page for other packages is http://downloads.openwrt.org/whiterussian/packages/

Once wol is installed on your router you might as well test it. On your Myth Backend, use ifconfig eith0 to see the mac id of you ethernet card.

use the poweroff command to power off the mythbackend.

shell to the router using scp. At the prompt do this:


wol -p 65535 -h 192.168.1.255 00:15:33:4D:C6:28


the last part is your MythBackend ethernet MAC id or MAC address. You can get this from a shell prompt on your Mythbackend like this:


ifconfig eth0


The first line should end with the mac id:

eth0 Link encap:Ethernet HWaddr 00:15:33:4D:C6:28

The -h 192.168.1.125 assumes that your network is set up in the default linksys way, with the router having the address 192.168.1.1 and the rest of the machines in the network having addresses such as 192.168.1.100 etc. Try it and see if your machine wakes up. If not, you may have to use ethtool to set your nic to wakeup. [See this doc on the Myth wiki for setting up ethtool.]