mirror of
https://gitea.com/mcereda/oam.git
synced 2026-02-09 05:44:23 +00:00
Imported scripts from private repository and enforced the naming convention
This commit is contained in:
21
scripts/reset-wifi-if-no-internet-connection.bash
Normal file
21
scripts/reset-wifi-if-no-internet-connection.bash
Normal file
@@ -0,0 +1,21 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
interface="wlan0"
|
||||
|
||||
max_retries=3
|
||||
timeout=1
|
||||
|
||||
log_path="$(dirname $0)/$(basename $0).log"
|
||||
log_prefix="$(date +'%Y-%m-%d %T')"
|
||||
|
||||
i=0
|
||||
until [ $i -eq $max_retries ]; do
|
||||
let "i++"
|
||||
if nc -Nz -w $timeout www.google.com 443; then
|
||||
echo "$log_prefix" "connection is OK" >> $log_path
|
||||
break
|
||||
else
|
||||
echo "$log_prefix" "no connection, resetting interface" >> $log_path
|
||||
sudo ifconfig wlan0 down && sudo ifconfig wlan0 up
|
||||
fi
|
||||
done
|
||||
Reference in New Issue
Block a user