From 6a89d6c61736edf07accc2c250dcb9e1f2837ed3 Mon Sep 17 00:00:00 2001 From: Alfin Auzikri Date: Tue, 5 Apr 2022 22:57:34 +0700 Subject: [PATCH] add script to check connectivity after set up nameservers --- cyberpanel.sh | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/cyberpanel.sh b/cyberpanel.sh index 9e059731f..aeddb9eaa 100644 --- a/cyberpanel.sh +++ b/cyberpanel.sh @@ -1187,6 +1187,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 @@ -1204,6 +1208,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)"