diff options
author | Scott Dodson <sdodson@redhat.com> | 2016-11-18 10:58:56 -0500 |
---|---|---|
committer | Scott Dodson <sdodson@redhat.com> | 2016-11-18 11:15:22 -0500 |
commit | e61ec40b1b409c8cf61b41f9a8025dc45dd9d090 (patch) | |
tree | 0dc58bfefe30b0d31587b2e66b69cc71a7a91c78 /roles | |
parent | 477a8171069402237f11523052017c79f53700b0 (diff) | |
download | openshift-e61ec40b1b409c8cf61b41f9a8025dc45dd9d090.tar.gz openshift-e61ec40b1b409c8cf61b41f9a8025dc45dd9d090.tar.bz2 openshift-e61ec40b1b409c8cf61b41f9a8025dc45dd9d090.tar.xz openshift-e61ec40b1b409c8cf61b41f9a8025dc45dd9d090.zip |
Create the file in two passes, atomicly copy it over
Diffstat (limited to 'roles')
-rwxr-xr-x | roles/openshift_node_dnsmasq/files/networkmanager/99-origin-dns.sh | 14 |
1 files changed, 8 insertions, 6 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 66f2b5324..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 @@ -87,14 +88,15 @@ EOF # Only if dnsmasq is running properly make it our only nameserver if `systemctl -q is-active dnsmasq.service`; then - sed -i -e '/^nameserver.*$/d' -e 'a\nameserver '"${def_route_ip}"'\' /etc/resolv.conf - fi - - 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 + 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 |