Fix IP_RANGE variable substitution

This commit is contained in:
Unknown 2020-02-29 01:35:33 -05:00
parent d7cbcf7ec1
commit 239b5be082
No known key found for this signature in database
GPG Key ID: 3222DB0F636031B6

View File

@ -104,19 +104,19 @@ function installUnbound () {
apt-get install -y unbound apt-get install -y unbound
# Configuration # Configuration
echo 'interface: ${VAR: : -1}1 echo "interface: ${IP_RANGE: : -1}1
access-control: ${VAR: : -1}1/24 allow access-control: ${IP_RANGE: : -1}1/24 allow
hide-identity: yes hide-identity: yes
hide-version: yes hide-version: yes
use-caps-for-id: yes use-caps-for-id: yes
prefetch: yes' >> /etc/unbound/unbound.conf prefetch: yes" >> /etc/unbound/unbound.conf
elif [[ "$OS" =~ (centos|amzn) ]]; then elif [[ "$OS" =~ (centos|amzn) ]]; then
yum install -y unbound yum install -y unbound
# Configuration # Configuration
sed -i 's|# interface: 0.0.0.0$|interface: ${VAR: : -1}1|' /etc/unbound/unbound.conf sed -i "s|# interface: 0.0.0.0$|interface: ${IP_RANGE: : -1}1|" /etc/unbound/unbound.conf
sed -i 's|# access-control: 127.0.0.0/8 allow|access-control: ${VAR: : -1}1/24 allow|' /etc/unbound/unbound.conf sed -i "s|# access-control: 127.0.0.0/8 allow|access-control: ${IP_RANGE: : -1}1/24 allow|" /etc/unbound/unbound.conf
sed -i 's|# hide-identity: no|hide-identity: yes|' /etc/unbound/unbound.conf sed -i 's|# hide-identity: no|hide-identity: yes|' /etc/unbound/unbound.conf
sed -i 's|# hide-version: no|hide-version: yes|' /etc/unbound/unbound.conf sed -i 's|# hide-version: no|hide-version: yes|' /etc/unbound/unbound.conf
sed -i 's|use-caps-for-id: no|use-caps-for-id: yes|' /etc/unbound/unbound.conf sed -i 's|use-caps-for-id: no|use-caps-for-id: yes|' /etc/unbound/unbound.conf
@ -125,8 +125,8 @@ prefetch: yes' >> /etc/unbound/unbound.conf
dnf install -y unbound dnf install -y unbound
# Configuration # Configuration
sed -i 's|# interface: 0.0.0.0$|interface: ${VAR: : -1}1|' /etc/unbound/unbound.conf sed -i "s|# interface: 0.0.0.0$|interface: ${IP_RANGE: : -1}1|" /etc/unbound/unbound.conf
sed -i 's|# access-control: 127.0.0.0/8 allow|access-control: ${VAR: : -1}1/24 allow|' /etc/unbound/unbound.conf sed -i "s|# access-control: 127.0.0.0/8 allow|access-control: ${IP_RANGE: : -1}1/24 allow|" /etc/unbound/unbound.conf
sed -i 's|# hide-identity: no|hide-identity: yes|' /etc/unbound/unbound.conf sed -i 's|# hide-identity: no|hide-identity: yes|' /etc/unbound/unbound.conf
sed -i 's|# hide-version: no|hide-version: yes|' /etc/unbound/unbound.conf sed -i 's|# hide-version: no|hide-version: yes|' /etc/unbound/unbound.conf
sed -i 's|# use-caps-for-id: no|use-caps-for-id: yes|' /etc/unbound/unbound.conf sed -i 's|# use-caps-for-id: no|use-caps-for-id: yes|' /etc/unbound/unbound.conf
@ -139,15 +139,15 @@ prefetch: yes' >> /etc/unbound/unbound.conf
mv /etc/unbound/unbound.conf /etc/unbound/unbound.conf.old mv /etc/unbound/unbound.conf /etc/unbound/unbound.conf.old
echo 'server: echo "server:
use-syslog: yes use-syslog: yes
do-daemonize: no do-daemonize: no
username: "unbound" username: \"unbound\"
directory: "/etc/unbound" directory: \"/etc/unbound\"
trust-anchor-file: trusted-key.key trust-anchor-file: trusted-key.key
root-hints: root.hints root-hints: root.hints
interface: ${VAR: : -1}1 interface: ${IP_RANGE: : -1}1
access-control: ${VAR: : -1}1/24 allow access-control: ${IP_RANGE: : -1}1/24 allow
port: 53 port: 53
num-threads: 2 num-threads: 2
use-caps-for-id: yes use-caps-for-id: yes
@ -155,7 +155,7 @@ prefetch: yes' >> /etc/unbound/unbound.conf
hide-identity: yes hide-identity: yes
hide-version: yes hide-version: yes
qname-minimisation: yes qname-minimisation: yes
prefetch: yes' > /etc/unbound/unbound.conf prefetch: yes" > /etc/unbound/unbound.conf
fi fi
if [[ ! "$OS" =~ (fedora|centos|amzn) ]];then if [[ ! "$OS" =~ (fedora|centos|amzn) ]];then
@ -173,9 +173,9 @@ private-address: ::ffff:0:0/96" >> /etc/unbound/unbound.conf
echo 'include: /etc/unbound/openvpn.conf' >> /etc/unbound/unbound.conf echo 'include: /etc/unbound/openvpn.conf' >> /etc/unbound/unbound.conf
# Add Unbound 'server' for the OpenVPN subnet # Add Unbound 'server' for the OpenVPN subnet
echo 'server: echo "server:
interface: ${VAR: : -1}1 interface: ${IP_RANGE: : -1}1
access-control: ${VAR: : -1}1/24 allow access-control: ${IP_RANGE: : -1}1/24 allow
hide-identity: yes hide-identity: yes
hide-version: yes hide-version: yes
use-caps-for-id: yes use-caps-for-id: yes
@ -187,7 +187,7 @@ private-address: 169.254.0.0/16
private-address: fd00::/8 private-address: fd00::/8
private-address: fe80::/10 private-address: fe80::/10
private-address: 127.0.0.0/8 private-address: 127.0.0.0/8
private-address: ::ffff:0:0/96' > /etc/unbound/openvpn.conf private-address: ::ffff:0:0/96" > /etc/unbound/openvpn.conf
fi fi
systemctl enable unbound systemctl enable unbound
@ -760,7 +760,7 @@ ifconfig-pool-persist ipp.txt" >> /etc/openvpn/server.conf
done done
;; ;;
2) 2)
echo 'push "dhcp-option DNS ${VAR: : -1}1"' >> /etc/openvpn/server.conf echo "push \"dhcp-option DNS ${IP_RANGE: : -1}1\"" >> /etc/openvpn/server.conf
;; ;;
3) # Cloudflare 3) # Cloudflare
echo 'push "dhcp-option DNS 1.0.0.1"' >> /etc/openvpn/server.conf echo 'push "dhcp-option DNS 1.0.0.1"' >> /etc/openvpn/server.conf