summaryrefslogtreecommitdiffstats
path: root/roles
diff options
context:
space:
mode:
authorScott Dodson <sdodson@redhat.com>2016-11-18 15:34:50 -0500
committerGitHub <noreply@github.com>2016-11-18 15:34:50 -0500
commit9b4df8fb52ae0978d3ad85513968a97a39a1bfbd (patch)
treef156f890ef5b91f52a420c9411ac2d2caa1780e5 /roles
parent35519353258cd586426af48506390ff886d26cf2 (diff)
parente61ec40b1b409c8cf61b41f9a8025dc45dd9d090 (diff)
downloadopenshift-9b4df8fb52ae0978d3ad85513968a97a39a1bfbd.tar.gz
openshift-9b4df8fb52ae0978d3ad85513968a97a39a1bfbd.tar.bz2
openshift-9b4df8fb52ae0978d3ad85513968a97a39a1bfbd.tar.xz
openshift-9b4df8fb52ae0978d3ad85513968a97a39a1bfbd.zip
Merge pull request #2822 from sdodson/onlydnsmasq
node_dnsmasq -- Set dnsmasq as our only nameserver
Diffstat (limited to 'roles')
-rwxr-xr-xroles/openshift_node_dnsmasq/files/networkmanager/99-origin-dns.sh15
1 files changed, 10 insertions, 5 deletions
diff --git a/roles/openshift_node_dnsmasq/files/networkmanager/99-origin-dns.sh b/roles/openshift_node_dnsmasq/files/networkmanager/99-origin-dns.sh
index ced0fa663..c3d5efb9e 100755
--- a/roles/openshift_node_dnsmasq/files/networkmanager/99-origin-dns.sh
+++ b/roles/openshift_node_dnsmasq/files/networkmanager/99-origin-dns.sh
@@ -36,6 +36,7 @@ if [[ $2 =~ ^(up|dhcp4-change)$ ]]; then
UPSTREAM_DNS_TMP=`mktemp`
UPSTREAM_DNS_TMP_SORTED=`mktemp`
CURRENT_UPSTREAM_DNS_SORTED=`mktemp`
+ NEW_RESOLV_CONF=`mktemp`
######################################################################
# couldn't find an existing method to determine if the interface owns the
@@ -85,13 +86,17 @@ EOF
systemctl restart dnsmasq
fi
- sed -i '0,/^nameserver/ s/^nameserver.*$/nameserver '"${def_route_ip}"'/g' /etc/resolv.conf
-
- if ! grep -q '99-origin-dns.sh' /etc/resolv.conf; then
- echo "# nameserver updated by /etc/NetworkManager/dispatcher.d/99-origin-dns.sh" >> /etc/resolv.conf
+ # Only if dnsmasq is running properly make it our only nameserver
+ if `systemctl -q is-active dnsmasq.service`; then
+ sed -e '/^nameserver.*$/d' /etc/resolv.conf > ${NEW_RESOLV_CONF}
+ echo "nameserver "${def_route_ip}"" >> ${NEW_RESOLV_CONF}
+ if ! grep -q '99-origin-dns.sh' ${NEW_RESOLV_CONF}; then
+ echo "# nameserver updated by /etc/NetworkManager/dispatcher.d/99-origin-dns.sh" >> ${NEW_RESOLV_CONF}
+ fi
+ cp -Z ${NEW_RESOLV_CONF} /etc/resolv.conf
fi
fi
# Clean up after yourself
- rm -f $UPSTREAM_DNS_TMP $UPSTREAM_DNS_TMP_SORTED $CURRENT_UPSTREAM_DNS_SORTED
+ rm -f $UPSTREAM_DNS_TMP $UPSTREAM_DNS_TMP_SORTED $CURRENT_UPSTREAM_DNS_SORTED $NEW_RESOLV_CONF
fi