From d7fb76ba74b077cb047e0ef017e8db20862ffc5c Mon Sep 17 00:00:00 2001 From: dinger1986 Date: Mon, 10 Jul 2023 23:35:57 +0100 Subject: [PATCH] Update troubleshoot_server.sh --- troubleshoot_server.sh | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/troubleshoot_server.sh b/troubleshoot_server.sh index 311c01d7..bf3f8a35 100644 --- a/troubleshoot_server.sh +++ b/troubleshoot_server.sh @@ -23,24 +23,21 @@ osname=$(echo "$osname" | tr '[A-Z]' '[a-z]') relno=$(lsb_release -sr | cut -d. -f1) # Resolve Locally used DNS server -if [[ "$osname" == "debian" && "$relno" == 12 ]]; then -locdns=$(resolvconf -l | grep -m 1 -oE '[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+') -else resolvestatus=$(systemctl is-active systemd-resolved.service) -if [ $resolvestatus = active ]; then - locdns=$(resolvectl | grep -m 1 -oE '[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+') - echo -e $locdns +if [[ "$osname" == "debian" && "$relno" == 12 ]]; then +locdns=$(resolvconf -l | tail -n +1 | grep -m 1 -oE '[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+') + +elif [ $resolvestatus = active ]; then + locdns=$(resolvectl | tail -n +1 | grep -m 1 -oE '[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+') else - while ! [[ $resolveconf ]]; do + while ! [[ $resolveconf ]]; do resolveconf=$(sudo systemctl status systemd-resolved.service | grep "Active: active (running)") sudo systemctl start systemd-resolved.service echo -ne "DNS Resolver not ready yet...${NC}\n" sleep 3 done - locdns=$(resolvectl | grep -m 1 -oE '[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+') - echo -e $locdns + locdns=$(resolvectl | tail -n +1 | grep -m 1 -oE '[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+') sudo systemctl stop systemd-resolved.service -fi fi while [[ $rmmdomain != *[.]*[.]* ]]