libc updater now updates /etc/resolv.conf (or whatever it points to) and not an inter...
authorRoy Marples <roy@marples.name>
Sat, 9 Feb 2008 00:37:18 +0000 (00:37 +0000)
committerRoy Marples <roy@marples.name>
Sat, 9 Feb 2008 00:37:18 +0000 (00:37 +0000)
libc.in

diff --git a/libc.in b/libc.in
index 0f533b1444d76555a342e47fbeb3c0204354b22b..b608bf3eb607848bbd57ec5588fab1b2892a1e8b 100755 (executable)
--- a/libc.in
+++ b/libc.in
@@ -2,7 +2,9 @@
 # Copyright 2007-2008 Roy Marples
 # All rights reserved
 
-# libc subscriber for resolvconf 
+# libc subscriber for resolvconf
+# You could symlink /etc/resolv.conf to resolvconf/run/resolv.conf
+# for a read only etc, if resolvconf/run is linked to /var/run/resolvconf.
 
 # Redistribution and use in source and binary forms, with or without
 # modification, are permitted provided that the following conditions
 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
+RESOLVCONF=/etc/resolv.conf
 PREFIX=
-RESOLVCONF="${PREFIX}"/etc/resolvconf
 RESOLVCONFS="$(resolvconf -l)"
-BASE="${RESOLVCONF}/resolv.conf.d/base"
+CONFDIR="${PREFIX}"/etc/resolvconf
+BASE="${CONFDIR}/resolv.conf.d/base"
 
 uniqify() {
     local result=
@@ -106,8 +109,8 @@ done
 
 # Hold our new resolv.conf in a variable to save on temporary files
 NEWCONF="# Generated by resolvconf\n"
-[ -e "${RESOLVCONF}"/resolv.conf.d/head ] \
-       && NEWCONF="${NEWCONF}$(cat "${RESOLVCONF}"/resolv.conf.d/head)\n"
+[ -e "${CONFDIR}"/resolv.conf.d/head ] \
+       && NEWCONF="${NEWCONF}$(cat "${CONFDIR}"/resolv.conf.d/head)\n"
 [ -n "${SEARCH}" ] && NEWCONF="${NEWCONF}${SEARCH}\n"
 for N in ${NS}; do
        NEWCONF="${NEWCONF}nameserver ${N}\n"
@@ -129,22 +132,22 @@ NEWCONF="${NEWCONF}$(echo "${RESOLVCONFS}" | sed -e '/^[[:space:]]*$/d' \
        -e '/^[[:space:]]*search[[:space:]]*.*/d' \
        -e '/^[[:space:]]*domain[[:space:]]*.*/d' \
        )"
-[ -e "${RESOLVCONF}"/resolv.conf.d/tail ] \
-       && NEWCONF="${NEWCONF}$(cat "${RESOLVCONF}"/resolv.conf.d/tail)"
+[ -e "${CONFDIR}"/resolv.conf.d/tail ] \
+       && NEWCONF="${NEWCONF}$(cat "${CONFDIR}"/resolv.conf.d/tail)"
 
 # Check if the file has actually changed or not
-if [ -e "${RESOLVCONF}"/run/resolv.conf ]; then
-       [ "$(cat "${RESOLVCONF}"/run/resolv.conf)" = "$(printf "${NEWCONF}")" ] && exit 0
+if [ -e "${RESOLVCONF}" ]; then
+       [ "$(cat "${RESOLVCONF}")" = "$(printf "${NEWCONF}")" ] && exit 0
 fi
 
 # Create our resolv.conf now
-(umask 022; printf "${NEWCONF}" > "${RESOLVCONF}"/run/resolv.conf)
+(umask 022; printf "${NEWCONF}" > "${RESOLVCONF}")
 
 resolvconf -s nscd restart
 retval=$?
 
 # Notify users of the resolver
-for x in "${REVOLVCONF}"/update-libc.d/*; do
+for x in "${CONFDIR}"/update-libc.d/*; do
        if [ -e "${x}" ]; then
                "${x}" "$@"
                retval=$((${retval} + $?))