#!/bin/sh
#
# This script writes out the machine type, equivalent to the HOSTTYPE
# environment variable of tcsh-6.
# It relies on the `hostname` command and the built-in database of 
# the host types. 
#

if [ $?HOSTTYPE ] ; then
  if [ `echo $HOSTTYPE | wc -c ` -gt 1 ] ; then echo $HOSTTYPE ; exit 0 ; fi
fi

# Add your machine name to the appropriate list:
NEXT="tamika noether avalon lattice onyx almaz NEW_MACHINE" # next
CRAY="crayc90"
CONVEX="tammy c2a NEW_MACHINE" # convex
RS6000="hermosa diamond NEW_MACHINE" # rs6000
IRIS4D="mischa liszt slsiris forbes moffitt richards cabot NEW_MACHINE" # iris4d
SUN4="tyrosine glycine histidine serine alanine proline arginine NEW_MACHINE" # sun4
DECSTATION="zuma husc NEW_MACHINE" # decstation
ALPHASTATION="venice reba NEW_MACHINE" # alpha
HP9000S700="topanga laguna yuri kei NEW_MACHINE" # hp9000s700

HOSTNAME=`hostname`

for machine in $NEXT ; do
  if [ `echo $HOSTNAME | grep -i $machine | wc -l` -gt 0 ] ; then
    echo next ; exit 0
  fi
done

for machine in $CRAY ; do
  if [ `echo $HOSTNAME | grep -i $machine | wc -l` -gt 0 ] ; then
    echo cray ; exit 0
  fi
done

for machine in $HP9000S700 ; do
  if [ `echo $HOSTNAME | grep -i $machine | wc -l` -gt 0 ] ; then
    echo hp9000s700 ; exit 0
  fi
done

for machine in $ALPHASTATION ; do
  if [ `echo $HOSTNAME | grep -i $machine | wc -l` -gt 0 ] ; then
    echo alpha ; exit 0
  fi
done

for machine in $CONVEX ; do
  if [ `echo $HOSTNAME | grep -i $machine | wc -l` -gt 0 ] ; then
    echo convex; exit 0
  fi
done

for machine in $RS6000 ; do
  if [ `echo $HOSTNAME | grep -i $machine | wc -l` -gt 0 ] ; then
    echo rs6000; exit 0
  fi
done

for machine in $IRIS4D; do
  if [ `echo $HOSTNAME | grep -i $machine | wc -l` -gt 0 ] ; then
    echo iris4d; exit 0
  fi
done

for machine in $SUN4; do
  if [ `echo $HOSTNAME | grep -i $machine | wc -l` -gt 0 ] ; then
    echo sun4; exit 0
  fi
done

for machine in $DECSTATION; do
  if [ `echo $HOSTNAME | grep -i $machine | wc -l` -gt 0 ] ; then
    echo decstation; exit 0
  fi
done
