View unanswered posts    View active topics

All times are UTC - 6 hours





Post new topic Reply to topic  [ 18 posts ] 
Go to page 1, 2  Next

Print view Previous topic   Next topic  
Author Message
Search for:
PostPosted: Thu Jul 31, 2008 1:52 pm 
Offline
Joined: Sun Sep 02, 2007 2:30 pm
Posts: 94
Hi everyone,

This is a little 'how to' guide on setting up automatic wakeup to record and shutdown on your R5.5 Knoppmyth box by utilising the wake on lan (wol) method with a router acting as your concierge!

A little background: I tried to use ACPI wakeup and nvram wakeup which is probably easier to setup if your computer hardware supports it, but unfortunately my hardware does not so I've decided to use the WOL method which will help to save electricity by only switching on my mythbox when it needs to record!

:?: Hardware Requirements: This (as far as I'm aware) only works on wired ethernet network connections and is unsupported on wireless cards. Before you proceed make sure your computer supports wake on lan and is enabled (so you don't waste your time or money) - check in your computer's BIOS that it is enabled and test a wake on lan by executing the following command on another linux pc when the mythbox you want to wakeup is switched off (of course! :D ):
Code:
wol -p 7 -h 192.168.1.255  00:11:22:AA:BB:CC

where -p 7 indicates the port on which to send the 'magic' wake on lan packet and -h 192.168.1.255 is the broadcast for your subnet range (on my internal network I have computers in the range 192.168.1.*) and 00:11:22:AA:BB:CC is the MAC address of the mythbox you want to wakeup. For Windows, you can use various freeware WOL utilities, this site seems to have plenty: http://www.depicus.com/wake-on-lan/
For Mac OSX: http://www.apple.com/downloads/macosx/n ... onlan.html

Once you've checked you can boot your mythbox by the WOL method you can begin!

Part 1: Setting up your Router / Access Point / Other Supported Device

The general idea is to use a device that you currently leave switched on permanently and which is supported by firmware from DD-WRT ( http://www.dd-wrt.com ) or Open-WRT ( http://www.openwrt.org ). This allows us to upload wake times to the device and create and run a small script as a CRON job to check for and send out the magic WOL packet to boot your mythbox at the correct time!

I personally use the DD-WRT firmware on my router because it was supported for my device and it is very easy to use after flashing with a good web interface. You can of course use Open-WRT or others but I have no experience with them and shall not be describing them in this HOW TO.

:!: WARNING: This procedure requires re-flashing your router / access point / chosen device with new firmware. Doing so will almost certainly invalidate your warantey / guarentee with such a device. If you mis-flash the device or the flash goes wrong or indeed if anything goes amiss then you will end up with nothing more than a paperweight as it is VERY hard (if not impossible) to re-cover such devices from a bad flash ( http://www.dd-wrt.com/wiki/index.php/Re ... _Bad_Flash ). I have bricked ( http://www.dd-wrt.com/wiki/index.php/Glossary#Brick ) one of my access points (USR5451A) by flashing it with DD-WRT v24.SP1 even though it said on their website that it WAS supported! So be warned - if you cannot risk irreparably losing your router / access point then do NOT continue. You can find more precautions here on the DD-WRT wiki: http://www.dd-wrt.com/wiki/index.php/In ... recautions - read this page as it tells you about installing.

So warnings aside (!) and CONTINUING AT YOUR OWN RISK, check that your chosen device is supported on DD-WRT here: http://www.dd-wrt.com/wiki/index.php/Supported_Devices
If it is - great! But has your device got enough flash memory?
You will need at least 4MB of flash memory on your device at the time or writing (DD-WRT v24). otherwise SSH is not included with the firmware.

Download the firmware (that works with your device) from their website - I'd recommend the mini version of DD-WRT as this will give room to save a script on a 4MB device - and follow the instructions on their website on how to flash your device. From personal experience I recommend resetting your device back to factory settings before flashing with DD-WRT (I didn't do this with my USR5451A and it bricked, whereas I reset another and flashed it and it was fine).
  1. After flashing your device with DD-WRT, log onto your device at its ip address of http://192.168.1.1/ and click on the setup tab. Enter the initial username and password for the device which is 'root' and 'admin' respectively. Cange all the settings on this page to how you want it for your network setup. Of special note is the NTP time settings here - chose an NTP time server and select your current time zone to give the device an accurate current time. Select 'Save Settings' and 'Apply Setttings' to configure your device.
  2. Next change the username and password on the 'Administration' tab which is very important if your device is connected to the internet. On this page enable JFFS2 and also 'Clean JFFS2' - this will create a small writeable filesystem on the device's flash memory for saving your boot script. Again click 'Save Settings' and 'Apply Settings'.
  3. On the Administration tab now disable 'Clean JFFS2' and then save and apply the setting as this will prevent your script being erased upon the devices reboot.
  4. On the Services tab enalbe SSHd under 'Secure Shell' section. I personally have SSH TCP Forwarding disabled and Password Login enabled. Again save and apply the settings.
  5. These are the minimum steps needed to getting the device able to boot the mythbox but you will probably want to go through the settings and configure everything else for your own network, such as any wireless devices etc.
Now all we have to do is upload our script to the device and getting it running as a CRON job. The script I use is one which I found in a very good guide on MythTV wiki: http://mythtv.org/wiki/index.php/Wake_On_LAN_Router which is well worth a look at and a read as some background on setting up such a system.
Code:
now11=`date  "+%Y%m%d%H%M"`
 echo "checking for wake up at $now11" > /tmp/wakeup.log
 now11=`date  "+%s"`
 if [ ! -f /tmp/wakeup.txt ]
 then
       exit
 fi
 read wakeupat < /tmp/wakeup.txt
 if [ "$wakeupat" -lt "$now11" ]
 then
   /usr/sbin/wol -p 7 -h 192.168.1.255  00:11:22:AA:BB:CC
   rm /tmp/wakeup.txt
   echo "woke up mythtv" >> /tmp/wakeup.log
 fi

Basic things to change are under the wol commands -p is the port you which to send the WOL packet on (usually port 7), -h is the broadcast address on your network (for my network with addresses 192.168.1.* it is 192.168.1.255) and then obviously the MAC address of your mythbox.

To add this script to your device SSH into it by using Putty or another SSH client. The device is very easy to SSH into, just point your client to the device's IP address and logon with the username root (even if you have changed the web logon username to something different) and the password which you have chosen for the web interface logon. A text editor exists on the device - vi - you must type /bin/vi to run it though, so to create this script and save it to flash I'd type:
Code:
/bin/vi /jffs/checkwakeup.sh

where the flash partition is /jffs and checkwakeup.sh is the name of the script I'm creating. Press i to begin typing and then ESC and then type ZZ (case sensitive) to save and exit.

Now we must make this script executable, to do this type
Code:
chmod +x /jffs/checkwakeup.sh
. This script basically checks for a file called wakeup.txt which has been sent to the device by your mythbox when it shuts down. It contains the epoch time when your mythbox wants to be woken up again. If this time has elapsed then the file is deleted and a WOL packet sent to wake your mythbox up again. Else the script simply exits. So we want this script to run every minute (or other time interval) to check whether it is time to wakeup the mythbox. This is accomplished with a CRON job. The CRON job is easily created by going to the devices web interface and selecting the 'Administration' tab. Under the 'Cron' section, ensure that it is enabled and then in 'Additional Cron jobs' paste the following:
Code:
*/1 * * * * root /tmp/checkwakeup.sh

NB: root must be included for the script to actually run and the time interval for running is set as */1 which means every one minutes.
Save and apply the settings and the script should now be running fine.
This location has changed - see post on flash wearing below...

The following is new...

To reduce flash wearing and hopefully prevent your device from burning up its flash we shall run the checkwakeup script from the /tmp directory which is the RAM on the router. Since this is cleaned every time the router reboots we must ensure a copy exists here. To do this we create a startup script on the router's website administration consol. Goto: Administration -> Commands and paste the following in the command window (you may have to edit the existing startup script if one exists):
Code:
cp /jffs/checkwakeup.sh /tmp/checkwakeup.sh

Click 'Save Startup' and then reboot your device.

You've now set up your device to boot your mythbox!

Part 2: Setting up your MythBox running Knoppmyth R5.5

This part of the how to guide is based upon the MythTV wiki article on this subject: http://mythtv.org/wiki/index.php/Wake_On_LAN_Router and how to by graysky on the Knoppmyth forum: http://knoppmyth.net/phpBB2/viewtopic.php?t=18605

I've used SSH on my mythbox to do most of the editing and I find it very useful compared to crouching in front of the television with a keyboard. If you are wanting to use SSH you must ensure it is enabled (it is already by default on R5.5) and enable mythtv as a user on it temporarily, edit the /etc/ssh/sshd_config file:
Code:
# nano /etc/ssh/sshd_config
and remove the pounding (#) from mythtv. Then save it and restart your mythbox.

All we need to do is disable mythtv booting when we switch on our mythbox and instead ask mythwelcome to start for us which will handle all the wakeup time settings on our booting device. To do this modify the .fluxbox/apps file to boot mythwelcome:
Code:
$ nano /home/mythtv/.fluxbox/apps

As graysky says in their tutorial simply pound out the line [startup] {KnoppMyth-Run} and then type a new line replacing KnoppMyth-Run with mythwelcome, so that it looks like:
Code:
#[startup] {KnoppMyth-run}
[startup] {mythwelcome}

Save it and exit.

Now exit mythfrontend by pressing ESC repeatedly. Halt MythBackend by issueing a command like:
Code:
# pkill mythbackend
to do so press Alt-X on the homescreen and then su to root. Then press Alt-S to bring up the mythbackend setup. Under the general section skip through to the Shutdown/Wakeup Options page and fill it out exactly as graysky suggests:
Code:
Wakeup time format: yyyy-MM-dd:hh:mm
Command to set Wakeup Time: /usr/bin/mythshutdown --setwakeup $time
Server Halt Command: sudo /usr/bin/mythshutdown --shutdown
Pre-shutdown Check Command: /usr/bin/mythshutdown --check

But you are free to configure your own timeouts. Then skip through the setup and exit the mythbackend setup program.

Press Alt-X again and then type:
Code:
mythwelcome --setup

Under 'Command to Set Wakeup Time' type:
Code:
/home/mythtv/wakeup/mythwakeup.sh --settime $time

For wakeup time type:
Code:
time_t

Ensure the nvram command box is left blank and then configure the rest of the settings as follows:
Code:
Command to reboot: /sbin/reboot
Command to shutdown: /sbin/poweroff
Command to run Xterm: xterm
Command to start the frontend: KnoppMyth-run

Select finish and exit this setup.

Now start a terminal as the user mythtv. Type:
Code:
mkdir /home/mythtv/wakeup
to create the directory structure for our wakeup setting script. The actual script itself that I've used is an adaptation from the mythtv wiki page: http://mythtv.org/wiki/index.php/Wake_On_LAN_Router To create this script type the commands:
Code:
cd /home/mythtv/wakeup
nano mythwakeup.sh

and type in the following script *:
NB: This script is now an old version and has been left here as an archive
Code:
#!/bin/bash
echo $2 > /home/mythtv/wakeup/wakeup.txt
echo "shutdown from mythtv will wake up at $@" > /home/mythtv/wakeup/mythwakeup.log
scp /home/mythtv/wakeup/wakeup.txt root@192.168.1.1:/tmp/wakeup.txt > /dev/null

Where 192.168.1.1 is the IP address of your booting device that you are about to scp your wakeup time to.
Here is the latest version of this script:
Code:
#! /bin/bash
tw=$2
cur_count=$(tune2fs -l /dev/hda3 | awk '/Mount count:/ { print $3 }')
max_count=$(tune2fs -l /dev/hda3 | awk '/Maximum mount count:/ { print $4 }')
if [ $cur_count -ge $max_count ]; then
 tw=$[$w-600]
fi
echo $tw > /home/mythtv/wakeup/wakeup.txt
echo "shutdown from mythtv will wake up at $@" > /home/mythtv/wakeup/mythwakeup.log
scp /home/mythtv/wakeup/wakeup.txt root@192.168.1.1:/tmp/wakeup.txt > /dev/null
See posting * below for an explanation.

Save this script and then chmod it like so to make it executable:
Code:
chmod +x /home/mythtv/wakeup/mythwakeup.sh

The final step we must do to make this work is to allow dropbear scp - that is a secure file transfer without a password. This is straight forward to do (and described at various places on the internet, I took my advice from here: http://www.linuxjournal.com/article/8600 ), so first start a command terminal as the user mythtv again. Then issue the command:
Code:
ssh-keygen -t rsa

Simply press enter when promtped for a filename and passphrase. This generates a private and public key pair. Note the key location and open the file ending .pub with nano. Copy the entire (long!) line of text in this file and paste it into the web interface of your device under the Services tab -> Secure Shell -> Authorised Keys. Save and apply the settings on your device. I recommend now copying a few (very small!) files over to the device to ensure that copying by scp is occuring without a password or else you will not send the wakeup time to your device! For instance you will probably have to save the devices SSH key to your mythbox the first time you ever copy a file.

Now you're completely done! Shutdown and switch on your mythbox by issueing a command like
Code:
sudo shutdown -h now
and hopefully everthing should work smoothly!

Part 3: Common Troubleshooting Problems

My mythbox outputted the epoch wakeup time in UTC time format which was different to the time zone (including daylight savings etc.) to the time on my device. So check what timezone you are outputting to with a web epoch to 'readable' time web converter: e.g. www.epochconverter.com and then change your timezone on your device at Setup -> NTP to account for this.

Make sure your mythbox has power on from the socket when it is off or it won't be able to switch on!

The wakeup time is stored in RAM on the booting device to reduce flash wear. This means that rebooting the device or a power outage would erase the wakeup time and so you would miss your recording. You can store this file in flash by changing /tmp/wakeup.txt to /jffs/wakeup.txt in the above scripts but this will eventually permanently wear out the flash memory on these devices!

Fsck will check your ext3 partitions every 20 or so boots on Knoppmyth R5.5, either change your partition file system (see forum or wiki for how to...) or increase your wakeup before boot time in mythbackend setup to give enough time for a file system check (which may be several minutes on your computer). This will avoid missing the start of some programs!

_________________
Running Knoppmyth R5.5 on a Compaq EVO D510 (sff) w/ P4 1.8GHz, 1GB RAM, 330GB 7200rpm Maxtor IDE HDD, XFX Nvidia GeForce 6200 (AGP low profile, p/n: PV-T44A-WANG) and Huappauge NOVA-T 500 DVB-T dual tuner PCI card.


Last edited by mythman13 on Wed Mar 30, 2011 10:55 am, edited 8 times in total.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Aug 04, 2008 2:11 pm 
Offline
Joined: Wed Dec 10, 2003 8:31 pm
Posts: 1996
Location: /dev/null
Very detailed writeup. I'm confused as to why you're using the router to sent the WOL signal. Why not send it from the box you're using to talk to the router?

_________________
Retired KM user (R4 - R6.04); friend to LH users.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Aug 04, 2008 5:14 pm 
Offline
Joined: Sat Jun 25, 2005 7:39 pm
Posts: 162
Great guide. Thanks a lot!


Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 05, 2008 3:21 am 
Offline
Joined: Sun Sep 02, 2007 2:30 pm
Posts: 94
graysky wrote:
Very detailed writeup. I'm confused as to why you're using the router to sent the WOL signal. Why not send it from the box you're using to talk to the router?

Thanks and no problem, I'll just explain the setup:

I don't have any computers on my network running 24x7 atm. This is because they probably wouldn't being doing anything useful for most of the time and so its not worth the electricity to keep them on and running! But: I have a self contained frontend / backend mythbox that I want to act like a VCR: power on to record and power off when finished all automatically. I think I'm right in saying that your very good guide describes using a computer to send the WOL packet and switch on the mythbox which would be the solution I'd use if I had a computer running 24x7. However I do have a router on 24x7 as it'd be a pain to switch such network infrastructure on and off as necessary and because it is a low power device.

So I decided to utilise this router to automatically switch on my mythbox when it was scheduled to record. So when operational the sequence of events is:

1. Mythbox shuts down by Mythwelcome, sending the wakeup time for next recording to the router by scp.
2. The router saves this time in its RAM memory.
3. A CRON job on the router runs every minute and compares the current time and the time when the mythbox wants to be woken up.
4. If the wakeup time has elapsed, then a WOL packet is sent to the mythbox, the wakeup time is erased and then the mythbox switches on and records, then switches off again back to step 1.
5. Else the script exits and cycles back to step 3.

This allows me to utilise a low power device to switch my mythbox on like a VCR without having to keep a high powered device (e.g. a computer) on 24x7 to receive and process the wakeup events.

The box I'm using to talk to the router is just my desktop pc, which again I'd rather leave off than have running 24x7 as it is quite old and noisy!

md10md wrote:
Great guide. Thanks a lot!

No problem! I think, like graysky, that it's good and helpful to have this walk through guides to help people setup some complicated functionality on their mythbox - I documented it because I did it and if I need to re-do it in the future it's good to have a record to prompt me! I hope you all find it useful!

_________________
Running Knoppmyth R5.5 on a Compaq EVO D510 (sff) w/ P4 1.8GHz, 1GB RAM, 330GB 7200rpm Maxtor IDE HDD, XFX Nvidia GeForce 6200 (AGP low profile, p/n: PV-T44A-WANG) and Huappauge NOVA-T 500 DVB-T dual tuner PCI card.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 05, 2008 12:45 pm 
Offline
Joined: Wed Dec 10, 2003 8:31 pm
Posts: 1996
Location: /dev/null
@mythman13 - I think I understand now. Correct me if I'm wrong, but your method allows the router send the wakeup signal to the mythvbox because the BIOS in the mythbox can't wake up on its own via APCI or nvram?

EDIT: I just noticed you added the "background" section to your guide which answered my question. Cool. If you haven't done so already, I'd invite you to publish this guide to the knoppmythwiki as well. You might wanna even publish it to the official mythtv wiki as well.

_________________
Retired KM user (R4 - R6.04); friend to LH users.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 08, 2008 1:22 pm 
Offline
Joined: Sun Sep 02, 2007 2:30 pm
Posts: 94
graysky wrote:
@mythman13 - I think I understand now. Correct me if I'm wrong, but your method allows the router send the wakeup signal to the mythvbox because the BIOS in the mythbox can't wake up on its own via APCI or nvram?

Yep you've got it!

graysky wrote:
I'd invite you to publish this guide to the knoppmythwiki as well. You might wanna even publish it to the official mythtv wiki as well.

I've tried to add this guide to the KnoppmythWiki but cannot get pass the captcha passphrase riddle no matter how hard I try! Is there some technique for doing this or a limit to the number of characters etc. because I just can't seem to get it right - consequently I cannot post! Is there meant to be an image for this passphrase or just a line of text? It'd be a lot easier for newbies to the wiki if there was your usual captcha question like a warped line of text.

-Mythman

_________________
Running Knoppmyth R5.5 on a Compaq EVO D510 (sff) w/ P4 1.8GHz, 1GB RAM, 330GB 7200rpm Maxtor IDE HDD, XFX Nvidia GeForce 6200 (AGP low profile, p/n: PV-T44A-WANG) and Huappauge NOVA-T 500 DVB-T dual tuner PCI card.


Top
 Profile  
 
PostPosted: Tue Aug 19, 2008 10:33 am 
Offline
Joined: Sun Sep 02, 2007 2:30 pm
Posts: 94
Update to the Script on the Mythbox
* Work around to fsck check problem


Hi,

I've made a slight modification to the script on the Mythbox so that the problem, that I mentioned in the original posting, with fsck doing a file system check on your /myth partition does not make you miss the first few minutes of your recording when your Mythbox is automatically woken up by your router:

mythman13 wrote:
Fsck will check your ext3 partitions every 20 or so boots on Knoppmyth R5.5, either change your partition file system (see forum or wiki for how to...) or increase your wakeup before boot time in mythbackend setup to give enough time for a file system check (which may be several minutes on your computer). This will avoid missing the start of some programs!


Generally most people will have their /myth partition (the big one where all your recordings are stored) as the default file system type of ext3. This needs checking ever 20 or so boots to stop your drive getting errors that could mean that you lose your recordings. But this can take several minutes - my drive takes about 10 minutes to complete the scan when not completely full! So the problem is that your Mythbox may only be switching on a couple of minutes before the recording is set to start and so if it is a boot when the scan is due, then you could be missing 10 minutes or so of the show! You can easily avoid this by doing one of the following:
  • Changing the "time to wakeup before recordings" on the mythtv-setup program under the general tab to be sufficently long that you do not miss your show if a check occurs during the boot. But, in an extreme case where your Mythbox is only used like a VCR, this means that your box will be on and idle for 190 extra minutes (10 minutes idle wake before boot on 19 boots out of 20 without a check) - that's over 3 hours of idling!
  • Getting your Mythbox to wakeup perodically to do a check on the /myth partition.
  • Switch to the XFS file system on the /myth partition, which requires no checking. But if you've already got stuff stored on the partition then this isn't easy.
  • Wakeup the computer up 10 minutes early only on the 20th boot when a check needs to occur.
The last method is the one I've settled for and it doesn't require much alteration to the original setup. But if you're installing a new box I'd recommend to try XFS file system, although I haven't gotten around to trying this yet. I got the inspiration from this forum post: http://knoppmyth.net/phpBB2/viewtopic.p ... sc&start=0 and the scripting is largely based on the previous one I used and the additions suggested by marc.aronson and tjc on that thread - so thanks for that!

Here is the new script then:
Code:
#! /bin/bash
tw=$2
cur_count=$(tune2fs -l /dev/hda3 | awk '/Mount count:/ { print $3 }')
max_count=$(tune2fs -l /dev/hda3 | awk '/Maximum mount count:/ { print $4 }')
if [ $cur_count -ge $max_count ]; then
 tw=$[$w-600]
fi
echo $tw > /home/mythtv/wakeup/wakeup.txt
echo "shutdown from mythtv will wake up at $@" > /home/mythtv/wakeup/mythwakeup.log
scp /home/mythtv/wakeup/wakeup.txt root@192.168.1.1:/tmp/wakeup.txt > /dev/null

As usual 192.168.1.1 is the ip address of your router / device and 600 is the time in seconds that you want to wakeup before recording when a scan is due - so adjust this to suit your Mythbox.

To apply this update simply replace the old script for the Mythbox and follow the steps in the original guide above.

--Mythman

_________________
Running Knoppmyth R5.5 on a Compaq EVO D510 (sff) w/ P4 1.8GHz, 1GB RAM, 330GB 7200rpm Maxtor IDE HDD, XFX Nvidia GeForce 6200 (AGP low profile, p/n: PV-T44A-WANG) and Huappauge NOVA-T 500 DVB-T dual tuner PCI card.


Top
 Profile  
 
 Post subject: now on knoppmythwiki
PostPosted: Fri Aug 29, 2008 9:36 am 
Offline
Joined: Sun Sep 02, 2007 2:30 pm
Posts: 94
This guide is also now available on the Knoppmythwiki:
http://www.knoppmythwiki.org/index.php? ... nLANRouter
Mythman

_________________
Running Knoppmyth R5.5 on a Compaq EVO D510 (sff) w/ P4 1.8GHz, 1GB RAM, 330GB 7200rpm Maxtor IDE HDD, XFX Nvidia GeForce 6200 (AGP low profile, p/n: PV-T44A-WANG) and Huappauge NOVA-T 500 DVB-T dual tuner PCI card.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 04, 2008 9:48 pm 
Offline
Joined: Thu Feb 09, 2006 7:18 pm
Posts: 112
Thanks for the guide, I'm considering switching to this method, since acpi wakeup seems flaky on my hardware and I'm already running dd-wrt. Out of curiosity, how hard wuld it be have the router automatically wake the machine when a request for the mythweb page came in?

_________________
MBE:AMD Athlon 64 3000+ (venice),MSI K8MM-v Motherboard (via chip based), PVR-500, Chaintech av710, IDE Hard drive
SBE:P4 3Ghz, Asus P4G800, PVR-250, IDE Hard Drive


Top
 Profile  
 
 Post subject:
PostPosted: Sun Sep 07, 2008 5:02 am 
Offline
Joined: Sun Sep 02, 2007 2:30 pm
Posts: 94
Hi jigahow,
I've been thinking about how you could implement this I guess you'd want the router to detect when the mythbox is off (so perhaps ping it every minute or so to check) and then when it is the router should map the ip address or hostname of your mythbox to a page that you would create on the router which when accessed would send a wake on lan packet to the mythbox. I can see how to do the first bit but have no idea how you'd re-map an ip or hostname on a router unless you could I guess edit some dns settings. I also am unsure how to send a wake on lan packet when a page is accessed or whether you can easily create such web pages on DD-WRT.

In the meantime it is very easy to send a wake on lan packet from a DD-WRT router: just navigate to it using your browser and then goto Administration -> WOL and then enter the MAC address of your mythbox in the manual wakeup. There are many other settings on here to configure automatic wakeup etc.

Mythman

_________________
Running Knoppmyth R5.5 on a Compaq EVO D510 (sff) w/ P4 1.8GHz, 1GB RAM, 330GB 7200rpm Maxtor IDE HDD, XFX Nvidia GeForce 6200 (AGP low profile, p/n: PV-T44A-WANG) and Huappauge NOVA-T 500 DVB-T dual tuner PCI card.


Top
 Profile  
 
 Post subject:
PostPosted: Sun Sep 07, 2008 10:13 am 
Offline
Joined: Thu Feb 09, 2006 7:18 pm
Posts: 112
Yeah, that's he method I've been using, I was just trying to think of ways to make it more automatic. And by the way, in v24 if you're using static ip leases all you have to do is enable wol for that host and hit a button.

Would you need to know if the machine was off? Couldn't you just send out a magic packet when a request for the page was received? I'll admit this is beyond my level of expertise.

_________________
MBE:AMD Athlon 64 3000+ (venice),MSI K8MM-v Motherboard (via chip based), PVR-500, Chaintech av710, IDE Hard drive
SBE:P4 3Ghz, Asus P4G800, PVR-250, IDE Hard Drive


Top
 Profile  
 
 Post subject: remote wakeup solved
PostPosted: Mon Sep 08, 2008 5:34 am 
Offline
Joined: Sun Sep 02, 2007 2:30 pm
Posts: 94
Read the next post first for a quicker and longer lasting method
jiawho wrote:
Would you need to know if the machine was off? Couldn't you just send out a magic packet when a request for the page was received?

Yes you could! I hadn't thought about that, as that would simplify the setup greatly.

jigawho wrote:
And by the way, in v24 if you're using static ip leases all you have to do is enable wol for that host and hit a button.

I'm running v24 but I'm not using this router to assign ip leases etc. atm although I'm looking at doing this in the future so thanks for this advice!

This wiki page on the DD-WRT wiki explains how you can create a webserver on the router!

http://www.dd-wrt.com/wiki/index.php/WEB_server (based on this forum posting: http://www.dd-wrt.com/phpBB2/viewtopic.php?t=29673 )

If you scroll down to the end it explains how to create web pages that run bash scripts. So all you want is a page that when you access it it wakesup your mythbox.

Here is how I've done just that (it's real simple actually! :D ):
  1. SSH into your DD-WRT router.
  2. Type the following code (this changes to the right driectory and creates the file):
    Code:
    cd /tmp/www
    mkdir cgi-bin
    cd cgi-bin
    /bin/vi mythbox.cgi
  3. Your are now in the text editor vi. Type i and then enter the following (line beginning with echo is one single line from there to the end of the code):
    Code:
    # !/bin/sh                                                                                     
    /usr/sbin/wol -p 7 -h 192.168.1.255 00:11:22:AA:BB:CC                                           
    echo "<html><body><p>MythBox has been woken up, please wait for it to boot up!</p><p>Then click here to navigate to it: <a href="http://mythbox-address/">MythBox Home Page</a></p></body></html>"
  4. Change 00:11:22:AA:BB:CC for the MAC address of your MythBox, 192.168.1.255 to the broadcast address of your network, 7 to the wakeup port (this is the default usually) and http://mythbox-address/ to the web address of your MythBox.
  5. Press ESC and then type ZZ (case sensitive), this saves the file.
  6. Type the following to make it executable:
    Code:
    chmod +x mythbox.cgi
  7. Logout of the SSH and then using your web browser navigate to: http://ip.address.of.router/user/cgi-bin/mythbox.cgi
  8. Wait for your MythBox to wakeup and then clcik on the link to navigate to it!


At the moment this is stored in the RAM of your router so will be lost when you reboot or power it off! I'm trying to figure out how to backup this script.
I don't now how to remap the address of the MythBox to this page yet but at least it is a start!

_________________
Running Knoppmyth R5.5 on a Compaq EVO D510 (sff) w/ P4 1.8GHz, 1GB RAM, 330GB 7200rpm Maxtor IDE HDD, XFX Nvidia GeForce 6200 (AGP low profile, p/n: PV-T44A-WANG) and Huappauge NOVA-T 500 DVB-T dual tuner PCI card.


Last edited by mythman13 on Mon Sep 08, 2008 12:38 pm, edited 1 time in total.


Top
 Profile  
 
 Post subject: automatic
PostPosted: Mon Sep 08, 2008 7:15 am 
Offline
Joined: Sun Sep 02, 2007 2:30 pm
Posts: 94
To prevent losing this after startups goto the router's admin page under administration -> commands and paste the following into the command window:
Code:
mkdir /tmp/www/cgi-bin
cd /tmp/www/cgi-bin
echo "# !/bin/sh" > mythbox.cgi
echo "/usr/sbin/wol -p 7 -h 192.168.1.255 00:11:22:AA:BB:CC" >> mythbox.cgi
echo "echo \"<html><body><p>MythBox has been woken up, please wait for it to boot up!</p><p>Then click here to navigate to it: <a href=http://mythweb.address.here/>MythBox Home Page</a></p></body></html>\"" >> mythbox.cgi
chmod +x mythbox.cgi

N.B. last echo ... is all one line! Edit above for your mythweb address and MAC etc.
Click on save startup and you're done!

You don't have to bother doing anything in the previous post with this!

_________________
Running Knoppmyth R5.5 on a Compaq EVO D510 (sff) w/ P4 1.8GHz, 1GB RAM, 330GB 7200rpm Maxtor IDE HDD, XFX Nvidia GeForce 6200 (AGP low profile, p/n: PV-T44A-WANG) and Huappauge NOVA-T 500 DVB-T dual tuner PCI card.


Last edited by mythman13 on Mon Sep 08, 2008 12:37 pm, edited 1 time in total.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Sep 08, 2008 11:43 am 
Offline
Joined: Thu Feb 09, 2006 7:18 pm
Posts: 112
Question: I assume you put the internal address in your script, will this work if you're coming form outside the network?

_________________
MBE:AMD Athlon 64 3000+ (venice),MSI K8MM-v Motherboard (via chip based), PVR-500, Chaintech av710, IDE Hard drive
SBE:P4 3Ghz, Asus P4G800, PVR-250, IDE Hard Drive


Top
 Profile  
 
 Post subject: ip address
PostPosted: Mon Sep 08, 2008 12:35 pm 
Offline
Joined: Sun Sep 02, 2007 2:30 pm
Posts: 94
jigahow wrote:
Question: I assume you put the internal address in your script, will this work if you're coming form outside the network?

It depends where your router is. If the MythBox is on the same network as the router then it is the internal address of your MythBox on your internal network that you use. If you have the MythBox behind a different router on an external network then things could get complicated as I don't think the WOL packet would travel well from your router, across the internet and through another router to the MythBox.

However if you're thinking about remotely accessing your MythBox from work or something, then setup a VPN into your network through the router and then access the web-page on your router that boots your MythBox with its usual internal address (as it will appear as though you are part of the internal network).

So in all cases where the router and MythBox are on the same network you use the internal address of the MythBox because it is the router that is sending the wake on lan packet.

Continuing this on a new thread: http://knoppmyth.net/phpBB2/viewtopic.p ... 966#115966

Hope this helps!
Mythman

P.S. You can create a very fancy webpage if you want with a background, images, etc. and produce a sought of MythWebWelcome. But you will need enough flash or RAM on your router to do this! Just type the html code within the echo command in the script!

_________________
Running Knoppmyth R5.5 on a Compaq EVO D510 (sff) w/ P4 1.8GHz, 1GB RAM, 330GB 7200rpm Maxtor IDE HDD, XFX Nvidia GeForce 6200 (AGP low profile, p/n: PV-T44A-WANG) and Huappauge NOVA-T 500 DVB-T dual tuner PCI card.


Top
 Profile  
 

Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 18 posts ] 
Go to page 1, 2  Next



All times are UTC - 6 hours




Who is online

Users browsing this forum: No registered users and 17 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB® Forum Software © phpBB Group

Theme Created By ceyhansuyu