Skip to content

Commit

Permalink
Merge pull request #849 from alfinauzikri/check_connectivity
Browse files Browse the repository at this point in the history
Add script to check connectivity after set up nameservers
  • Loading branch information
usmannasir committed May 21, 2022
2 parents 675522d + 6a89d6c commit 3493fc8
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions cyberpanel.sh
Expand Up @@ -1197,6 +1197,10 @@ if ! grep -q "pid_max" /etc/rc.local 2>/dev/null ; then
systemctl mask systemd-resolved >/dev/null 2>&1
fi

# Backup previous resolv.conf file
cp /etc/resolv.conf /etc/resolv.conf_bak

# Delete resolv.conf file
rm -f /etc/resolv.conf

if [[ "$Server_Provider" = "Tencent Cloud" ]] ; then
Expand All @@ -1214,6 +1218,21 @@ if ! grep -q "pid_max" /etc/rc.local 2>/dev/null ; then
sleep 3
#take a break ,or installer will break

# Check Connectivity
if ping -q -c 1 -W 1 cyberpanel.sh >/dev/null; then
echo -e "\nSuccessfully set up nameservers..\n"
echo -e "\nThe network is up.. :)\n"
echo -e "\nContinue installation..\n"
else
echo -e "\nThe network is down.. :(\n"
rm -f /etc/resolv.conf
mv /etc/resolv.conf_bak /etc/resolv.conf
systemctl restart systemd-networkd >/dev/null 2>&1
echo -e "\nReturns the nameservers settings to default..\n"
echo -e "\nContinue installation..\n"
sleep 3
fi

cp /etc/resolv.conf /etc/resolv.conf-tmp

Line1="$(grep -n "f.write('nameserver 8.8.8.8')" installCyberPanel.py | head -n 1 | cut -d: -f1)"
Expand Down

0 comments on commit 3493fc8

Please sign in to comment.