What's new

Wake PC on plex request

  • SNBForums Code of Conduct

    SNBForums is a community for everyone, no matter what their level of experience.

    Please be tolerant and patient of others, especially newcomers. We are all here to share and learn!

    The rules are simple: Be patient, be nice, be helpful or be gone!

david279

Occasional Visitor
Im trying to come up with a method to wake my PC when someone tried to access the plex server from it. I found this script here https://forums.plex.tv/discussion/comment/884603#Comment_884603 originally for ddwrt and tried to modified it for merlin firmware but it doesn't seem to work.
Any help appreciated


Code:
#!/bin/sh
#Enable JFFS2 and place script in /jffs/ then run on startup in web interface.

INTERVAL=5
NUMP=3
OLD=""
PORT=32400
WOLPORT=9
TARGET=192.168.29.X
BROADCAST=192.168.29.255
MAC="XX:XX:XX:XX:XX:XX"
WOL="/usr/bin/ether-wake"
LOGFILE="/tmp/www/wol.html"

echo "<meta http-equiv=\"refresh\" content=\"10\">" > $LOGFILE
echo "AUTO WOL Script started at" `date` "<br>" >> $LOGFILE

while sleep $INTERVAL;do
NEW=`dmesg | awk '/ACCEPT/ && /DST='"$TARGET"'/ && /DPT='"$PORT"'/ {print }' | tail -1`
SRC=`dmesg | awk -F'[=| ]' '/ACCEPT/ && /DST='"$TARGET"'/ && /DPT='"$PORT"'/ {print $7}' | tail -1`
LINE=`dmesg | awk '/ACCEPT/ && /DST='"$TARGET"'/ && /DPT='"$PORT"'/'`
                                                                                                                           
if [ "$NEW" != "" -a "$NEW" != "$OLD" ]; then
   if ping -qc $NUMP $TARGET >/dev/null; then
      echo "NOWAKE $TARGET was accessed by $SRC and is already alive at" `date` "<br>">> $LOGFILE
   else
      echo "WAKE $SRC causes wake on lan at" `date` "<br>">> $LOGFILE
      $WOL -i $MAC >> $LOGFILE
      echo "<br>" >> $LOGFILE
      sleep 5
   fi
   OLD=$NEW
fi
done
 
Happy that you found it.

I, however, found it too unreliable as I saw a lot of uncalled for wake and couldn't figure out where why they were coming from my phone despite the app being closed. Also, I saw wake calls from random ip's, which was why I made a whitelist. Maybe you will figure out somehting better and we can add it to the script.
 

Similar threads

Latest threads

Support SNBForums w/ Amazon

If you'd like to support SNBForums, just use this link and buy anything on Amazon. Thanks!

Sign Up For SNBForums Daily Digest

Get an update of what's new every day delivered to your mailbox. Sign up here!
Top