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


1.3
date	2001.09.11.01.44.41;	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
@Add VERBOSE and DEBUG messages.
Exit with a proper status.
@
text
@#!/bin/sh

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

LOCAL_NAMESERVERS="10.0.0.100"
DHCP_CONFDIR="/usr/local/service/dhcpd/root/conf"
DHCP_DYNAMIC="${DHCP_CONFDIR}/dynamic.conf"
DHCP_NODHCP="${DHCP_CONFDIR}/nodhcp.conf"

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

case "$1" in
  up|change)
    :> "${DHCP_DYNAMIC}.new"

    if [ -n "${LOCAL_NAMESERVERS}" ]; then
      MAYBE_COMMA=","
    else
      MAYBE_COMMA=""
    fi
      
    echo "option domain-name-servers ${LOCAL_NAMESERVERS}${MAYBE_COMMA}${DNS};" >>"${DHCP_DYNAMIC}.new"

    if [ -n "$VERBOSE" ]; then
      echo "$0: Set nameservers for DHCP server to '${LOCAL_NAMESERVERS}${MAYBE_COMMA}${DNS}'"
    fi

    ;;

 down)

    if [ -f "$DHCP_NODHCP" ]; then
      cp "$DHCP_NODHCP" "${DHCP_DYNAMIC}.new"
    else
      :> "${DHCP_DYNAMIC}.new"
    fi

    if [ -n "$VERBOSE" ]; then
      echo "$0: Resetting nameservers for DHCP server"
    fi

    ;;

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


mv "${DHCP_DYNAMIC}.new" "$DHCP_DYNAMIC"

cat "${DHCP_CONFDIR}/static.conf" "${DHCP_CONFDIR}/dynamic.conf" "${DHCP_CONFDIR}/network.conf" >"${DHCP_CONFDIR}/dhcpd.conf.new"
mv "${DHCP_CONFDIR}/dhcpd.conf.new" "${DHCP_CONFDIR}/dhcpd.conf"
svc -t /service/dhcpd

if [ -n "$VERBOSE" ]; then
  echo "$0: Reconfigured DHCP server"
fi

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

exit 0
@


1.2
log
@Added verbosity.
@
text
@d3 4
d69 6
@


1.1
log
@Initial revision
@
text
@d9 4
a12 1
  if [ "$DNS" -eq "$OLD_DNS" ]; then
d29 4
d43 4
d55 1
d61 4
@
