Forum - Index
StrongVPN - StrongSecurity for your internet connection and anonymity for your online presense
Get a US IP address to access NetFlix :: HULU :: Pandora content from anywhere in the world
Welcome to the WDTVFORUMS, Please register.

WD TV HD the media player by Western Digital plays almost any Movie format and Music format. Please take the time to register and show support as well as give support for all WD TV models. Use the link below to register and enjoy all the advantages of being a member, enter upcoming contests, see all the images and enjoy all the downloadable content the forum has to offer. Thank you and see you on the boards!

  • REGISTER HERE! (fast and free)

  • Welcome Guest ( Log In | Register )



       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
    samui
    post Oct 29 2009, 11:41 PM
    Post #1


    WDTV USER
    *

    Group: Members
    Posts: 2
    Joined: 29-October 09
    Member No.: 5,349




    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)
    Go to the top of the page
     
    +Quote Post



    Reply to this topicStart new topic
    1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
    0 Members:

     

    Lo-Fi Version
    Delete cookies set by this board · Mark all posts as read
    Time is now: 24th May 2013 - 05:31 PM