head	1.3;
access;
symbols;
locks; strict;
comment	@# @;


1.3
date	2001.09.11.01.44.21;	author sgifford;	state Exp;
branches;
next	1.2;

1.2
date	2001.09.10.09.13.15;	author sgifford;	state Exp;
branches;
next	1.1;

1.1
date	2001.09.09.04.01.41;	author root;	state Exp;
branches;
next	;


desc
@@


1.3
log
@Added VERBOSE and DEBUG messages.
Exit with a proper status.
@
text
@#!/bin/sh

if [ -n "$DEBUG" ]; then
  echo "$0: Beginning $1"
fi

DNSFORWARDERS=/usr/local/service/dnscache/root/servers/forwarders

if [ "$1" = "change" ]; then
  if [ "$DNS" = "$OLD_DNS" ]; then
    if [ -n "$VERBOSE" ]; then
      echo "$0: DNS servers did not change, skipping..."
    fi
    exit 0
  fi
fi


case "$1" in
  change|up)
    if [ -z "${DNS}" ]; then
      rm -f "$DNSFORWARDERS"
      if [ -n "$VERBOSE" ]; then
        echo "$0: No DNS servers available; clearing out forwarders file"
      fi
    else
      :> "$DNSFORWARDERS.new"
      for i in `echo ${DNS} |sed -e 's/,/ /g'`; do
        echo $i >>"${DNSFORWARDERS}.new" 
      done
      mv "${DNSFORWARDERS}.new" "$DNSFORWARDERS"
      if [ -n "$VERBOSE" ]; then
        echo "$0: Set dnscache to use DNS servers '$DNS'"
      fi
    fi

    ;;

 down)
      rm -f "$DNSFORWARDERS"

      if [ -n "$VERBOSE" ]; then
        echo "$0: Clearing out forwarders file"
      fi

      ;;

  *)
    echo "Usage: $0 up|down" 1>&2
    exit 1
    ;;
esac

if [ -n "$VERBOSE" ]; then
  echo "$0: Restarting dnscache"
fi

svc -t /service/dnscache

if [ -n "$DEBUG" ]; then
  echo "$0: Ending $1"
fi

exit 0
@


1.2
log
@Added verbosity.
@
text
@d3 4
d33 1
a33 1
        echo "$0: Set resolver to use DNS servers '$DNS'"
d59 6
@


1.1
log
@Initial revision
@
text
@d6 4
a9 1
  if [ "$DNS" -eq "$OLD_DNS" ]; then
d19 3
d28 3
d38 4
d49 4
@
