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


1.3
date	2001.09.11.06.43.00;	author root;	state Exp;
branches;
next	1.2;

1.2
date	2001.09.11.01.45.08;	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
@Fix comparison bug (do string comparison instead of numeric).
Add verbosity.
@
text
@#!/bin/sh

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

RESOLV_CONF="/etc/resolv.conf"
RESOLV_DEFAULT="${RESOLV_CONF}.default"
RESOLV_DHCP="${RESOLV_CONF}.dhcp"

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

case "$1" in
  up|change)
    
    if [ -z "${DNS}" ]; then
      rm -f "$RESOLV_DHCP"
      if [ -n "$VERBOSE" ]; then
        echo "$0: No DNS servers available; using default resolv.conf"
      fi
    else
      :> "${RESOLV_DHCP}.new"
      for i in `echo "${DNS}" |sed -e 's/,/ /g'`; do
        echo "nameserver $i" >>"${RESOLV_DHCP}.new" 
      done
      mv "${RESOLV_DHCP}.new" "$RESOLV_DHCP"
      if [ -n "$VERBOSE" ]; then
        echo "$0: Set resolver to use DNS servers '$DNS'"
      fi
    fi

    ;;

 down)
      rm -f "$RESOLV_DHCP"
      if [ -n "$VERBOSE" ]; then
        echo "$0: Clearing out dynamic resolver file"
      fi

      ;;

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

if [ -n "$VERBOSE" ]; then
  echo "$0: Rebuilding resolv.conf"
fi

cat=""
if [ -f "$RESOLV_DEFAULT" ]; then
  cat="$cat $RESOLV_DEFAULT"
fi

if [ -f "$RESOLV_DHCP" ]; then
  cat="$cat $RESOLV_DHCP"
elif [ -f "$RESOLV_NODHCP" ]; then
  cat="$cat $RESOLV_NODHCP"
fi

cat $cat >"${RESOLV_CONF}.new"
mv "${RESOLV_CONF}.new" "$RESOLV_CONF"

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

exit 0
@


1.2
log
@Add VERBOSE and DEBUG messages.
Exit with a proper status.
@
text
@d12 4
a15 1
  if [ "$DNS" -eq "$OLD_DNS" ]; then
@


1.1
log
@Initial revision
@
text
@d3 4
d22 3
d31 3
d40 3
d52 4
d69 6
@
