What's new

Running dd-wrt script on asus wrt

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

Tyfoon

New Around Here
I now have DD-WRT installed on my AC66U but would prefer to use ASUSWRT as DD-WRT is causing me some issues.

I originally switched to DD-WRT (from stock Asus firmware) because I needed to run a script to detect if mobile phones entered the network. If so, these would trigger an HTTP command that was send to my VERA (house automation) to detect presence.

Please note I'm new to scripting on the router and I just followed a copy-paste exercise to get this working on dd-wrt (and of course changing some MAC & IP adresses).

Can someone tell me IF I can do the same on AsusWRT and if yes, how.

Any help is greatly appreciated!

I now have a startup script in DD-WRT:
while [ ! -e "/tmp/custom.sh" ]; do
sleep 1 # wait till /tmp/custom.sh gets generated
done
/tmp/custom.sh &

And then a script in Custom Scripts (XX replace actual MAC adresses to avoid posting real MACs):

#!/bin/sh
WATCHDOG_SLEEP_SEC=10
MAC_ADDRESS_1="XX:XX:XX:XX:XX:XX"
c1_last_state="0"
MAC_ADDRESS_2=""XX:XX:XX:XX:XX:XX"
c2_last_state="0"
MAC_ADDRESS_3="XX:XX:XX:XX:XX:XX"
c3_last_state="0"
MAC_ADDRESS_4="XX:XX:XX:XX:XX:XX"
c4_last_state="0"
HOST_2="192.168.1.101"
h2_last_state="x"
HOST_3="192.168.1.102"
h3_last_state="x"
HOST_4="192.168.1.40"
h4_last_state="0"
VERAURL="http://192.168.1.5:3480/data_reques...=urn:dcineco-com:serviceId:MSwitch1&Variable="
x=0
y=0
offcount1=0
offcount2=0
offcount3=0
offcount4=0

while sleep $WATCHDOG_SLEEP_SEC
do
if [ "$x" == 180 ]; then
# Every 30 minutes or so we do them all again, just in case Vera missed something
x=0
c1_last_state="0"
c2_last_state="0"
c3_last_state="0"
c4_last_state="0"
h2_last_state="0"
h3_last_state="0"
h4_last_state="0"
h10_last_state="0"
fi
x=$(( $x + 1 ))

c1_new_state=`wl -a eth1 assoclist | grep $MAC_ADDRESS_1`
if [ "$c1_new_state" == "$c1_last_state" ] ; then
sleep 0
else
if [ "$c1_new_state" == "assoclist $MAC_ADDRESS_1" ]; then
c1_last_state="$c1_new_state"
wget -qs "${VERAURL}Status1&Value=1"
offcount1=0
else
offcount1=$(( $offcount1 + 1 ))
fi
fi

c2_new_state=`wl -a eth1 assoclist | grep $MAC_ADDRESS_2`
if [ "$c2_new_state" == "$c2_last_state" ] ; then
sleep 0
else
if [ "$c2_new_state" == "assoclist $MAC_ADDRESS_2" ]; then
c2_last_state="$c2_new_state"
wget -qs "${VERAURL}Status2&Value=1"
offcount2=0
else
offcount2=$(( $offcount2 + 1 ))
fi
fi

c3_new_state=`wl -a eth1 assoclist | grep $MAC_ADDRESS_3`
if [ "$c3_new_state" == "$c3_last_state" ] ; then
sleep 0
else
if [ "$c3_new_state" == "assoclist $MAC_ADDRESS_3" ]; then
c3_last_state="$c3_new_state"
wget -qs "${VERAURL}Status3&Value=1"
offcount3=0
else
offcount3=$(( $offcount3 + 1 ))
fi
fi

c4_new_state=`wl -a eth1 assoclist | grep $MAC_ADDRESS_4`
if [ "$c4_new_state" == "$c4_last_state" ] ; then
sleep 0
else
if [ "$c4_new_state" == "assoclist $MAC_ADDRESS_4" ]; then
c4_last_state="$c4_new_state"
wget -qs "${VERAURL}Status4&Value=1"
offcount4=0
else
offcount4=$(( $offcount4 + 1 ))
fi
fi

if [ $offcount1 -lt 6 ]; then
# give not responding devices 1 minute to respond
sleep 0
else
c1_last_state="$c1_new_state"
wget -qs "${VERAURL}Status1&Value=0"
offcount1=0
fi

if [ $offcount2 -lt 6 ]; then
#give not responding devices 1 minute to respond
sleep 0
else
c2_last_state="$c2_new_state"
wget -qs "${VERAURL}Status2&Value=0"
offcount2=0
fi

if [ $offcount3 -lt 6 ]; then
#give not responding devices 1 minute to respond
sleep 0
else
c3_last_state="$c3_new_state"
wget -qs "${VERAURL}Status3&Value=0"
offcount3=0
fi

if [ $offcount4 -lt 6 ]; then
#give not responding devices 1 minute to respond
sleep 0
else
c4_last_state="$c4_new_state"
wget -qs "${VERAURL}Status4&Value=0"
offcount4=0
fi

# Ping LAN hosts


h3_new_state=`ping -w 1 -c 1 $HOST_3 | grep 'received' | awk -F',' '{ print $2}' | awk '{ print $1}'`
if [ "$h3_new_state" == "$h3_last_state" ] ; then
sleep 0
else
h3_last_state="$h3_new_state"
if [ "$h3_new_state" == "1" ]; then
wget -qs "${VERAURL}Status6&Value=1"
else
wget -qs "${VERAURL}Status6&Value=0"
fi
fi

h4_new_state=`ping -w 1 -c 1 $HOST_4 | grep 'received' | awk -F',' '{ print $2}' | awk '{ print $1}'`
if [ "$h4_new_state" == "$h4_last_state" ] ; then
sleep 0
else
h4_last_state="$h4_new_state"
if [ "$h4_new_state" == "1" ]; then
wget -qs "${VERAURL}Status5&Value=1"
else
wget -qs "${VERAURL}Status5&Value=0"
fi
fi

done
 

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!

Members online

Top