Forum - Index
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 )


     
    Reply to this topicStart new topic
       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
    post Oct 29 2009, 11:41 PM
    Post #


    SITE SUPPORT


    Group: Bot

    Joined: Today, 03:16 PM




    Go to the top of the page
     
    Quote Post
    nameht
    post Jan 8 2010, 03:39 AM
    Post #2


    WDTV USER
    *

    Group: Members
    Posts: 1
    Joined: 8-January 10
    Member No.: 10,615




    I have tomato firmware, is it possible to run this script on there?

    thanks!
    Go to the top of the page
     
    +Quote Post
    jonny87
    post Oct 10 2010, 03:42 AM
    Post #3


    WDTV SEMI-PRO
    **

    Group: Members
    Posts: 13
    Joined: 9-October 10
    Member No.: 27,552




    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!
    Go to the top of the page
     
    +Quote Post
    SignorRossi
    post Oct 14 2010, 06:23 PM
    Post #4


    WDTV USER
    *

    Group: Members
    Posts: 2
    Joined: 19-February 10
    Member No.: 13,270




    QUOTE (nameht @ Jan 8 2010, 02:39 AM) *
    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.
    Go to the top of the page
     
    +Quote Post
    Jayme65
    post Oct 27 2011, 11:55 AM
    Post #5


    WDTV USER
    *

    Group: Members
    Posts: 3
    Joined: 18-February 10
    Member No.: 13,205




    QUOTE (samui @ Oct 30 2009, 01:41 AM) *
    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
    Go to the top of the page
     
    +Quote Post
    rostar
    post Feb 11 2012, 06:59 PM
    Post #6


    WDTV USER
    *

    Group: Members
    Posts: 1
    Joined: 11-February 12
    Member No.: 105,626




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

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

     

    Lo-Fi Version
    Delete cookies set by this board · Mark all posts as read
    Time is now: 30th July 2014 - 03:16 PM