Nov 28, 2012

Turn Off the wireless connection on the router as soon as there is no one connected

After developing a script to in order to remotely turn On  the wireless on my DD-WRT router, I have thought it would be a good idea if I could turn Off the wireless connection on the router as soon as there is no one connected anymore.

There might be I'm going to forget to turn it off, or maybe to lazy to do it, so anyhow Why not do it automatically?
So I started using the mighty Google and soon found out the answer on the DD-WRT Forum - the whole  credit for what I will be doing next goes to those guys.

The script is no more no less than the next, I have just changed the original echo true > with echo `date -u` >> for troubleshooting purposes:

if [ -e /tmp/wlan_idle_check ] && [ -z `wl assoclist` ]; 
         then wl radio off; rm /tmp/wlan_idle_check; 
elif [ -z `wl assoclist` ]; 
         then echo `date -u` >> /tmp/wlan_idle_check; 
else 
         rm /tmp/wlan_idle_check; fi;  

Next step I just need to go to router's web interface, activate the cron job and place the script preceded by 0,15,30,45 * * * * root
which will make the job run every 15 minutes.


Finally, according to the description available on DD-WRT forum:

- the cron job will be running every 15 minutes;
- If nobody is found online, cron at first writes a temporary file;
- On the next run if still none is there (file exists) it will disable the wlan;
- If someone is online, WLAN will stay enabled.

I have just had the opportunity to test and see it working  }:-)

No comments:

Post a Comment