From bb141bd797f8703fa0e6aa9639aca2aaa4bb8af2 Mon Sep 17 00:00:00 2001 From: randomshell <43271778+randomshell@users.noreply.github.com> Date: Sat, 15 Sep 2018 13:27:19 +0200 Subject: [PATCH] Add handler for existing Unbound install --- openvpn-install.sh | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/openvpn-install.sh b/openvpn-install.sh index 6a93997..f557209 100644 --- a/openvpn-install.sh +++ b/openvpn-install.sh @@ -863,6 +863,28 @@ prefetch: yes' > /etc/unbound/unbound.conf # Restart the service systemctl restart unbound 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 }