auto relogin cron script to captive portal on wlan client interface
in cron: (crontab -e) or Scheduled Tasks
* * * * * /etc/crontabs/captive-login.sh
in /etc/crontab/captive-login.sh with chmod 755 captive-login.sh
#!/bin/sh
# captive-login.sh auto relogin to captive portal on wlan client interface
#
# ping captive portal, not reachable => restart wlan
# ping internet address, not reachable => login to captive portal
# logger "captive-login: auto relogin to captive portal by wlan"
# url or id-adress of the captive portal
url_cp=<xxx.xxx.xxx.xxx>
# login-link to the captive portal
url_cp_login=<https:/yyyyy.com/yyyy>
# url or ip-adress of an internet server
url_net=8.8.8.8
# ping captive portal
return_text=$(ping -c 2 -W 4 $url_cp)
return_value=$?
# logger "captive-login: PING VALUE: $return_value; PING TEXT: $return_text"
case $return_value in
0) ;;
1) wifi down radio0
logger "captive-login: reconnect wlan"
sleep 5s
wifi up radio0
sleep 5s
;;
*) ;;
esac
# ping internet address
return_text=$(ping -c 2 -W 4 $url_net)
return_value=$?
case $return_value in
0) ;;
1) wget $url_cp_login -0 /dev/null
logger "captive-login: login"
;;
*) ;;
esac
I am still testing, if this runs well in all situations.
It should be improved in situations of fails.
Peter