I have a dedicated plex media server and would like it to wake up when using plex.
I am using the method of the dd-wrt router to wake up the server.
Took me a while but finally got it to work, although still not completely.
Here’s the script I use. (deleted mac for privacy)
INTERVAL=1
PINGTIME=1
OLD=""
PORT=32400
WOLPORT=9
TARGET=192.168.1.64
BROADCAST=192.168.1.255
MAC=xx:xx:xx:xx:xx:xx
WOL=/usr/sbin/wol
LOGFILE="/tmp/www/wol.html"
echo “<meta http-equiv=“refresh” content=“10”>” > $LOGFILE
echo “AUTO WOL Script started at” date “
” >> $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 -qw $PINGTIME $TARGET >/dev/null; then
echo “NOWAKE $TARGET was accessed by $SRC and is already alive at” date “
”>> $LOGFILE
else
echo “WAKE $SRC causes wake on lan at” date “
”>> $LOGFILE
$WOL -i $BROADCAST -p $WOLPORT $MAC >> $LOGFILE
echo “
” >> $LOGFILE
sleep 1
fi
OLD=$NEW
fi
done
This is put in startup with the web interface
I see in some instructions this part, but it’s not clear to me. What do the first 2 lines mean?
#!/bin/sh
#Enable JFFS2 and place script in /jffs/ then run on startup in web interface.
#You can check the log from http://192.168.1.1/user/wol.html
Now to the problem, the server wakes when I access it from outside my own network.
But when the servers is awake, the routers keeps sending the wake command.
I see this line in the script 'echo “NOWAKE $TARGET was accessed by $SRC and is already alive at” date “
”>> $LOGFILE ’ which makes me believe that when the server is online I should get a message in the log, and the wake command is not send. However I never get this message, looks like the dd-wrt doesn’t see the server a being on, this also explains why it keeps sending the wake command every couple of seconds.
The server doesn’t wake when accessed from local lan. This I just don’t understand…
Anyone that can help me finetune things??