#!/bin/sh
#@(#)HP Station Admin Scripts
#
# whichport	 find out if printer port is serial1, serial 2 or parallel
#

while [ 0 ] 
do
  echo
  echo
  cat <<EOF

 NOTE: If you are using ENVIZEX II or ENTRIA II Stations please be sure
       that the "Remote Port Extension" is loaded.

        _________________________________________________

		Type of Connection:

	1) Serial

	2) Parallel

		?) Help		p) return to printer menu

EOF

  $ECHO "Which type of connection does your printer have? (default=2): $NL"
  read SEL
  case $SEL in
    1)
      while [ 0 ]
      do
        echo
        cat <<EOF
        _________________________________________________

                Port Reserved for Printer: 

        1) Serial 1 (or RS-232)

        2) Serial 2

                ?) Help         p) return to printer menu

EOF
       $ECHO "Which port is reserved for the printer? (default=1): $NL"
        read SEL
        case $SEL in
          1|"")
	    PERIPHPORT=9100
	    break ;;
          2)
            xtutil_can-ping $XTNAME
            if [ $? -eq 0 ]
            then
              $REMSH $XTNAME get config \
		| egrep '(^SP1)|(^Serial[ 	]*[(]1[)])'> /dev/null 2>&1
              if [ $? -eq 0 ]
              then
                $REMSH $XTNAME get config \
		  | egrep '(^SP2)|(^Serial[ 	]*[(]2[)])'> /dev/null 2>&1
                if [ $? -ne 0 ]
                then
                  cat <<EOF

Error: Unable to communicate with Serial Port 2 for this Station
Explanation: All Stations have at least one serial port (labelled Serial 1 
or RS-232). Selected ENTRIA, ENVIZEX, and ENVIZEX II models have an 
additional serial port (labelled Serial 2). This error message indicates 
that the Station you are administering has only one serial port. When 
the "Connect to Port" menu is re-displayed, select:
         1) Serial 1 (or RS-232)
EOF
	          continue 
                else
	          PERIPHPORT=9102
	          break 
                fi
              fi
            fi
            
            cat <<EOF
Error: Unable to verify the existence of Serial Port 2 on this Station.
Explanation: The Station is likely powered off and therefore not responding
to communication attempts to either serial port.
Please note: All Stations have at least one serial port (labelled Serial 1 
or RS-232). Only Selected ENTRIA, ENVIZEX, and ENVIZEX II models have an 
additional serial port (labelled Serial 2).

EOF
            $ECHO "Are you sure that this Station has a second serial port? [y|n] (y): $NL"
            read SEL
            case $SEL in
              y*|Y*|"")
                PERIPHPORT=9102
                break ;;
              *) 
                echo "" 
                echo "No changes to print spooler." 
                echo "" 
                exit 100
                ;;
            esac
	    ;;
	  p*|P*)
	    exit 100 ;;
	  \?)
	    cat <<EOF


Depending upon the model of your Station you may have one or two serial ports
available for connecting printers.

All Stations have at least one serial port (labelled Serial 1 or RS-232).
Selected ENTRIA models, ENVIZEX (p series) models, and ENVIZEX II have an 
additional serial port (labelled Serial 2).

If you are unsure whether this Station has a second serial port,
choose the default, Serial 1.

EOF
	    continue ;;
          *)
            echo ""
            echo "Invalid selection"
            continue ;;
        esac 
      done
      break
      ;;
  2|"")
    PERIPHPORT=9101
    break ;;
  p*|P*)
    exit 100 ;;
  \?)
     cat <<EOF



A serial printer connects to a serial port on the back of your Station.
All Stations have at least one serial port (labelled Serial 1 or RS-232).
Selected ENTRIA models, ENVIZEX "Series p", and ENVIZEX II base units have 
an additional serial port (labelled Serial 2).

A parallel printer connects to the port on the back of your Station 
labelled "PARALLEL".

EOF
    continue ;;
 *)
    echo ""
    echo "Invalid selection"
    continue ;;
  esac
done

echo $PERIPHPORT > $TMP/PERIPHPORT

exit 0
