#!/sbin/sh
#@(#)HP Netstation Admin Scripts
#
# ckinstall	Check installation of netstation software 
#
if [ -r /opt/hpxt/enware2 ]
then 

cat <<EOF

It appears that some version of Netstation Software for ENVIZEX II and 
ENTRIA II netstations is installed on this system. This test will:
	Check that some files which are important to the operation
	of an ENVIZEX II netstation are present on this system.
EOF

$ECHO "Proceed with the install test [y|n] (y): $NL"
read SEL
echo ""

case $SEL in
    y|Y|yes|YES|Yes|"")
	;;
    *)
	exit 100
	;;
esac

XTHOME=/opt/hpxt/enware2/xthome
RGBFILE=$XTHOME/lib/rgb.txt
WHATFILE=$XTHOME/lib/what
XSERVERFILE=$XTHOME/bin/archive/C/Xserver

if [ -f $RGBFILE ]
then
        echo "$RGBFILE is present."
else
        echo "ERROR: $RGBFILE is NOT present."
fi

if [ -f $WHATFILE ]
then
        echo "$WHATFILE is present."
else
        echo "ERROR: $WHATFILE is NOT present."
fi

if [ -f $XSERVERFILE ]
then
        echo "$XSERVERFILE is present."
else
        echo "ERROR: $XSERVERFILE is NOT present."
fi

fi

if [ -r /usr/lib/X11/700X ]
then 
cat <<EOF

It appears that some version of ENWARE software for ENVIZEX and ENTRIA 
netstations is installed on this system. This test will:
	Check that all files necessary in order to boot an HP Netstation
	are present on this computer.

EOF

$ECHO "Proceed with the install test [y|n] (y): $NL"
read SEL
echo ""

case $SEL in
    y|Y|yes|YES|Yes|"")
	;;
    *)
	exit 100
	;;
esac

#
#               List the model numbers in each series
#               of netstations that are currently supported.
#
XTHOME=/usr/lib/X11/700X
RGBFILE=$XTHOME/rgb.txt
MODELS_700X="C2300A C2300B"
MODELS_700RX="C2700A C2703A C2707A C2708A C3225A"
MODELS_ENVIZEX="C2730A C2731A C3253A C2730ATR C2731ATR C3253ATR C3253A C2730AVG
 C2731AVG C3253AVG"
MODELS_ENTRIA="C3230A C3231A C3233A C3234A C3236A C3262A C3263A C3264A C3265A"

ALLMODELS="$MODELS_700X $MODELS_700RX $MODELS_ENVIZEX $MODELS_ENTRIA"

echo ""
if [ -f $RGBFILE ]
then
	echo "$RGBFILE is present."
else
	echo "ERROR: $RGBFILE is NOT present."
fi

cat <<EOF

*********************************************************
* Downloadables for the following netstations		*
* are present:						*
EOF
for i in $ALLMODELS
do
    if [ -f $XTHOME/bin/$i ]
    then
        echo "$MODELS_700X" | grep $i  > /dev/null 2>&1
        if [ $? -eq 0 ]
        then
            echo "*              700/X Series, model $i		*"
        fi

        echo "$MODELS_700RX" | grep $i  > /dev/null 2>&1
        if [ $? -eq 0 ]
        then
            echo "*              700/RX Series, model $i		*"
        fi

        echo "$MODELS_ENVIZEX" | grep $i  > /dev/null 2>&1
        if [ $? -eq 0 ]
        then
            echo "*              ENVIZEX Series, model $i		*"
        fi

        echo "$MODELS_ENTRIA" | grep $i  > /dev/null 2>&1
        if [ $? -eq 0 ]
        then
            echo "*              ENTRIA Series, model $i		*"
        fi
    fi
done
echo "*********************************************************"

FLAG=0
for i in $ALLMODELS
do
        if [ ! -f $XTHOME/bin/$i ]
        then
            FLAG=1
            break
        fi
done

if [ $FLAG -eq 1 ]
then
    cat <<EOF

*********************************************************
* Downloadables for the following netstations		*
* are NOT present:					*
EOF
    for i in $ALLMODELS
    do
        if [ ! -f $XTHOME/bin/$i ]
        then
            echo "$MODELS_700X" | grep $i  > /dev/null 2>&1
            if [ $? -eq 0 ]
            then
                echo "*              700/X Series, model $i		*"
            fi

            echo "$MODELS_700RX" | grep $i  > /dev/null 2>&1
            if [ $? -eq 0 ]
            then
                echo "*              700/RX Series, model $i		*"
            fi

            echo "$MODELS_ENVIZEX" | grep $i  > /dev/null 2>&1
            if [ $? -eq 0 ]
            then
                echo "*              ENVIZEX Series, model $i		*"
            fi

            echo "$MODELS_ENTRIA" | grep $i  > /dev/null 2>&1
            if [ $? -eq 0 ]
            then
                echo "*              ENTRIA Series, model $i		*"
            fi
        fi
    done
    echo "*********************************************************"
fi

cat <<EOF

*********************************************************
* Note: Look on the back of the HP Netstation base unit	*
* for the model number.					*
*********************************************************

EOF

$ECHO "Please type <Enter> to continue, or ? for help: $NL"
read SEL
if [ $SEL ]
then
    if [ $SEL = "?" ]
    then
        echo ""
        echo '  The series and models of netstations that are supported'
        echo '  depends on the downloadable files that have been installed.'
        echo "  These files are located in $XTHOME/bin."
        echo '  All models need not be supported by your system, only'
        echo '  those that correspond to the models you have or would'
        echo '  like to install.'
        echo ""
        $ECHO "Please type <Enter> to continue: $NL"
        read SEL
    fi
fi

fi
exit 100
