Skip to content

Instantly share code, notes, and snippets.

@lowerpower
Last active February 16, 2017 16:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lowerpower/a43172a74e4ea67dce7c9809036f9d1e to your computer and use it in GitHub Desktop.
Save lowerpower/a43172a74e4ea67dce7c9809036f9d1e to your computer and use it in GitHub Desktop.
Reboot EnGenius gateway when we notice the ethernet is down (from wireless side, but would work ethernet side if ethernet is not the problem) Cron Monitor Script DDWRT
#!/bin/ash
#
# gw_cron.sh
#
# We had a problem wiht EnGenius access point loosing ethernet link, but was accessable
# from wireless side. we ran this script on one of the DDWRT routers on wireless side
# specifing an address on the other side of the ethernet link. Put this in a cron
# and specify an IP address on the other side, and if it is not accessable, check
# that the EnGenius access point is accessable, if so reboot it via the telnet CLI.
#
# we ran this every 15 min via cron on ddwrt on wireless side of access point
#
# put username, password and address of EnGenius gateway below.
#
# remove these comments if storing script in EEPROM
#
Monitor_ip='<pingable ip to monitor>'
EnGenius_gw='<ip of your EnGenius GW'
EnGenius_un='admin'
EnGenius_pw='<your pw>'
logger "monitor link script run"
ping -c10 -q $Monitor_ip
if [ $? -eq 0 ]; then
echo "alive"
exit 0
else
echo “"down reboot wireless if up"
ping -c10 -q $EnGenius_gw
if [ $? -eq 0 ]; then
echo "wireless up, reboot"
logger "reboot link"
{ sleep 2; echo $EnGenius_un; echo $EnGenius_pw; sleep 1; echo "reboot"; sleep 1; echo "logout"; } | telnet $EnGenius_gw
else
echo "wireless not up do nothing"
fi
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment