Don't update the helpers if the resolv.conf added matches what we already have for...
[openresolv] / resolvconf.in
index e975ad4b88676d7b4f3fac180cdffe296324444a..1dc88b0a30037fb04be3a5fe796914e704c2dfd7 100755 (executable)
@@ -310,7 +310,7 @@ if [ ! -d "${IFACEDIR}" ]; then
                error_exit "Failed to create needed directory ${IFACEDIR}"
 else
        # Delete any existing information about the interface
-       if [ "${CMD}" = "a" -o "${CMD}" = "d" ]; then
+       if [ "${CMD}" = "d" ]; then
                cd "${IFACEDIR}"
                for ARG in ${ARGS}; do
                        if [ "${CMD}" = "d" -a ! -e "${ARG}" ]; then
@@ -323,8 +323,17 @@ else
 fi
 
 if [ "${CMD}" = "a" ]; then
-       # Create our resolv.conf file
-       cat >"${IFACEDIR}"/"${IFACE}" || exit $?
+       # Read resolv.conf from stdin
+       RESOLV="$(cat)"
+       # If what we are given matches what we have, then do nothing
+       if [ -e "${IFACEDIR}/${IFACE}" ]; then
+               if [ "$(printf "${RESOLV}")" = "$(cat "${IFACEDIR}/${IFACE}")" ]
+               then
+                       exit 0
+               fi
+               rm "${IFACEDIR}/${IFACE}"
+       fi
+       printf "${RESOLV}" >"${IFACEDIR}/${IFACE}" || exit $?
 fi
 
 RETVAL=0