Created
May 24, 2022 16:25
-
-
Save oldkingcone/6efbe39d6944e2040e1c01abe535a2ec to your computer and use it in GitHub Desktop.
check parrot OS network connection, create missing file and retest network connection.
This file contains hidden or 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 | |
clear | |
while :; do | |
ping -c1 google.com | |
if [[ $? -eq 0 ]]; then | |
echo "Connected!" | |
break | |
else | |
clear | |
date | |
if ! [[ -f "/run/systemd/resolve/stub-resolv.conf" ]]; then | |
echo -e "\033[0;31mAttempting to create file.\033[0m\n" | |
if [[ -e "/run/systemd/resolve/" ]]; then | |
sudo rm -rf /run/systemd/resolve/ | |
if [ $? -eq 0 ]; then | |
echo "Removed previously created directory." | |
echo | |
else | |
echo "Unable to remove previous directory....." | |
echo | |
fi | |
fi | |
sudo mkdir -p /run/systemd/resolve/ | |
sudo echo -e "search local\nnameserver 1.1.1.1\nnameserver 1.0.0.1" > /run/systemd/resolve/stub-resolv.conf | |
if [ $? -eq 0 ]; then | |
echo "File created!" | |
echo | |
file /run/systemd/resolve/stub-resolv.conf | |
else | |
echo -e "\033[0;31mFile creation failed!!!\033[0m" | |
echo | |
fi | |
else | |
echo "File exists, not sure why there is no internet. Check host system to ensure that the host has actual internet connection." | |
fi | |
fi | |
sleep 1 | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
this script can only be run as the root user. sudo will not allow you to write to that directory.