#!/bin/sh

# If pdnsd has been removed we are not supposed to do anything.

test -x /usr/sbin/pdnsd-ctl || exit 0
[ -x /sbin/resolvconf ] && exit 0

CONF=/etc/pdnsd.conf
DNS1LABEL=pppdns1
DNS2LABEL=pppdns2

if grep -q "[\t\s]*status_ctl\s*=\s*on;" $CONF; then

# USEPEERDNS, DNS1, and DNS2 are variables exported by pppd.  Do we have
# usepeerdns and a couple of nameservers?  If so, adjourn NS addresses.
    if [ "$USEPEERDNS" ] && [ "$DNS1" ]; then
	pdnsd-ctl server $DNS1LABEL up $DNS1 >/dev/null 2>&1
	if [ $? = 0 ] && [ "$DNS2" ]; then
	    pdnsd-ctl server $DNS2LABEL up $DNS2 >/dev/null 2>&1
	fi
    fi
fi

exit 0
