From 8f69ccf45bab2a1710722f88a4bfaa1a674c35d5 Mon Sep 17 00:00:00 2001 From: Johan Date: Thu, 22 Dec 2022 08:25:05 +0100 Subject: [PATCH] Update install-bind.sh --- BashScripts/install-bind.sh | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/BashScripts/install-bind.sh b/BashScripts/install-bind.sh index a865331..d8d3c02 100644 --- a/BashScripts/install-bind.sh +++ b/BashScripts/install-bind.sh @@ -6,33 +6,33 @@ if [[ $EUID -ne 0 ]]; then fi REALUSER=$(logname) -apt update 2>>install.log +apt update -qq 2>>install.log -if ! ufw status | grep -q 'Status: active'; then +ufw status >/dev/null 2>&1 || ( echo "Installing UFW..." - apt install ufw -y 2>>install.log && - ufw default allow outgoing 2>>install.log && - ufw default deny incoming 2>>install.log && - ufw allow ssh 2>>install.log && + apt install ufw -y 2>>install.log + ufw default allow outgoing 2>>install.log + ufw default deny incoming 2>>install.log + ufw allow ssh 2>>install.log ufw enable 2>>install.log -fi -if nslookup 127.0.0.1 | grep -q 'command not found'; then +) +nslookup 127.0.0.1 >/dev/null 2>&1 || ( echo "Installing DNS utils..." - apt install dnsutils 2>>install.log -fi -if ! named -v | grep -q 'BIND'; then + apt install dnsutils -y 2>>install.log +) +named -v >/dev/null 2>&1 || ( echo "Installing BIND9..." apt install bind9 -y 2>>install.log && - ufw allow Bind9 -y 2>>install.log && + ufw allow Bind9 2>>install.log && nslookup google.com 127.0.0.1 -fi +) if ! grep -q "listen-on {" "/etc/bind/named.conf.options"; then sed -i -e 's/^};/\tlisten-on { any; };\n};/mig' /etc/bind/named.conf.options fi if ! grep -q "allow-query" "/etc/bind/named.conf.options"; then sed -i -e 's/^};/\tallow-query { any; };\n};/mig' /etc/bind/named.conf.options fi -if ! grep -q "\tforwarders {" "/etc/bind/named.conf.options"; then +if ! grep -q "forwarders { 1" "/etc/bind/named.conf.options"; then sed -i -e 's/^};/\tforwarders { 1.1.1.1; 8.8.8.8; 8.8.4.4; };\n};/mig' /etc/bind/named.conf.options fi named-checkconf && systemctl restart bind9