#!/bin/sh


# Copyright (c) 2003 KONICA MINOLTA BUSINESS TECHNOLOGIES, INC. All rights reserved.


cat banner
echo
echo "Enter '?' at any time to receive help."
echo


if test ! -d BSD
then 
     echo "Please change to the CrownSoft directory before you install the software."
     exit 0
fi

#
# Prompt whether to install the SYSV, HP or BSD version.
#

DONE=no

while [ $DONE != yes ]
do
    echo "Operating System? (BSD | SYSV | HP | AIX | SGI | SOLARIS) [BSD]: "
    read REPLY
    case $REPLY in
	SYSV|sysv)
	    SYS=sysv
	    DONE=yes
	    ;;
	HP|hp|H|h)
	    SYS=hp
	    DONE=yes
	    ;;
	BSD|bsd|B|b)
	    SYS=bsd
	    DONE=yes
	    ;;
        AIX|aix|A|a)
            SYS=aix
            DONE=yes
            ;;
        SGI|sgi)
            SYS=sgi
            DONE=yes
            ;;
        Solaris|SOLARIS|solaris)
            SYS=solaris
            DONE=yes
            ;;
	\?)
	    echo "Enter the type of spooler that this system utilizes."
	    echo "A BSD system is based on Berkeley's UNIX Version 4.2BSD"
	    echo "    Examples: SunOS, Ultrix, 4.3BSD"
	    echo "A SYSV system is based on AT&T's System V."
	    echo "    Examples: SYSVR4, SCO UNIX"
	    echo "HP is for the HP-UX system."
            echo "AIX is for the IBM AIX system."
	    echo "SGI is for Silicon Graphics system."
	    echo "Solaris for Sun's Solaris Operating System."
	    echo
	    ;;
	?*)
	    echo "$REPLY is not a valid choice"
	    ;;
	*)
	    SYS=bsd
	    DONE=yes
	    ;;
    esac
done

case $SYS in
    sysv)
        DONE=no
        while [ $DONE != yes ]
        do
            echo "TCP/IP Implementation? (sockets | streams)[streams]:"
            read REPLY
            case $REPLY in
                STREAMS|streams|ST|st)
                    TCP=streams
                    DONE=yes
                    ;;
                SOCKETS|sockets|SO|so)
                    TCP=sockets
                    DONE=yes
                    ;;
                \?)
	            echo "Enter the TCP/IP implementation that this sytem uses."
	            echo "Generally, SYSV systems use streams."
	            echo "Exceptions: HP-UX is SYSV and sockets, Apollo's SYSV uses"
	            echo "sockets."
                    echo
	            ;;
                ?*)
                    echo "$REPLY is not a valid choice"
                    ;;
                *)
                    TCP=streams
                    DONE=yes
                    ;;
            esac
        done

	if [ $TCP = "sockets" ]
	then
	    cp BSD/qef* SYSV
	    cp BSD/Makefile.BSD SYSV/Makefile
	fi
	if [ $TCP = "streams" ]
	then
	    cp SYSV/Makefile.SYSV SYSV/Makefile
	fi
	SYSV/Qinstall.SYSV
	;;
    solaris)
        DONE=no
        while [ $DONE != yes ]
        do
            echo "TCP/IP Implementation? (sockets | streams)[streams]:"
            read REPLY
            case $REPLY in
                STREAMS|streams|ST|st)
                    TCP=streams
                    DONE=yes
                    ;;
                SOCKETS|sockets|SO|so)
                    TCP=sockets
                    DONE=yes
                    ;;
                \?)
	            echo "Enter the TCP/IP implementation that you wish to use."
	            echo "Solaris will allow either the sockets or streams implementation."
                    echo
	            ;;
                ?*)
                    echo "$REPLY is not a valid choice"
                    ;;
                *)
                    TCP=streams
                    DONE=yes
                    ;;
            esac
        done

	if [ $TCP = "sockets" ]
	then
	    cp BSD/qef* SYSV
	    cp BSD/Makefile.SOLARIS SYSV/Makefile
	fi
	if [ $TCP = "streams" ]
	then
	    cp SYSV/Makefile.SOLARIS SYSV/Makefile
	fi
	cp SYSV/addprt.SOLARIS SYSV/addprt
        export TCP
	SYSV/Qinstall.SYSV
	;;
    hp)
	HP/Qinstall.HP
	;;
    aix)
        AIX/Qinstall.AIX
        ;;
    sgi)

        DONE=no
        while [ $DONE != yes ]
        do
            echo "BSD or SYSV style spooler? (BSD | SYSV)[SYSV]:"
            read REPLY
            case $REPLY in
                BSD|bsd|B|b)
                    SPOOL=BSD
                    DONE=yes
                    ;;
                SYSV|sysv|S|s)
                    SPOOL=SYSV
                    DONE=yes
                    ;;
                \?)
	            echo "Enter the type of print spooler that you wish to use."
	            echo "Some SGI systems will allow either the BSD spooler or SYSV spooler"
                    echo
	            ;;
                ?*)
                    echo "$REPLY is not a valid choice"
                    ;;
                *)
                    SPOOL=SYSV
                    DONE=yes
                    ;;
            esac
        done

	if [ $SPOOL = "SYSV" ]
	then
	    	cp BSD/qef* SYSV
        	cp BSD/Makefile.SGI SYSV/Makefile 
        	SYSV/Qinstall.SYSV
		cp SYSV/addprt.SGI addprt
	fi
	if [ $SPOOL = "BSD" ]
	then
        	cp BSD/Makefile.SGI BSD/Makefile 
        	BSD/Qinstall.BSD
	fi
        ;;
    bsd|*)
        cp BSD/Makefile.BSD BSD/Makefile 
	BSD/Qinstall.BSD
	;;
esac

exit 0

