Rejig our Makefile to better support NetBSD. We now talk to /var/run/resolvconf direc...
[openresolv] / resolvconf.in
index 7b1a52d5e348e9e389e7ab0c136cf372ef547bb2..dc6f335e2f025da5a08689523fc62edb6ebd41c3 100755 (executable)
 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
-argv0="$0"
+ARGV0="$0"
 
-PREFIX=
-RESOLVCONF="${PREFIX}"/etc/resolvconf
-UPDATED="${RESOLVCONF}"/update.d
-VARDIR="${RESOLVCONF}"/run
+SYSCONFDIR=@SYSCONFDIR@
+VARDIR=@VARBASE@/run/resolvconf
 IFACEDIR="${VARDIR}/interfaces"
 
 error_exit() {
@@ -39,7 +37,7 @@ error_exit() {
 
 usage() {
        cat <<-EOF
-       Usage: ${argv0##*/} [options]
+       Usage: ${ARGV0##*/} [options]
 
        Inform the system about any DNS updates.
 
@@ -149,8 +147,8 @@ if [ "${CMD}" = "l" -o "${CMD}" = "i" ]; then
        if [ -n "${ARGS}" ]; then
                LIST="${ARGS}"
                ${FORCE} || REPORT=true
-       elif [ -r "${RESOLVCONF}"/interface-order ]; then
-               LIST="$(cat "${RESOLVCONF}"/interface-order)"
+       elif [ -r "${SYSCONFDIR}"/interface-order ]; then
+               LIST="$(cat "${SYSCONFDIR}"/interface-order)"
        fi
 
        # If we don't have a list then prefer lo, tunnels, ppp
@@ -188,7 +186,7 @@ if [ "${CMD}" = "v" ]; then
        NEWSEARCH=
        NEWNS=
        NEWDOMAIN=
-       LINES="$("${argv0}" -l "${IFACE}" |
+       LINES="$("${ARGV0}" -l "${IFACE}" |
                sed -e "s/'/'\\\\''/g" -e "s/^/'/g" -e "s/$/'/g")"
        eval set -- ${LINES}
        for LINE in "$@"; do
@@ -296,12 +294,12 @@ else
        # Delete any existing information about the interface
        if [ "${CMD}" = "a" -o "${CMD}" = "d" ]; then
                cd "${IFACEDIR}"
-               for iface in ${IFACE}; do
-                       if [ "${CMD}" = "d" -a ! -e "${iface}" ]; then
+               for ARG in ${ARGS}; do
+                       if [ "${CMD}" = "d" -a ! -e "${ARG}" ]; then
                                ${FORCE} && continue
-                               error_exit "No resolv.conf for interface ${iface}"
+                               error_exit "No resolv.conf for interface ${ARG}"
                        fi
-                       rm -f "${iface}" || exit $?
+                       rm -f "${ARG}" || exit $?
                done
        fi
 fi
@@ -312,9 +310,9 @@ if [ "${CMD}" = "a" ]; then
 fi
 
 RETVAL=0
-for x in "${UPDATED}"/*; do
-       if [ -e "${x}" ]; then
-               "${x}" "${CMD}" "${IFACE}"
+for SCRIPT in "${SYSCONFDIR}"/update.d/*; do
+       if [ -e "${SCRIPT}" ]; then
+               "${SCRIPT}" "${CMD}" "${IFACE}"
                RETVAL=$((${RETVAL} + $?))
        fi
 done