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
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