Add handler for existing Unbound install

This commit is contained in:
randomshell 2018-09-15 13:27:19 +02:00
parent c015a62bb8
commit bb141bd797

View file

@ -863,6 +863,28 @@ prefetch: yes' > /etc/unbound/unbound.conf
# Restart the service # Restart the service
systemctl restart unbound systemctl restart unbound
else else
echo "Unbound is already installed." echo ""
echo "Unbound is already installed."
echo "You can allow the script to configure it automatically for OpenVPN integration:"
echo "an `include:` statement will be added to `unbound.conf` with the necessary changes in a separate `openvpn-server.conf` file."
echo "No other changes are made to the current configuration."
while [[ $CONTINUE != "y" && $CONTINUE != "n" ]]; do
read -rp "Apply configuration changes? [y/n]: " -e local CONTINUE
done
if [[ $CONTINUE = "y" ]]; then
# Add include: statement
awk '{ print } !flag && /server:/ { print " include: /etc/unbound/openvpn-server.conf"; flag = 1 }' /etc/unbound/unbound.conf > /etc/unbound/unbound.conf
# Add OpenVPN integration
echo 'interface: 10.8.0.1
access-control: 10.8.0.1/24 allow' > /etc/unbound/openvpn-server.conf
# Restart the service
systemctl restart unbound
else
echo "OpenVPN will be configured to use 10.8.0.1 IP for clients DNS"
echo "You need to manually configure Unbound to listen on this interface"
fi fi
} }