#!/bin/sh
#@(#)HP X Station Admin Scripts
#
# getxtmodel
#	1) Get series of X station and return it in $TMP/XTTYPE
#	   with a 0 exit code. 
#	2) Exit code 1 is "user didn't provide series and wants to quit".
#	3) Exit code 99 is "fatal error".
#

# Check downloadable files to see if what kinds of terminals can be supported
# Model number groups are already defined in xtadm.


FLAG_700X=0
FLAG_700RX=0
FLAG_ENVIZEX=0
FLAG_ENTRIA=0

for i in $MODELS_700X		# see if 700/X downloadables are present
do
    if [ -f $SWHOME/bin/$i ]
    then 
        FLAG_700X=1
    fi
done

for i in $MODELS_700RX		# see if 700/RX downloadables are present
do
    if [ -f $SWHOME/bin/$i ]
    then 
        FLAG_700RX=1
    fi
done

for i in $MODELS_ENVIZEX	# see if ENVIZEX downloadables are present
do
    if [ -f $SWHOME/bin/$i ]
    then 
        FLAG_ENVIZEX=1
    fi
done

for i in $MODELS_ENTRIA		# see if ENTRIA downloadables are present
do
    if [ -f $SWHOME/bin/$i ]
    then 
        FLAG_ENTRIA=1
    fi
done

if [ $FLAG_700X -eq 0 -a $FLAG_700RX -eq 0 -a $FLAG_ENVIZEX -eq 0 -a $FLAG_ENTRIA -eq 0 ]
then
    echo
    echo 'ERROR:  There are no downloadable files.  Reinstall tape.'
    echo
    exit 99
elif [ $FLAG_700X -eq 0 ]
then	#no 700/X downloadables present
    XTTYPE="700RX"
elif [ $FLAG_700RX -eq 0 -a $FLAG_ENVIZEX -eq 0 -a $FLAG_ENTRIA -eq 0 ]
then	#only 700/X downloadables present
    XTTYPE="700X"
else
    while [ 0 ] 
    do
	    cat <<EOF

		      Possible X stations

	1)   700/X
	2)   700/RX, ENVIZEX, ENTRIA

		?) Help		p) previous menu

EOF
            $ECHO "Which series of X stations are you adding (2): $NL"
            read SEL
            case $SEL in
              1)
		XTTYPE="700X"
                break
		;;
              2|"")
		XTTYPE="700RX"
                break
		;;
              p*|P*)
		exit 1
		;;
              \?)
		cat <<EOF

The X station series is required for configuration.
The identification label is on the front left of the base unit.

  700/X series:   produced from 1990 to early 1991
                  physical dimensions 17.4" x 12.5" x 4"
                                      44cm x 32cm x 10cm
  700/RX series:  produced from 1991 to late 1993
                  physical dimensions 16.5" x 15.75" x 3"
                                      42cm x 40cm x 7.6cm
  ENVIZEX series: produced from 1993 to present
                  physical dimensions 16.5" x 14.6" x 3"
                                      42cm x 37cm x 7.6cm
  ENTRIA series:  produced from early 1994 to present
                  physical dimensions 13.3" x 11.4" x 2.6"
                                      33cm x 28cm x 6.5cm

EOF
                $ECHO "Please type <Enter> to continue: $NL"
                read SEL
                ;;
              *)    ;;
            esac
    done

    echo ""
    case $XTTYPE in
	700X)
	    echo "X station series: 700/X"
	    ;;
	*)
	    echo "X station series: 700/RX, ENVIZEX, ENTRIA"
	    ;;
    esac
fi

echo $XTTYPE > $TMP/XTTYPE

exit 0
