From 874f32a33fb851285a0ac4cbe25cb08c8e8d745b Mon Sep 17 00:00:00 2001 From: shihaam Date: Thu, 2 Jun 2022 20:48:34 +0500 Subject: [PATCH] dig instead of ping + efficiency --- nginx-allow-dynamicip/nginx-allow-dynamicip.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nginx-allow-dynamicip/nginx-allow-dynamicip.sh b/nginx-allow-dynamicip/nginx-allow-dynamicip.sh index 51985dd..e5a4482 100755 --- a/nginx-allow-dynamicip/nginx-allow-dynamicip.sh +++ b/nginx-allow-dynamicip/nginx-allow-dynamicip.sh @@ -3,7 +3,7 @@ CONFIG=/etc/nginx/sites-enabled/$1 DOMAIN=$2 -IP=$(ping -c 1 $DOMAIN | awk '{print $3}' | head -n 1 | sed 's\(\\' | sed 's\)\\') +IP=$(dig $DOMAIN +short) IP_OLD=$(grep -A0 '#DYNAMIC' $CONFIG | awk '{print $2}' | cut -f1 -d ';') if [ "$IP" != "$IP_OLD" ]