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


1.2
date	2001.09.11.01.43.40;	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.2
log
@Add DEBUG and VERBOSE messages.
Exit with a proper status.
Execute the change if either the IP address or netmask change
  (before it was only if the IP address changed).
@
text
@#!/bin/sh

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

if [ "$1" = "change" ]; then
  if [ "$IPADDR" = "$OLD_IPADDR" -a \
       "$NETMASK" = "$OLD_NETMASK" \
     ]; then

    if [ -n "$VERBOSE" ]; then
      echo "$0: IP address and netmask unchanged; skipping."
    fi

    exit 0
  fi
fi


case "$1" in
  up|change)

    if [ -z "${DEVICE}" -o -z "${IPADDR}" ]; then
      echo "$0: DEVICE (${DEVICE}) or IPADDR (${IPADDR}) not set!" 1>&2
      exit 1
    fi

    ifconfig_opts=""
		
    if [ -n "${NETMASK}" ]; then
      ifconfig_opts="$ifconfig_opts netmask ${NETMASK}"
    fi

    if [ -n "$VERBOSE" ]; then
      echo "$0: Running ifconfig" "${DEVICE}" "${IPADDR}" $ifconfig_opts up
    fi

    /sbin/ifconfig "${DEVICE}" "${IPADDR}" $ifconfig_opts up

    ;;

  down)

    if [ -n "$VERBOSE" ]; then
      echo "$0: Running ifconfig" "${DEVICE}" down
    fi

    /sbin/ifconfig "${DEVICE}" down
    ;;

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

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

exit 0
@


1.1
log
@Initial revision
@
text
@d3 4
d8 2
a9 2
  if [ "$IPADDR" -eq "$OLD_IPADDR" -a \
       "$NETMASK" -eq "$OLD_NETMASK" \
d11 5
d35 4
d44 5
d57 6
@
