Created
December 5, 2019 10:24
-
-
Save tyilo/2356ba1143aa354a19b9e67c3ef43040 to your computer and use it in GitHub Desktop.
Fix NetworkManager
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 | |
if [[ $(id -u) -ne 0 ]]; then | |
echo "Run with root!" | |
exit 1 | |
fi | |
net_connected() { | |
ping -c 1 1.1.1.1 > /dev/null | |
} | |
while true; do | |
if ! net_connected; then | |
echo "Restarting NetworkManager" | |
systemctl restart NetworkManager | |
while ! net_connected; do | |
sleep 1 | |
done | |
echo "Internet seems to work again" | |
fi | |
sleep 1 | |
done |
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
[Unit] | |
Description=Automatically restarts NetworkManager if internet access becomes unavailable | |
[Service] | |
ExecStart=/usr/sbin/fix-nm | |
[Install] | |
WantedBy=multi-user.target |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment