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) |
|
|
|
samui Wake-on-lan script for auto-mode NAS/media server (no more 24/7 turned on) Oct 29 2009, 11:41 PM
nameht I have tomato firmware, is it possible to run this... Jan 8 2010, 03:39 AM
SignorRossi QUOTE (nameht @ Jan 8 2010, 02:39 AM) I h... Oct 14 2010, 06:23 PM
jonny87 hello,
is it possible to run this script with a f... Oct 10 2010, 03:42 AM
Jayme65 QUOTE (samui @ Oct 30 2009, 01:41 AM) NAS... Oct 27 2011, 11:55 AM
rostar I am trying to adapt samui's script to wake my... Feb 11 2012, 06:59 PM![]() ![]() |
| Lo-Fi Version
Delete cookies set by this board · Mark all posts as read |
Time is now: 24th May 2013 - 05:31 PM |