Move the configuration to /etc/resolvconf.conf from individual files.
authorRoy Marples <roy@marples.name>
Mon, 16 Mar 2009 20:42:52 +0000 (20:42 +0000)
committerRoy Marples <roy@marples.name>
Mon, 16 Mar 2009 20:42:52 +0000 (20:42 +0000)
dnsmasq and named subscribers now require you to configure where they
write their config files to.
This makes for a much easier configuration.

Makefile
dnsmasq.in
libc.in
named.in
resolvconf.8.in
resolvconf.in

index eff9d56548286447b2ebf15c8cf4f0f118362d40..8b5a0d9d3e6e5a1638348326f844d53d9e9dcd32 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,5 +1,5 @@
 NAME=          openresolv
-VERSION=       2.1.1
+VERSION=       3.0
 PKG=           ${NAME}-${VERSION}
 
 INSTALL?=      install
@@ -11,12 +11,12 @@ BINMODE?=   0755
 DOCMODE?=      0644
 MANMODE?=      0444
 
-SYSCONFDIR?=   ${PREFIX}/etc/resolvconf
+SYSCONFDIR?=   ${PREFIX}/etc
 BINDIR=                ${PREFIX}/sbin
 LIBEXECDIR?=   ${PREFIX}/libexec/resolvconf
 MANDIR?=       ${MANPREFIX}/man
 
-RESOLVCONF=    resolvconf resolvconf.8
+RESOLVCONF=    resolvconf resolvconf.8 resolvconf.conf.5
 SUBSCRIBERS=   libc dnsmasq named
 TARGET=                ${RESOLVCONF} ${SUBSCRIBERS}
 
@@ -39,10 +39,14 @@ installdirs:
 install: ${TARGET}
        ${INSTALL} -d ${DESTDIR}${BINDIR}
        ${INSTALL} -m ${BINMODE} resolvconf ${DESTDIR}${BINDIR}
+       ${INSTALL} -d ${DESTDIR}${SYSCONFDIR}
+       ${INSTALL} -m ${DOCMODE} resolvconf.conf ${DESTDIR}${SYSCONFDIR}
        ${INSTALL} -d ${DESTDIR}${LIBEXECDIR}
        ${INSTALL} -m ${BINMODE} ${SUBSCRIBERS} ${DESTDIR}${LIBEXECDIR}
        ${INSTALL} -d ${DESTDIR}${MANDIR}/man8
        ${INSTALL} -m ${MANMODE} resolvconf.8 ${DESTDIR}${MANDIR}/man8
+       ${INSTALL} -d ${DESTDIR}${MANDIR}/man5
+       ${INSTALL} -m ${MANMODE} resolvconf.conf.5 ${DESTDIR}${MANDIR}/man5
 
 dist:
        ${INSTALL} -d /tmp/${PKG}
index 1104989519780edea81943cc5db9efe07da73266..bac90e1f721f51e491cdadc75ea6a6a43e26b718 100644 (file)
 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
-# A sample dnsmasq config that works as above is like so.
-# NOTE: The loopback interface on some systems maybe lo0.
-#domain-needed
-#interface=lo
-#resolv-file=@PREFIX@/etc/dnsmasq-resolv.conf
-#conf-file=@PREFIX@/etc/dnsmasq-resolvconf.conf
-
-# The last step is to configure dns configuration for /etc/resolv.conf
-# for the lo interface. You can do this in resolvconf as well by adding
-#nameserver 127.0.0.1
-# to @SYSCONFDIR@/resolv.conf.d/base
-
-# Load our variables from resolvconf
-eval "$(resolvconf -v)"
+[ -f "@SYSCONFDIR@"/resolvconf.conf ] || exit 0
+. "@SYSCONFDIR@/resolvconf.conf" || exit 1
+[ -z "${dnsmasq_conf}" -o -z "${dnsmasq_resolv}" ] && exit 0
+eval "$(${RESOLVCONF:-resolvconf} -v)"
 
 PREFIX=@PREFIX@
-DNSMASQRESOLV="${PREFIX}/etc/dnsmasq-resolv.conf"
-DNSMASQCONF="${PREFIX}/etc/dnsmasq-resolvconf.conf"
-DNSMASQPID=/var/run/dnsmasq.pid
+DNSMASQPID="${dnsmasq_pid:-/var/run/dnsmasq.pid}"
 
 NEWCONF="# Generated by resolvconf\n"
 NEWRESOLV="${NEWCONF}"
@@ -56,26 +44,28 @@ NEWRESOLV="${NEWCONF}"
 # Check for DBus support in the binary
 
 DBUS=no
-DBUSPID=/var/run/dbus/dbus.pid
+DBUSPID="${dbus_pid:-/var/run/dbus/dbus.pid}"
 [ -s "${DBUSPID}" ] || DBUSPID=/var/run/dbus.pid
 [ -s "${DBUSPID}" ] || DBUSPID=/var/run/dbus/pid
 if [ -s "${DBUSPID}" -a -s ${DNSMASQPID} ]; then
        if dnsmasq --version 2>/dev/null | \
-               grep -q "^Compile time options.*[[:space:]]DBus[[:space:]]" \
-               ; then
+               grep -q "^Compile time options.*[[:space:]]DBus[[:space:]]"
+       then
                # Sanity - check that dnsmasq and dbus are running
-               if kill -0 $(cat "${DBUSPID}") 2>/dev/null \
-                       && kill -0 $(cat ${DNSMASQPID}) 2>/dev/null; then
+               if kill -0 $(cat "${DBUSPID}") 2>/dev/null && \
+                       kill -0 $(cat ${DNSMASQPID}) 2>/dev/null
+               then
                        DBUS=yes
-                       NEWCONF="${NEWCONF}\n# Domain specific servers will be sent over dbus\nenable-dbus\n"
+                       NEWCONF="${NEWCONF}\n# Domain specific servers will"
+                       NEWCONF="${NEWCONF} be sent over dbus\nenable-dbus\n"
                fi
        fi
 fi
 
 for N in ${NAMESERVERS}; do
        case "\n${NEWRESOLV}\n" in
-               *"\nnameserver ${N}\n");;
-               *) NEWRESOLV="${NEWRESOLV}nameserver ${N}\n";;
+       *"\nnameserver ${N}\n");;
+       *) NEWRESOLV="${NEWRESOLV}nameserver ${N}\n";;
        esac
 done
 
@@ -94,7 +84,8 @@ for D in ${DOMAINS}; do
                        else
                                IFS=$OIFS
                        fi
-                       DBUSDEST="${DBUSDEST} uint32:$(printf "%u" ${NUM}) string:${DN}"
+                       DBUSDEST="${DBUSDEST} uint32:$(printf "%u" ${NUM})"
+                       DBUSDEST="${DBUSDEST} string:${DN}"
                else
                        NEWCONF="${NEWCONF}server=/${DN}/${NS%%,*}\n"
                fi
@@ -104,23 +95,23 @@ for D in ${DOMAINS}; do
 done
 
 RELOAD="no"
-if [ -e "${DNSMASQCONF}" ]; then
-       if [ "$(cat "${DNSMASQCONF}")" != "$(printf "${NEWCONF}")" ]; then
+if [ -f "${dnsmasq_conf}" ]; then
+       if [ "$(cat "${dnsmasq_conf}")" != "$(printf "${NEWCONF}")" ]; then
                RELOAD="yes"
-               printf "${NEWCONF}" > "${DNSMASQCONF}"
+               printf "${NEWCONF}" > "${dnsmasq_conf}"
        fi
 else
        RELOAD="yes"
-       printf "${NEWCONF}" > "${DNSMASQCONF}"
+       printf "${NEWCONF}" > "${dnsmasq_conf}"
 fi
-if [ -e "${DNSMASQRESOLV}" ]; then
-       if [ "$(cat "${DNSMASQRESOLV}")" != "$(printf "${NEWRESOLV}")" ]; then
+if [ -f "${dnsmasq_resolv}" ]; then
+       if [ "$(cat "${dnsmasq_resolv}")" != "$(printf "${NEWRESOLV}")" ]; then
                RELOAD="yes"
-               printf "${NEWRESOLV}" > "${DNSMASQRESOLV}"
+               printf "${NEWRESOLV}" > "${dnsmasq_resolv}"
        fi
 else
        # dnsmasq polls this file so no need to set RELOAD="yes"
-       printf "${NEWRESOLV}" > "${DNSMASQRESOLV}"
+       printf "${NEWRESOLV}" > "${dnsmasq_resolv}"
 fi
 
 [ "${RELOAD}" = "yes" ] && resolvconf -s dnsmasq restart
diff --git a/libc.in b/libc.in
index bd7e3f5a88fb14dfa1cea6268262d3ce133b9e57..aea4af211cc3d6e95817982efe68ab366ddff548 100644 (file)
--- a/libc.in
+++ b/libc.in
@@ -3,8 +3,6 @@
 # All rights reserved
 
 # 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.
 
-# Load our variables from resolvconf
-eval "$(resolvconf -v)"
+RESOLVCONF="${RESOLVCONF:-resolvconf}"
+eval "$(${RESOLVCONF} -v)"
 
-RESOLVCONF=/etc/resolv.conf
 SYSCONFDIR=@SYSCONFDIR@
 LIBEXECDIR=@LIBEXECDIR@
-BASE="${SYSCONFDIR}/resolv.conf.base"
-
-uniqify()
-{
-    local result=
-    while [ -n "$1" ]; do
-               case " ${result} " in
-               *" $1 "*);;
-               *) result="${result} $1";;
-               esac
-               shift
-       done
-    echo "${result# *}"
-}
 
 # sed may not be available, and this is faster on small files
 key_get_value()
@@ -72,33 +55,59 @@ key_get_value()
        fi
 }
 
-NEWNS=
-NEWSEARCH=
-if [ -e "${BASE}" ]; then
-       NEWNS="$(key_get_value "nameserver " "${BASE}")"
-       NEWSEARCH="$(key_get_value "search " "${BASE}")"
-       if [ -z "${NEWSEARCH}" ]; then
-               NEWSEARCH="$(key_get_value "domain " "${BASE}")"
+# Support original resolvconf configuration layout
+# as well as the openresolv config file
+if [ -f "${SYSCONFDIR}"/resolvconf.conf ]; then
+       . "${SYSCONFDIR}"/resolvconf.conf
+elif [ -d "${SYSCONFDIR}/resolvconf" ]; then
+       SYSCONFDIR="${SYSCONFDIR}/resolvconf/resolv.conf.d"
+       BASE="${SYSCONFDIR}/resolv.conf.d/base"
+       if [ -f "${BASE}" ]; then
+               name_servers="$(key_get_value "nameserver " "${BASE}")"
+               search_domains="$(key_get_value "search " "${BASE}")"
+               if [ -z "${search_domains}" ]; then
+                       search_domains="$(key_get_value "domain " "${BASE}")"
+               fi
+               resolv_conf_options="$(key_get_value "options " "${BASE}")"
+       fi
+       if [ -f "${SYSCONFDIR}"/resolv.conf.d/head ]; then
+               resolv_conf_head="$(cat "${SYSCONFDIR}"/resolv.conf.d/head)"
+       fi
+       if [ -f "${SYSCONFDIR}"/resolv.conf.d/tail ]; then
+               resolv_conf_tail="$(cat "${SYSCONFDIR}"/resolv.conf.d/tail)"
        fi
 fi
-NEWSEARCH="$(uniqify ${NEWSEARCH} ${SEARCH})"
-NEWNS="$(uniqify ${NEWNS} ${NAMESERVERS})"
+RESOLV_CONF="${resolv_conf:-/etc/resolv.conf}"
+
+uniqify()
+{
+       local result=
+       while [ -n "$1" ]; do
+               case " ${result} " in
+               *" $1 "*);;
+               *) result="${result} $1";;
+esac
+shift
+done
+echo "${result# *}"
+}
+
+NEWSEARCH="$(uniqify ${search_domains} ${SEARCH})"
+NEWNS="$(uniqify ${name_servers} ${NAMESERVERS})"
 
 # Hold our new resolv.conf in a variable to save on temporary files
 NEWCONF="# Generated by resolvconf\n"
-[ -e "${SYSCONFDIR}"/resolv.conf.head ] \
-       && NEWCONF="${NEWCONF}$(cat "${SYSCONFDIR}"/resolv.conf.head)\n"
+if [ -n "${resolv_conf_head}" ]; then
+       NEWCONF="${NEWCONF}${resolv_conf_head}\n"
+fi
 [ -n "${NEWSEARCH}" ] && NEWCONF="${NEWCONF}search ${NEWSEARCH}\n"
 for N in ${NEWNS}; do
        NEWCONF="${NEWCONF}nameserver ${N}\n"
 done
 
 # Now get any configured options
-OPTS=
-if [ -e "${BASE}" ]; then
-       OPTS="$(key_get_value "options " "${BASE}")"
-fi
-OPTS="${OPTS}${OPTS:+ }$(resolvconf -l | key_get_value "options ")"
+OPTS="${resolv_conf_options}${resolv_conf_options:+ }"
+OPTS="${OPTS}$(${RESOLVCONF} -l | key_get_value "options ")"
 if [ -n "${OPTS}" ]; then
        NEWCONF="${NEWCONF}options"
        for OPT in $(uniqify ${OPTS}); do
@@ -107,16 +116,17 @@ if [ -n "${OPTS}" ]; then
        NEWCONF="${NEWCONF}\n"
 fi
 
-[ -e "${SYSCONFDIR}"/resolv.conf.tail ] \
-       && NEWCONF="${NEWCONF}$(cat "${SYSCONFDIR}"/resolv.conf.tail)\n"
+if [ -n "{resolv_conf_tail}" ]; then
+       NEWCONF="${NEWCONF}${resolv_conf_tail}\n"
+fi
 
 # Check if the file has actually changed or not
-if [ -e "${RESOLVCONF}" ]; then
-       [ "$(cat "${RESOLVCONF}")" = "$(printf "${NEWCONF}")" ] && exit 0
+if [ -e "${RESOLV_CONF}" ]; then
+       [ "$(cat "${RESOLV_CONF}")" = "$(printf "${NEWCONF}")" ] && exit 0
 fi
 
 # Create our resolv.conf now
-(umask 022; printf "${NEWCONF}" > "${RESOLVCONF}")
+(umask 022; printf "${NEWCONF}" > "${RESOLV_CONF}")
 
 resolvconf -s nscd restart
 retval=$?
index d6bc16406900946901eb369ba9b555770e0376ad..6e9cfa0d0d5294629ee319900c9318136fc584d6 100644 (file)
--- a/named.in
+++ b/named.in
@@ -2,7 +2,7 @@
 # Copyright 2007-2009 Roy Marples <roy@marples.name>
 # All rights reserved
 
-# named updater for resolvconf
+# named subscriber for 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.
 
-# The bind config needs to be setup to include our file
-#options {
-#   include "resolvconf-options.conf";
-#};
-#include "resolvconf-zones.conf";
-
-# The last step is to configure dns configuration for /etc/resolv.conf
-#echo "nameserver 127.0.0.1" > @SYSCONFDIR@/resolv.conf.base
-
-# Load our variables from resolvconf
-eval "$(resolvconf -v)"
-
-# If our dir doesn't exist then don't do anything
-NAMEDB=/etc/namedb
-[ -d "${NAMEDB}" ] || NAMEDB="/etc/bind"
-[ -d "${NAMEDB}" ] || exit 0
-
-NAMEDOPTIONS="${NAMEDB}/resolvconf-options.conf"
-NAMEDZONES="${NAMEDB}/resolvconf-zones.conf"
+[ -f "@SYSCONFDIR@"/resolvconf.conf ] || exit 0
+. "@SYSCONFDIR@/resolvconf.conf" || exit 1
+[ -z "${named_zones}" -o -z "${named_options}" ] && exit 0
+eval "$("${RESOLVCONF:-resolvconf}" -v)"
 
 NEWOPTIONS="# Generated by resolvconf\n"
 NEWZONES="${NEWOPTIONS}"
 FORWARD=
 for N in ${NAMESERVERS}; do
        case "${FORWARD}" in
-               *"\n\t${N};"*);;
-               *) FORWARD="${FORWARD}\n\t${N};";;
+       *"\n\t${N};"*);;
+       *) FORWARD="${FORWARD}\n\t${N};";;
        esac
 done
 if [ -n "${FORWARD}" ]; then
@@ -61,7 +46,8 @@ fi
 
 for D in ${DOMAINS}; do
        NEWZONES="${NEWZONES}zone \"${D%%:*}\" {\n"
-       NEWZONES="${NEWZONES}\ttype forward;\n\tforward first;\n\tforwarders {\n"
+       NEWZONES="${NEWZONES}\ttype forward;\n"
+       NEWZONES="${NEWZONES}\tforward first;\n\tforwarders {\n"
        NS="${D#*:}"
        while [ -n "${NS}" ]; do
                NEWZONES="${NEWZONES}\t\t${NS%%,*};\n"
@@ -74,25 +60,24 @@ done
 # No point in changing files or reloading bind if the end result has not
 # changed
 RELOAD="no"
-if [ -e "${NAMEDOPTIONS}" ]; then 
-       if [ "$(cat "${NAMEDOPTIONS}")" != "$(printf "${NEWOPTIONS}")" ]; then
-               printf "${NEWOPTIONS}" > "${NAMEDOPTIONS}"
+if [ -f "${named_options}" ]; then 
+       if [ "$(cat "${named_options}")" != "$(printf "${NEWOPTIONS}")" ]; then
+               printf "${NEWOPTIONS}" > "${named_options}"
                RELOAD="yes"
        fi
 else
-       printf "${NEWOPTIONS}" > "${NAMEDOPTIONS}"
+       printf "${NEWOPTIONS}" > "${named_options}"
        RELOAD="yes"
 fi
-if [ -e "${NAMEDZONES}" ]; then
-       if [ "$(cat "${NAMEDZONES}")" != "$(printf "${NEWZONES}")" ]; then
-               printf "${NEWZONES}" > "${NAMEDZONES}"
+if [ -f "${named_zones}" ]; then
+       if [ "$(cat "${named_zones}")" != "$(printf "${NEWZONES}")" ]; then
+               printf "${NEWZONES}" > "${named_zones}"
                RELOAD="yes"
        fi
 else
-       printf "${NEWZONES}" > "${NAMEDZONES}"
+       printf "${NEWZONES}" > "${named_zones}"
        RELOAD="yes"
 fi
 
 [ "${RELOAD}" = "yes" ] && resolvconf -s named restart
-
 exit 0
index f78a5e87edfb752c6f22e6787c1cfdef49e7af99..c37f5e40c8268cc781117e100f99a87db682ded7 100644 (file)
@@ -22,7 +22,7 @@
 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 .\" SUCH DAMAGE.
 .\"
-.Dd March 14, 2009
+.Dd March 16, 2009
 .Dt RESOLVCONF 8 SMM
 .Os
 .Sh NAME
@@ -70,7 +70,7 @@ as it thinks best.
 When a local resolver other than libc is installed, such as
 .Xr dnsmasq 8
 or
-.Xr named 8
+.Xr named 8 ,
 then
 .Nm
 will supply files that the resolver should be configured to include.
@@ -79,18 +79,15 @@ will supply files that the resolver should be configured to include.
 can mark an interfaces
 .Pa resolv.conf
 as private.
-This means that the nameservers listed in that
+This means that the name servers listed in that
 .Pa resolv.conf
 are only used for queries against the domain/search listed in the same file.
-This only works when a local resolver other than libc is installed.
-Doing this, you would probably want
-.Nm
-to always configure
-.Pa /etc/resolv.conf
-with the local nameserver.
+This only works when a local resolver other than libc is installed. 
 See
-.Pa @SYSCONFDIR@/resolv.conf.base
-below on how to do this.
+.Xr resolvconf.conf 5
+for how to configure
+.Nm
+to use a local name server.
 .Pp
 When an interface goes down, it should then call
 .Nm
@@ -132,14 +129,14 @@ as private.
 .It Fl u
 Force
 .Nm
-to update all it's helpers.
+to update all it's subscribers.
 .Nm
-does not update the helpers when adding a resolv.conf that matches
+does not update the subscribers when adding a resolv.conf that matches
 what it already has for that interface.
 .El
 .Pp
 .Nm
-also has some options designed to be used by it's helpers:-
+also has some options designed to be used by it's subcribers:-
 .Bl -tag -width indent
 .It Fl s Ar service Ar command ...
 Try and send the
@@ -148,11 +145,11 @@ to the system
 .Ar service .
 Normally this is something like
 .Ar resolvconf -s named restart .
-We have this command, so the helpers don't have to know too much about the
+We have this command, so the subscribers don't have to know too much about the
 operating system on the host.
 .It Fl v
-Echo variables DOMAINS, SEARCH and NAMESERVERS so that the helper can configure
-the resolver easily.
+Echo variables DOMAINS, SEARCH and NAMESERVERS so that the subscriber can
+configure the resolver easily.
 .El
 .Sh ENVIRONMENT
 .Bl -ohang
@@ -169,43 +166,24 @@ as private.
 .El
 .Sh FILES
 .Bl -ohang
-.It Pa @SYSCONFDIR@/interface-order
-Determines the order in which nameserver information records are processed
-by resolvconf -l.
-.It Pa @SYSCONFDIR@/private-interfaces
-A list of interfaces who should be marked as private by default.
-.It Pa @SYSCONFDIR@/resolv.conf.base
-Contains basic resolver information which is included in
-.Pa /etc/resolv.conf
-even when no interfaces are configured.
-This is a good place to set libc to always use your local nameserver like so:
-.Bd -literal -offset indent
-nameserver 127.0.0.1
-.Ed
-.It Pa @SYSCONFDIR@/resolv.conf.head
-File to be prepended to
-.Pa /etc/resolv.conf .
-.It Pa @SYSCONFDIR@/resolv.conf.tail
-File to be appended to
-.Pa /etc/resolv.conf .
-.It Pa @VARBASE@/run/resolvconf
-Directory that holds the data for
+.It Pa @SYSCONFDIR@/resolvconf.conf
+Configuration file for
 .Nm .
 .It Pa @LIBEXECDIR@
-Directory of the helper scripts which are run every time
+Directory of subscribers which are run every time
 .Nm
 adds, deletes or updates.
 .It Pa @LIBEXECDIR@/libc.d
-Directory of helper scripts which are run after the libc helper script is run.
+Directory of subscribers which are run after the libc subscriber is run.
+.It Pa @VARBASE@/run/resolvconf
+State directory for
+.Nm .
 .El
 .Sh HISTORY
 This implementation of
 .Nm
 is called openresolv and is fully command line compatible with Debian's
-resolvconf, as written by Thomas Hood, on which openresolv is based.
-.Pp
-The Debian version only works with bash and other GNU userland tools, whereas
-openresolv works with a POSIX shell and userland tools.
+resolvconf, as written by Thomas Hood.
 .Sh BUGS
 .Nm
 does not validate any of the files given to it.
@@ -214,9 +192,9 @@ When running a local resolver other than libc, you will need to configure it
 to include files that
 .Nm
 will generate.
-You should consult the comment section in the helper script
-for your resolver found in @LIBEXECDIR@ for instructions
-on this.
+You should consult
+.Xr resolvconf.conf 5
+for instructions on how to configure your resolver.
 .Sh SEE ALSO
 .Xr dnsmasq 8 ,
 .Xr named 8 ,
index 6b54d1751d0baaab820a9f1e2e46962aab96c49a..88480296010e5c6497c49b533df0d35020508ca2 100644 (file)
@@ -32,6 +32,20 @@ IFACEDIR="${VARDIR}/interfaces"
 METRICDIR="${VARDIR}/metrics"
 PRIVATEDIR="${VARDIR}/private"
 
+# Support original resolvconf configuration layout
+# as well as the openresolv config file
+if [ -f "${SYSCONFDIR}"/resolvconf.conf ]; then
+       . "${SYSCONFDIR}"/resolvconf.conf
+elif [ -d "${SYSCONFDIR}/resolvconf" ]; then
+       SYSCONFDIR="${SYSCONFDIR}/resolvconf"
+       if [ -f "${SYSCONFDIR}"/interface-order ]; then
+               interface_order="$(cat "${SYSCONFDIR}"/interface-order) *"
+       fi
+fi
+if [ -n "${interface_order}" ]; then
+       interface_order="lo lo[0-9]* ${interface_order} *"
+fi
+
 error_exit()
 {
        echo "$*" >&2
@@ -142,15 +156,15 @@ parse_resolv()
 
 uniqify()
 {
-    local result=
-    while [ -n "$1" ]; do
+       local result=
+       while [ -n "$1" ]; do
                case " ${result} " in
                *" $1 "*);;
                *) result="${result} $1";;
                esac
                shift
        done
-    echo "${result# *}"
+       echo "${result# *}"
 }
 
 FORCE=false
@@ -182,7 +196,8 @@ if [ "${CMD}" = "s" ]; then
                if [ -s /var/run/"${SERVICE}".pid ]; then
                        kill -0 $(cat /var/run/"${SERVICE}".pid) 2>/dev/null
                elif [ -s /var/run/"${SERVICE}"/"${SERVICE}".pid ]; then
-                       kill -0 $(cat /var/run/"${SERVICE}"/"${SERVICE}".pid) 2>/dev/null
+                       kill -0 $(cat /var/run/"${SERVICE}"/"${SERVICE}".pid) \
+                               2>/dev/null
                elif [ -s /var/run/"${SERVICE}"/pid ]; then
                        kill -0 $(cat /var/run/"${SERVICE}"/pid) 2>/dev/null
                else
@@ -195,9 +210,11 @@ if [ "${CMD}" = "s" ]; then
                service "${SERVICE}" "${ACTION}" "$@" 
        elif [ -x /etc/init.d/"${SERVICE}" -a -x /sbin/runscript ]; then
                if [ "${ACTION}" = "restart" ]; then
-                       /etc/init.d/"${SERVICE}" --quiet --nodeps conditionalrestart "$@"
+                       /etc/init.d/"${SERVICE}" --quiet --nodeps \
+                               conditionalrestart "$@"
                else
-                       /etc/init.d/"${SERVICE}" --quiet --nodeps "${ACTION}" "$@"
+                       /etc/init.d/"${SERVICE}" --quiet --nodeps \
+                               "${ACTION}" "$@"
                fi
        elif [ -x /etc/init.d/"${SERVICE}" ]; then
                /etc/init.d/"${SERVICE}" "${ACTION}" "$@"
@@ -206,7 +223,8 @@ if [ "${CMD}" = "s" ]; then
        elif [ -x /etc/rc.d/rc."${SERVICE}" ]; then
                /etc/rc.d/rc."${SERVICE}" "${ACTION}" "$@"
        else
-               error_exit "Don't know how to interact with services on this platform"
+               error_exit "Don't know how to interact with services on" \
+                       "this platform"
        fi
        exit $?
 fi
@@ -221,8 +239,8 @@ if [ "${CMD}" = "l" -o "${CMD}" = "i" ]; then
        if [ -n "${ARGS}" ]; then
                LIST="${ARGS}"
                ${FORCE} || REPORT=true
-       elif [ -r "${SYSCONFDIR}"/interface-order ]; then
-               LIST="lo lo[0-9]* $(cat "${SYSCONFDIR}"/interface-order) *"
+       else
+               LIST="${interface_order}"
        fi
        # If we don't have a list then prefer lo, metrics, tunnels, ppp
        # and then anything else.
@@ -234,7 +252,8 @@ if [ "${CMD}" = "l" -o "${CMD}" = "i" ]; then
                                LIST="${LIST} ${METRIC#* }"
                        done
                fi
-               LIST="${LIST} tap[0-9]* tun[0-9]* vpn vpn[0-9]* ppp[0-9]* ippp[0-9]* *"
+               LIST="${LIST} tap[0-9]* tun[0-9]* vpn vpn[0-9]*"
+               LIST="${LIST} ppp[0-9]* ippp[0-9]* *"
        fi
 
        RETVAL=0
@@ -243,7 +262,8 @@ if [ "${CMD}" = "l" -o "${CMD}" = "i" ]; then
                # Only list interfaces which we really have
                if ! [ -e "${IFACE}" ]; then
                        if ${REPORT}; then
-                               echo "No resolv.conf for interface ${IFACE}" >&2
+                               echo "No resolv.conf for interface" \
+                                       "${IFACE}" >&2
                                RETVAL=$((${RETVAL} + 1))
                        fi
                        continue
@@ -267,7 +287,7 @@ if [ "${CMD}" = "v" ]; then
        for D in ${DOMAINS}; do
                DN="${D%%:*}"
                case " ${NEWDOMAINS}" in
-                       *" ${DN}:"*) continue;;
+               *" ${DN}:"*) continue;;
                esac
                DONE="${DONE} ${DN}"
                NEWDOMAINS="${NEWDOMAINS}${NEWDOMAINS:+ }${DN}:"
@@ -307,7 +327,8 @@ if [ "${CMD}" = "a" ]; then
        done
        for x in '.' '-' '~'; do
                case "${IFACE}" in
-               [${x}]*) error_exit "${x} not allowed at start of interface name";;
+               [${x}]*) error_exit \
+                       "${x} not allowed at start of interface name";;
                esac
        done
        [ "${CMD}" = "a" -a -t 0 ] && error_exit "No file given via stdin"
@@ -322,11 +343,13 @@ if [ ! -d "${IFACEDIR}" ]; then
                        # Change to /etc as link maybe relative
                        cd "${VARDIR%/*}"
                        if ! mkdir -m 0755 -p "${DIR}"; then
-                               error_exit "Failed to create needed directory ${DIR}"
+                               error_exit "Failed to create needed" \
+                                       "directory ${DIR}"
                        fi
                else
                        if ! mkdir -m 0755 -p "${VARDIR}"; then
-                               error_exit "Failed to create needed directory ${VARDIR}"
+                               error_exit "Failed to create needed" \
+                                       "directory ${VARDIR}"
                        fi
                fi
        fi
@@ -339,9 +362,11 @@ else
                for ARG in ${ARGS}; do
                        if [ "${CMD}" = "d" -a ! -e "${ARG}" ]; then
                                ${FORCE} && continue
-                               error_exit "No resolv.conf for interface ${ARG}"
+                               error_exit "No resolv.conf for" \
+                                       "interface ${ARG}"
                        fi
-                       rm -f "${ARG}" "${METRICDIR}/"*" ${ARG}" "${PRIVATEDIR}/${ARG}" || exit $?
+                       rm -f "${ARG}" "${METRICDIR}/"*" ${ARG}" \
+                               "${PRIVATEDIR}/${ARG}" || exit $?
                done
        fi
 fi
@@ -351,7 +376,8 @@ if [ "${CMD}" = "a" ]; then
        RESOLV="$(cat)\n"
        # If what we are given matches what we have, then do nothing
        if [ -e "${IFACEDIR}/${IFACE}" ]; then
-               if [ "$(printf "${RESOLV}")" = "$(cat "${IFACEDIR}/${IFACE}")" ]
+               if [ "$(printf "${RESOLV}")" = \
+                       "$(cat "${IFACEDIR}/${IFACE}")" ]
                then
                        exit 0
                fi
@@ -359,9 +385,7 @@ if [ "${CMD}" = "a" ]; then
        fi
        printf "${RESOLV}" >"${IFACEDIR}/${IFACE}" || exit $?
        rm -f "${METRICDIR}/"*" ${IFACE}"
-       if [ ! -d "${METRICDIR}" ]; then
-               mkdir "${METRICDIR}"
-       fi
+       [ ! -d "${METRICDIR}" ] && mkdir "${METRICDIR}"
        rm -f "${METRICDIR}/"*" ${IFACE}"
        # Pad metric to 6 characters, so 5 is less than 10
        # All interfaces will get a default metric of 0
@@ -378,17 +402,17 @@ if [ "${CMD}" = "a" ]; then
                [ -d "${PRIVATEDIR}" ] && echo " " >"${PRIVATEDIR}/${IFACE}"
                ;;
        *)
-               [ -e "${PRIVATEDIR}/${IFACE}" ] && rm -f "${PRIVATEDIR}/${IFACE}"
+               if [ -e "${PRIVATEDIR}/${IFACE}" ]; then
+                       rm -f "${PRIVATEDIR}/${IFACE}"
+               fi
                ;;
        esac
 fi
 
 RETVAL=0
 for SCRIPT in "${LIBEXECDIR}"/*; do
-       if [ -e "${SCRIPT}" ]; then
-               "${SCRIPT}" "${CMD}" "${IFACE}"
-               RETVAL=$((${RETVAL} + $?))
-       fi
+       [ -f "${SCRIPT}" -a -x "${SCRIPT}" ] || continue
+       RESOLVCONF="${ARGV0}" "${SCRIPT}" "${CMD}" "${IFACE}"
+       RETVAL=$((${RETVAL} + $?))
 done
-
 exit ${RETVAL}