This little post is about Open-mesh cloud controlled wireless access points and a little scripting to make them function in our environment.
So, a very nice man donated several of these Open-mesh wireless access points to our international school. They are really affordably priced and the concept behind them is great. They can run off of passive POE or regular power and can detect if they are on the wire or not. When they are on the wire they can act as a gateway to other devices and if they do not detect the wire they can wirelessly mesh with others that are in gateway mode creating a mesh of wireless ap’s to serve your single SSID across a campus. They connect to open-mesh’s cloud service where they can be centrally monitored and configured from anywhere.
Now all of that is great right? Absolutely! The only issue is we are in Ethiopia and in this developing country there are two things that are very inconsistent. Electricity, and Internet connection. Now sure, we have a huge generator, and UPS’s in the server closet, as well as a 12Mb fiber line provided by the telecom. UPS’s are very expensive here and they do not last long so we just can’t cover everything. When we lose power, which happens frequently each day, these device are not necessarily designed for that. When they come back up and don’t initially find a connection to the cloud, they tend to go into what I like to call a zombie state. They are on, but they stop trying to connect to the cloud so they can function properly and actually communicate on the network. After much troubleshooting and frustration and support tickets and firmware updates, I finally just came up with a script that runs every 10 minutes and checks to see if it can ping the inside gateway on our network. If it fails it reboots itself and usually finds the connection to the cloud and starts to work properly.
Here are the the instructions for the rebootIfDead script.
Find the IP of your device in the cloudtrax console and ssh into the device.
ssh root@DEVICEIP password
Change the target=”xx.xx.xx.xx” line to your gateway IP and copy and paste the following lines.
# Clear screen
# Create rebootIfDeadFile in /sbin folder
# Put in all the commands to the new file
echo 'SHELL=/bin/ash' >> /sbin/rebootIfDead
echo 'target="GATEWAY-IP-HERE"' >> /sbin/rebootIfDead
echo 'ping -q -c1 $target > /dev/null' >> /sbin/rebootIfDead
echo 'if [ $? -eq 0 ]' >> /sbin/rebootIfDead
echo 'then' >> /sbin/rebootIfDead
echo 'echo "Im Alive!!"' >> /sbin/rebootIfDead
echo 'else' >> /sbin/rebootIfDead
echo 'touch /tmp/pingfail.txt' >> /sbin/rebootIfDead
echo 'date >> /tmp/pingfail.txt' >> /sbin/rebootIfDead
echo 'echo "Im Dead!"' >> /sbin/rebootIfDead
echo '/sbin/reboot -f' >> /sbin/rebootIfDead
echo 'fi' >> /sbin/rebootIfDead
# Make the file executable
chmod +x /sbin/rebootIfDead
# Write out current crontab
crontab -l > tmpCron
# Put new cron statement into cron file
echo "0-59/10 * * * * /sbin/rebootIfDead" >> tmpCron
# Install new cron file
# Display the rebootIfDeadScript
ls -l /sbin/rebootIfDead
# Diplay crontab
This will create a file called rebootIfDead in the /sbin folder, mark it executable and fill it with the following contents:
ping -q -c1 $target > /dev/null
if [ $? -eq 0 ]
echo "Im Alive!!"
date >> /tmp/pingfail.txt
echo "Im Dead!"
Next it will add a recurring 10 minute launch of the script to the crontab.
Maybe there is another way to fix this issue or maybe it just presents itself in inconsistent power and internet situations such as ours.
Do you run Open-mesh, I would love to hear you thoughts!
Remember, be safe and please script at your own risk!