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


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

1.2
date	2001.09.11.01.44.03;	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 comparision bug (do string comparision instead of numeric).
@
text
@#!/bin/sh

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

if [ "$1" = "change" ]; then
  if [ "$GATEWAY" = "$OLD_GATEWAY" ]; then

    if [ -n "$VERBOSE" ]; then
      echo "$0 Default gateway unchanged; skipping"
    fi

    exit 0
  fi
fi


case "$1" in
  change)

    $0 down
    $0 up

    ;;

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

    if [ -z "${GATEWAY}" ]; then
      exit 0
    fi

    for gw in `echo "${GATEWAY}" |sed -e 's/,/ /g'` ; do

      if [ -n "$VERBOSE" ]; then
        echo "$0: About to run " route add default gw "${gw}" dev "${DEVICE}"
      fi

      route add default gw "${gw}" dev "${DEVICE}"
    done

    ;;

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

    if [ -z "${OLD_GATEWAY}" ]; then
      exit 0
    fi

    for gw in `echo "${OLD_GATEWAY}" |sed -e 's/,/ /g'`; do
      if [ -n "$VERBOSE" ]; then
        echo "$0: About to run " route delete default gw "${gw}" dev "${DEVICE}"
      fi
      route delete default gw "${gw}" dev "${DEVICE}"
    done
    ;;

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

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

exit 0
@


1.2
log
@Added DEBUG and VERBOSE messages.
Exit with a proper status.
@
text
@d8 1
a8 1
  if [ "$GATEWAY" -eq "$OLD_GATEWAY" ]; then
@


1.1
log
@Initial revision
@
text
@d3 4
d9 5
d38 5
d59 3
d71 6
@
