#!/bin/sh
# ifup hook script for resolvconf
# Written by Roy Marples <roy@marples.name> under the BSD-2 license

[ -x /sbin/resolvconf ] || exit 0
case "$ADDRFAM" in
	inet|inet6) : ;;
	*) exit 0;;
esac

conf=
[ -n "$IF_DNS_DOMAIN" ] && conf="${conf}domain $IF_DNS_DOMAIN\n"
[ -n "$IF_DNS_SEARCH" ] && conf="${conf}search $IF_DNS_SEARCH\n"
[ -n "$IF_DNS_SORTLIST" ] && conf="${conf}sortlist $IF_DNS_SORTLIST\n"
[ -n "$IF_DNS_OPTIONS" ] && conf="${conf}options $IF_DNS_OPTIONS\n"
for nameserver in $IF_DNS_NAMESERVERS; do
	conf="${conf}nameserver $nameserver\n"
done
if [ -n "$conf" ]; then
	conf="# Generated by ifup for $IFACE.$ADDRFAM\n$conf"
	printf "$conf" | /sbin/resolvconf -a "$IFACE.$ADDRFAM"
fi
