Created
January 25, 2016 10:55
-
-
Save sjmf/2e02fc95ca32e46a7f9a to your computer and use it in GitHub Desktop.
Aggressive Wifi-reconnect script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
cd "$(dirname "$0")" | |
# Set up 3g usb dongle ZTE WCDMA Technologies MSM MF110 | |
if [ "$EUID" -ne 0 ]; then | |
echo "Please run this script as root"; exit 1; | |
fi | |
# Create script in /opt/ | |
mkdir -p /opt/wifi/ | |
cat <<< '#!/bin/bash | |
if ! ping -c1 8.8.8.8; then | |
ifdown --force wlan0 && | |
ifup --force wlan0 && | |
echo Wifi reset on: `date` | |
else | |
echo Wifi is up: `date` | |
fi | |
' >/opt/wifi/wifi.sh | |
chmod +x /opt/wifi/wifi.sh | |
# Create entry in crontab to run script | |
crontab -l > mycron | |
echo "* * * * * bash /opt/tunnel/wifi.sh > /var/log/wifi.log 2>&1" >> mycron | |
crontab mycron | |
rm mycron |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment