#! /bin/sh
# -*- shell-script -*-

# Shell script to be called from radns. This will call the resolvconf
# program which will merge the DNS addresses into the real
# /etc/resolv.conf.

PATH=$PATH:/usr/local/sbin
export PATH

# For debug
#echo interface: $if
#echo resolv_conf: $resolv_conf

if [ "$if" = "" ]
then
    exit 1;
fi

if [ "$resolv_conf" = "" ]
then
    if [ $verbose -gt 0 ]
    then
        echo "$0: Environment variable $resolv_conf not set. Exiting..."
    fi
    exit 1
fi

# Do nothing if $resolv_conf is not an ordinary file
if [ ! -f $resolv_conf ]
then
    if [ $verbose -gt 0 ]
    then
        echo "$0: $resolv_conf is not an ordinary file or does not exist. Exiting..."
    fi
    exit 1
fi

# resolvconf's interface directory
# (/usr/local/etc/resolvconf/run/interfaces/ on FreeBSD) needs to be
# writable by our user, by default 'radns'.

resolvconf -a $if < $resolv_conf
