Vladimir Khlyunev | 3f27ff7 | 2024-11-01 14:42:24 +0400 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | set -ex |
| 3 | |
| 4 | if [ "$#" -ne 1 ]; then |
| 5 | echo "Usage: $0 COREDNS_IP" |
| 6 | exit 1 |
| 7 | fi |
| 8 | |
| 9 | export DEBIAN_FRONTEND=noninteractive |
| 10 | export DEBCONF_NONINTERACTIVE_SEEN=true |
| 11 | APT_OPTS="-y -o APT::Install-Suggests=0 -o APT::Install-Recommends=0 -o Dpkg::Options::=--force-confold -o Dpkg::Options::=--force-confdef" |
| 12 | |
| 13 | apt ${APT_OPTS} install dnsmasq |
| 14 | service systemd-resolved stop |
| 15 | systemctl disable systemd-resolved |
| 16 | rm /etc/resolv.conf |
| 17 | cat > /etc/resolv.conf <<EOF |
| 18 | nameserver 127.0.0.1 |
| 19 | EOF |
| 20 | LISTEN_ADDR=$(ip a | grep 172 | awk '{print $2}' | awk -F/ '{print $1}' | head -n1) |
| 21 | grep "${LISTEN_ADDR}" /etc/dnsmasq.conf || echo "listen-address=::1,127.0.0.1,${LISTEN_ADDR}" >> /etc/dnsmasq.conf |
| 22 | grep "subdomain.team.sustaining" /etc/dnsmasq.conf || echo "server=/*.subdomain.team.sustaining/${1}" >> /etc/dnsmasq.conf |
| 23 | grep "mnt-bm.mirantis.net" /etc/dnsmasq.conf || echo "server=/*.mnt-bm.mirantis.net/${1}" >> /etc/dnsmasq.conf |
| 24 | grep "server=172.18.176.6" /etc/dnsmasq.conf || echo "server=172.18.176.6" >> /etc/dnsmasq.conf |
| 25 | service dnsmasq restart |