Wake-on-lan script for auto-mode NAS/media server (no more 24/7 turned on), Written for my ASUS router with DD-WRT v2.4 SP2 |

![]() ![]() |
Wake-on-lan script for auto-mode NAS/media server (no more 24/7 turned on), Written for my ASUS router with DD-WRT v2.4 SP2 |
Oct 29 2009, 11:41 PM
Post
#1
|
|
|
WDTV USER ![]() Group: Members |
I picked up a WDTV Live yesterday from a local BB, love the easiness of streaming the video files from my NAS. But I also like the way now my Buffalo NAS turns off when it does not recieve WOL magic packets, and how it automatically turns on when it get the WOL packets. Unfortunately I can't install the Buffalo client software that wakes the NAS, so I had to write a little script on my own, and load it to my ASUS router that currently runs DD-WRT v2.4 SP2, this script at the end replaces the original client software from Buffalo since it monitors the IP-enabled devices in my network, it detects the ones I know it needs to use the NAS, whenever it's online, the router will perform the WOL. I am posting it here in case if anyone runs into the same problem I have.
copy and past below, and save it under the /jffs/usr/sbin/ directory, make sure you give it execute permission. CODE ################################################### # change the values in PC1, PC2, MP to the hostname of your targeted devices # or you can add more (just make sure add to the if statement too for it to work) ################################################### #!/bin/sh NAS=LS-WTGL668 LEASES=/tmp/dnsmasq.leases PC1=LivingRoomPC PC2=RoomPC MP=WDTVLive NET=`nslookup $NAS | grep Server` NET=${NET##* } NET=${NET%.*} while read LINE do HOST=${LINE% *} HOST=${HOST##* } if [ "$HOST" = "$PC1" -o "$HOST" = "$PC2" -o "$HOST" = "$MP" ] then echo "host matched $HOST" IP=${LINE% $HOST*} IP=${IP##* } echo "ip of $HOST is $IP" ONLINE=`ping -W 1 -c 1 $IP | grep 'bytes from'` if [ -n "$ONLINE" ] then echo "$HOST is online" NASLINE=`cat $LEASES | grep $NAS` NASIP=${NASLINE% $NAS*} NASIP=${NASIP##* } NASMAC=${NASLINE% $NASIP*} NASMAC=${NASMAC##* } echo "NAS IP is $NASIP MAC is $NASMAC" i=0 while [ $i -lt 3 ] do /usr/sbin/wol -i $NASIP -p 9 $NASMAC i=$((i+1)) done exit 0 fi fi done < $LEASES then all there left to do is create a cron job entry in DD-WRT (under the "Administration tab") * * * * * root wolnas > /tmp/wolnaslog Now, the router that 24/7 on will be monitoring the network and does the WOL for you. You can also use the script for a media server too if you don't want to keep it turned-on 24/7. (IMG:style_emoticons/default/smile.gif) Enjoy (IMG:style_emoticons/default/smile.gif) |
|
|
|
Oct 29 2009, 11:41 PM
Post
#
|
|
|
SITE SUPPORT Group: Bot |
|
|
|
|
Jan 8 2010, 03:39 AM
Post
#2
|
|
|
WDTV USER ![]() Group: Members |
I have tomato firmware, is it possible to run this script on there?
thanks! |
|
|
|
Oct 10 2010, 03:42 AM
Post
#3
|
|
|
WDTV SEMI-PRO ![]() ![]() Group: Members |
hello,
is it possible to run this script with a fritzbox? what must i change. the firmware of the wdtv live is irrelevant?! have someone a idea to solve this problem? my problem is i want to start my "windows home server" with the wdtv live. THANK YOU! |
|
|
|
Oct 14 2010, 06:23 PM
Post
#4
|
|
|
WDTV USER ![]() Group: Members |
I have tomato firmware, is it possible to run this script on there? thanks! I'd like that too. A manual for dummys please (IMG:style_emoticons/default/wink.gif) I know tomato has the build in ether-wake command. |
|
|
|
Oct 27 2011, 11:55 AM
Post
#5
|
|
|
WDTV USER ![]() Group: Members |
NAS=LS-WTGL668 Just one question please: If I want to place this script on another router than the ASUS (but still running DD-WRT, as my Buffalo), do I have to change this specific line: NAS=LS-WTGL668 And if so, what value should I put? Where can I find the exact specific "name" of my router? Hope that I'm clear ! ;-) Thanks a lot |
|
|
|
Feb 11 2012, 06:59 PM
Post
#6
|
|
|
WDTV USER ![]() Group: Members |
I am trying to adapt samui's script to wake my HTPC with no luck. I have a Linksys WRT54G DDWRT v24 SP2 and have added static leases with static IP for my HTPC and WDLive TV. WOL works manually but the script does not wake the HTPC when I power up the WDLive. What additional settings have to be changed to make this work? Any help is appreciated. (IMG:style_emoticons/default/smile.gif)
Reason for edit: Removed long unnecessary quote
|
|
|
|
![]() ![]() |
| Lo-Fi Version
Delete cookies set by this board · Mark all posts as read |
Time is now: 21st May 2013 - 12:01 AM |