#!/bin/sh

#
# Edit the following setting of MOUNTPT to be wherever you have
# mounted the SCO Skunkware 97 CD-ROM. By default, i have set it
# to /mnt. If you mounted the SCO Skunkware 97 CD-ROM on /usr/skunk97,
# then you would set MOUNTPT=/usr/skunk97
#

MOUNTPT=/mnt

#
# ------------------------------------------------------------------
#
# In order to easily access many of the installed SCO Skunkware 97
# components, you may wish to add /usr/local/bin to your PATH and
# /usr/local/man to your MANPATH. For instance, a Bourne shell user
# could add the following to their $HOME/.profile :
# 
#         PATH=$PATH:/usr/local/bin
#         MANPATH=$MANPATH:/usr/local/man
#         export PATH MANPATH
# 
# The system administrator can set these on a system-wide basis by
# modifying the files /etc/default/login and /etc/default/man.
#
# ------------------------------------------------------------------

getyn() {
        ans=
        while [ "$ans" = "" ]
        do
                read ans
                [ "$ans" = "Y" ] || [ "$ans" = "y" ] && {
                        ans=Y
                        break
                }
                [ "$ans" = "n" ] || [ "$ans" = "N" ] && {
                        ans=N
                        break
                }
                ans=
                echo "\nPlease answer with a Y or N \c"
        done
}

OpenServer() {
echo "\nWould you like to install all of the SCO Skunkware 97 custom"
echo "installable software to your hard disk at this time ? <Y/N> \c"

getyn

if [ "$ans" = "Y" ] 
then
        while [ ! -d $MOUNTPT/osr5/inst ]
        do
            echo "\nIt appears you have the SCO Skunkware 97 CD-ROM mounted"
            echo "somewhere other than $MOUNTPT .\n"
            echo "Please enter the full absolute pathname of the CD-ROM"
            echo "mount point (e.g. /cdrom, /usr/skunk, ...) : \c"
            read MOUNTPT
        done
        custom -p SKUNK97:default -i -z $MOUNTPT/osr5/inst
else
        echo "\nYou can install one or more of the SCO Skunkware 97"
        echo "custom installable components at a later time by copying"
        echo "this file (<mount-point>/osr5/INSTALL) to your hard disk,"
        echo "and uncommenting the line or lines for the component(s)"
        echo "you wish to install. You may also need to modify the"
        echo "MOUNTPT variable (set by default to /mnt)."
        echo "After doing this, simply execute the INSTALL program (as root)."
# ------------------------------------------------------------------
#
# Uncomment the lines below which contain the packages you'd like installed
# and then run this file as root as a shell script (# sh INSTALL) or, as root,
# issue any of the following at a shell prompt :
#
# To install all of the SCO Skunkware 97 custom installable components,
# uncomment the following line.
#
#custom -p SKUNK97:default -i -z $MOUNTPT/osr5/inst
#
# To install individual components, uncomment those desired.
# Note that many of the components rely on shared libraries
# which are in the Glib package. The Glib package should always
# be installed :
#
#custom -p SKUNK97:default:Glib -i -z $MOUNTPT/osr5/inst
#
#custom -p SKUNK97:default:Gutil -i -z $MOUNTPT/osr5/inst
#custom -p SKUNK97:default:Apache -i -z $MOUNTPT/osr5/inst
#custom -p SKUNK97:default:IMGCK -i -z $MOUNTPT/osr5/inst
#custom -p SKUNK97:default:Gimp -i -z $MOUNTPT/osr5/inst
#custom -p SKUNK97:default:Xlock -i -z $MOUNTPT/osr5/inst
#custom -p SKUNK97:default:Tcl -i -z $MOUNTPT/osr5/inst
#custom -p SKUNK97:default:TclX -i -z $MOUNTPT/osr5/inst
#custom -p SKUNK97:default:TK -i -z $MOUNTPT/osr5/inst
#custom -p SKUNK97:default:Zircon -i -z $MOUNTPT/osr5/inst
#custom -p SKUNK97:default:freeWAIS -i -z $MOUNTPT/osr5/inst
#custom -p SKUNK97:default:GS -i -z $MOUNTPT/osr5/inst
#custom -p SKUNK97:default:Ghostview -i -z $MOUNTPT/osr5/inst
#custom -p SKUNK97:default:GZIP -i -z $MOUNTPT/osr5/inst
#custom -p SKUNK97:default:Lynx -i -z $MOUNTPT/osr5/inst
#custom -p SKUNK97:default:Mpeg_bits -i -z $MOUNTPT/osr5/inst
#custom -p SKUNK97:default:Mpeg_blocks -i -z $MOUNTPT/osr5/inst
#custom -p SKUNK97:default:Mpeg_encode -i -z $MOUNTPT/osr5/inst
#custom -p SKUNK97:default:Mpeg_stat -i -z $MOUNTPT/osr5/inst
#custom -p SKUNK97:default:Netpbm -i -z $MOUNTPT/osr5/inst
#custom -p SKUNK97:default:Perl5 -i -z $MOUNTPT/osr5/inst
#custom -p SKUNK97:default:XHTML -i -z $MOUNTPT/osr5/inst
#custom -p SKUNK97:default:Fvwm -i -z $MOUNTPT/osr5/inst
#custom -p SKUNK97:default:Mpeg_play -i -z $MOUNTPT/osr5/inst
#custom -p SKUNK97:default:Xanim -i -z $MOUNTPT/osr5/inst
#custom -p SKUNK97:default:Xarchie -i -z $MOUNTPT/osr5/inst
#custom -p SKUNK97:default:Xdaliclock -i -z $MOUNTPT/osr5/inst
#custom -p SKUNK97:default:XDir -i -z $MOUNTPT/osr5/inst
#custom -p SKUNK97:default:Xfig -i -z $MOUNTPT/osr5/inst
#custom -p SKUNK97:default:XFtp -i -z $MOUNTPT/osr5/inst
#custom -p SKUNK97:default:Xmcd -i -z $MOUNTPT/osr5/inst
#custom -p SKUNK97:default:Xmorph -i -z $MOUNTPT/osr5/inst
#custom -p SKUNK97:default:Xpdf -i -z $MOUNTPT/osr5/inst
#custom -p SKUNK97:default:XV -i -z $MOUNTPT/osr5/inst
#custom -p SKUNK97:default:Xsaver -i -z $MOUNTPT/osr5/inst
#custom -p SKUNK97:default:Xsnow -i -z $MOUNTPT/osr5/inst
#custom -p SKUNK97:default:XFM -i -z $MOUNTPT/osr5/inst
#custom -p SKUNK97:default:Xinvest -i -z $MOUNTPT/osr5/inst
#custom -p SKUNK97:default:Xquote -i -z $MOUNTPT/osr5/inst
#custom -p SKUNK97:default:Xsw -i -z $MOUNTPT/osr5/inst
#custom -p SKUNK97:default:Xtar -i -z $MOUNTPT/osr5/inst
#custom -p SKUNK97:default:XMmix -i -z $MOUNTPT/osr5/inst
#custom -p SKUNK97:default:Xsaver -i -z $MOUNTPT/osr5/inst
#custom -p SKUNK97:default:Xlincity -i -z $MOUNTPT/osr5/inst
#custom -p SKUNK97:default:Xgal -i -z $MOUNTPT/osr5/inst
#custom -p SKUNK97:default:Xbj -i -z $MOUNTPT/osr5/inst
#custom -p SKUNK97:default:GS -i -z $MOUNTPT/osr5/inst
#custom -p SKUNK97:default:rxvt -i -z $MOUNTPT/osr5/inst
#custom -p SKUNK97:default:xfishtank -i -z $MOUNTPT/osr5/inst
#custom -p SKUNK97:default:Xsaver -i -z $MOUNTPT/osr5/inst
fi
}

UnixWare() {
echo "\nWould you like to install all of the SCO Skunkware 97 pkgadd"
echo "installable software to your hard disk at this time ? <Y/N> \c"

getyn

while [ ! -d $MOUNTPT/uw2/Packages ]
do
        echo "\nIt appears you have the SCO Skunkware 97 CD-ROM mounted"
        echo "somewhere other than $MOUNTPT .\n"
        echo "Please enter the full absolute pathname of the CD-ROM"
        echo "mount point (e.g. /cdrom, /usr/skunk, ...) : \c"
        read MOUNTPT
done

if [ "$ans" = "Y" ] 
then
	ALL=1
        for p in $MOUNTPT/uw2/Packages/*.pkg
        do
                [ "$p" = "$MOUNTPT/uw2/Packages/Tcl8.pkg" ] && continue
                [ "$p" = "$MOUNTPT/uw2/Packages/Tk8.pkg" ] && continue
		[ "$GEM" ] && {
		    b=`basename $p`
		    [ -f $MOUNTPT/uw5/Packages/$b ] && continue
		}
                /usr/sbin/pkgadd -n -d $p all
        done
	[ "$GEM" ] || {
            echo "Installation of SCO Skunkware 97 packages complete."
            echo "In addition to these packages, Tcl 8.0b2 and Tk 8.0b2"
            echo "are also contained on the CD-ROM. To install these, run"
            echo "the commands :"
            echo "\t/usr/sbin/pkgadd -d $MOUNTPT/uw2/Packages/Tcl8.pkg"
            echo "\t/usr/sbin/pkgadd -d $MOUNTPT/uw2/Packages/Tk8.pkg"
            echo "\nThe installation of these beta versions of Tcl/Tk"
            echo "will overwrite some of the Tcl 7.6p2 and Tk 4.2p2"
            echo "header files."
	}
else
        for p in $MOUNTPT/uw2/Packages/*.pkg
        do
		[ "$GEM" ] && {
		    b=`basename $p`
		    [ -f $MOUNTPT/uw5/Packages/$b ] && continue
		}
                echo "Would you like to install $p ? <Y/N> \c"
                getyn
                [ "$ans" = "Y" ] && /usr/sbin/pkgadd -n -d $p all
        done
fi
}

Gemini() {
GEM=1
UnixWare
while [ ! -d $MOUNTPT/uw5/Packages ]
do
        echo "\nIt appears you have the SCO Skunkware 97 CD-ROM mounted"
        echo "somewhere other than $MOUNTPT .\n"
        echo "Please enter the full absolute pathname of the CD-ROM"
        echo "mount point (e.g. /cdrom, /usr/skunk, ...) : \c"
        read MOUNTPT
done

if [ "$ALL" ] 
then
        for p in $MOUNTPT/uw5/Packages/*.pkg
        do
                /usr/sbin/pkgadd -n -d $p all
        done
        echo "Installation of SCO Skunkware 97 packages complete."
else
        for p in $MOUNTPT/uw5/Packages/*.pkg
        do
                echo "Would you like to install $p ? <Y/N> \c"
                getyn
                [ "$ans" = "Y" ] && /usr/sbin/pkgadd -n -d $p all
        done
fi
}

QueryOS() {
        if [ -d /usr/sbin ]
        then
                GUESS=UnixWare
                OTHER=OpenServer
        else
                GUESS=OpenServer
                OTHER=UnixWare
        fi
        echo "I am uncertain of your operating system type."
        echo "I think it's SCO $GUESS, is this correct ? <Y/N> \c"
        getyn
        if [ "$ans" = "Y" ]
        then
                $GUESS
        else
                $OTHER
        fi
}

case `uname` in
SCO_SV) OpenServer ;;
UNIX_SV) UnixWare ;;
UnixWare) Gemini ;;
*) QueryOS ;;
esac
