#!/bin/csh -f 
#
# $Header: /tmp_mnt/ufs/pcn/carl/PCN/IF/Scripts/RCS/pcnhost.cpp,v 1.1 91/04/17 11:17:26 carl Exp $
# Copywrite (C) 1989, The Aerospace Corp
#
# calibrate <profile data>

# This shell program is used to add an entry to the 
# parameter database.
# After running the makefile
# in the test directory, run this program.
# $Header: /tmp_mnt/ufs/pcn/carl/PCN/IF/Scripts/RCS/pcnhost.cpp,v 1.1 91/04/17 11:17:26 carl Exp $

# These are set when the script is installed.
set HOSTDBASE = /usr/local/xpcn/lib/pcn_hosts
set HOSTNAME = `hostname`

if (! (-e $HOSTDBASE)) then
  echo Host database \"${HOSTDBASE}\" does not exist
  exit 1
endif

if (! (-w $HOSTDBASE)) then
  echo Cannot write to host database: $HOSTDBASE
  exit 1
endif

if (!(${#argv} == 3 || ${#argv} == 1)) then
  echo "Usage: pcnhost [-h hostname] hosttype"
  exit 1
endif

if ($1 =~ "-h") then
  set HOSTNAME = $2
  set HOSTTYPE = $3
else
  set HOSTNAME = `hostname`
  set HOSTTYPE = $1
endif

grep $HOSTTYPE $HOSTDBASE > /dev/null
if ($status != 0) then
  echo Machine type $HOSTTYPE does not exist in host database file.
  exit 1
endif

echo Adding a machine of type ${HOSTTYPE} named ${HOSTNAME} to 
echo the host dbase.
echo ""
echo -n "Ok to proceed ? "
set ok = $<

if (! ($ok =~ "y" || $ok =~ "yes")) then
  echo Host database update aborted.
  exit 1
endif

echo "+>" $HOSTNAME $HOSTTYPE >> $HOSTDBASE

echo Update completed.

