#!/bin/sh
### setnetconf
### $Id: setnetconf,v 1.3 1993/05/29 18:39:46 mdw Exp $
### Matt Welsh <mdw@tc.cornell.edu>

# Some security
PATH=/bin:/usr/bin:/etc
IFS="	 "

# This is the netsetup directory
NET_DIR="/etc"
TMPFILE=/tmp/netconf.$$
. $NET_DIR/netf.sh

if [ "$#" != "2" ]; then
  echo "setnetconf: usage"
  echo "  getnetconf <field> <value>"
  exit 1
fi

if [ ! -f $CONF_FILE ]; then
  echo "getnetconf: cannot read $CONF_FILE."
  exit 1
fi

ORIG=`grep "^$1\W" $CONF_FILE`

if [ "$ORIG" = "" ]; then
  echo "$1 $2" >> $CONF_FILE
else
  # It's in there[tm]
  cat $CONF_FILE | sed -e "s/$ORIG/$1 $2/g" > $TMPFILE
  mv $TMPFILE $CONF_FILE
fi
