Set up dnsmasq on seed node
MOSSUST-121
Change-Id: I1718c01aa1f60a20359357a352ce9ea950391114
diff --git a/bm_mcc_mosk/seed/setup_dnsmasq.sh b/bm_mcc_mosk/seed/setup_dnsmasq.sh
new file mode 100755
index 0000000..d9f110f
--- /dev/null
+++ b/bm_mcc_mosk/seed/setup_dnsmasq.sh
@@ -0,0 +1,25 @@
+#!/bin/bash
+set -ex
+
+if [ "$#" -ne 1 ]; then
+ echo "Usage: $0 COREDNS_IP"
+ exit 1
+fi
+
+export DEBIAN_FRONTEND=noninteractive
+export DEBCONF_NONINTERACTIVE_SEEN=true
+APT_OPTS="-y -o APT::Install-Suggests=0 -o APT::Install-Recommends=0 -o Dpkg::Options::=--force-confold -o Dpkg::Options::=--force-confdef"
+
+apt ${APT_OPTS} install dnsmasq
+service systemd-resolved stop
+systemctl disable systemd-resolved
+rm /etc/resolv.conf
+cat > /etc/resolv.conf <<EOF
+nameserver 127.0.0.1
+EOF
+LISTEN_ADDR=$(ip a | grep 172 | awk '{print $2}' | awk -F/ '{print $1}' | head -n1)
+grep "${LISTEN_ADDR}" /etc/dnsmasq.conf || echo "listen-address=::1,127.0.0.1,${LISTEN_ADDR}" >> /etc/dnsmasq.conf
+grep "subdomain.team.sustaining" /etc/dnsmasq.conf || echo "server=/*.subdomain.team.sustaining/${1}" >> /etc/dnsmasq.conf
+grep "mnt-bm.mirantis.net" /etc/dnsmasq.conf || echo "server=/*.mnt-bm.mirantis.net/${1}" >> /etc/dnsmasq.conf
+grep "server=172.18.176.6" /etc/dnsmasq.conf || echo "server=172.18.176.6" >> /etc/dnsmasq.conf
+service dnsmasq restart