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