LinHES Forums
http://forum.linhes.org/

Need some Help with Waking a NAS box from MYTH
http://forum.linhes.org/viewtopic.php?f=11&t=18858
Page 1 of 1

Author:  ljazz1111 [ Mon Aug 25, 2008 1:50 pm ]
Post subject:  Need some Help with Waking a NAS box from MYTH

Hi all. I have my video's and music stored on a Naslite NAS. I have successfully mounted the NAS disks and all has been good.
I have now been doing my part going green and set up the NAS box to shutdown and Wake on Lan.
Now, my question is... I would like myth to send the packet to wake the NAS box when I go to the menu to access videos or music. Is there a helpful tutorial to do this??
I have searched for this, but all I can see is the other way around (waking up the myth box). I am somewhat of a newbie and have done "some" scripting, but not in the realm I am thinking I need here.
Am I on the right path in thinking I need a script to send out the packet, mount the disks, then attach this script to the menu buttons?
Any help would be appreciated.
Thanks so much!
LaDawn

Author:  marc.aronson [ Thu Aug 28, 2008 10:05 pm ]
Post subject: 

The first thing that comes to mind is to add a new menu entry to the mythtv menus called something like "Start NAS". Have this menu entry tied to a script that:

1. Pings the NAS with a magic packet to wake it up.

2. Goes into a wait state until the NAS is ready.

3. Mounts the NAS exported directories.

Marc

Author:  ljazz1111 [ Mon Sep 01, 2008 12:12 am ]
Post subject: 

Yes thats pretty much what I was thinking, but the actual code is where I am lacking. Is there something like this around that I could use? Like just a copy-paste or something simple like that? Thanks

Author:  marc.aronson [ Mon Sep 01, 2008 9:43 am ]
Post subject: 

The script below should help. It will give the identified machine up to 200 second to respond to the ping. If your NAS responds to pings before it is ready to accept a mount request, you may need to add a final "sleep" to give it time to finish coming ready. Also, you will need to find a Linux program that can issue the WOL command -- see thiswiki to find such a program. See also this post by graysky for useful info.

Marc


Code:
#! /bin/bash
#
# $1:    IP address of name of host to wait for
# $2:    MAC address of host to wait for
#
host_ip="$1"
host_mac="$2"
num_tries=50
wait_between_tries=4
font="-adobe-helvetica-bold-*-*-*-34-*-*-*-*-*-*-*"
#
# Modify the "echo wol" below these comments to issue a "WAKE ON LAN".
# "$host_ip" is the IP address of the machine to wake up.
# "$host_mac" is the MAC address of the machine to wake up.
#
echo wol "$host_mac"
#
# Wait until machine waits up or we timeout
#
ping -c $num_tries -i $wait_between_tries -W $wait_between_tries $host_ip
if [ $? -ne 0 ]; then
  echo "###      Unable to wake up $host_ip" | tr "#" "\n" \
   | osd_cat -f $font \
     -c white -s 3 -S black -O 1 -u black \
     --delay=3 --align=left --pos=top
  exit 1
fi
#
# If your machine responds to pings before it is able to accept a
# network mount, uncomment the sleep command below. You may need
# to modify the number of seconds.
#
# sleep 10
exit 0

Author:  ljazz1111 [ Tue Sep 23, 2008 10:29 am ]
Post subject: 

Thanks for your input Marc! I worked with the code you gave me and got it working after a few tries. It would run from the command line but not within the button in Myth. It would wake the machine but not mount my drives. I finally figured out it needed permissions to run as root. I edited the sudoers file, chmod the script file, and voila! Thanks again! I'm quite proud of myself in figuring it out I'm going to try to work a bit more on the script to fit my needs but as for now its working.

Author:  marc.aronson [ Tue Sep 23, 2008 11:30 pm ]
Post subject: 

LaDawn, glad that helped you out and congratulations on sorting through the root vs. mythtv user problem!

Marc

Page 1 of 1 All times are UTC - 6 hours
Powered by phpBB® Forum Software © phpBB Group
http://www.phpbb.com/