#!/bin/sh
# install_pkg for hpux 

# Copyright (c) 2001-2004 Digi International Inc., All Rights Reserved
# 
# This software contains proprietary and confidential information of Digi
# International Inc.  By accepting transfer of this copy, Recipient agrees
# to retain this software in confidence, to prevent disclosure to others,
# and to make no use of this software other than that for which it was
# delivered.  This is an unpublished copyrighted work of Digi International
# Inc.  Except as permitted by federal law, 17 USC 117, copying is strictly
# prohibited.
# 
# Restricted Rights Legend
#
# Use, duplication, or disclosure by the Government is subject to
# restrictions set forth in sub-paragraph (c)(1)(ii) of The Rights in
# Technical Data and Computer Software clause at DFARS 252.227-7031 or
# subparagraphs (c)(1) and (2) of the Commercial Computer Software -
# Restricted Rights at 48 CFR 52.227-19, as applicable.
#
# Digi International Inc. 11001 Bren Road East, Minnetonka, MN 55343
#
# ***************************************************************************

PKG=$1
PROD=$2
SOFT=$3

## SOFT only passed in from GUI, Lynx install_pkg handles this tweak
case $SOFT in
rp)
   PROD="rp"
   ;;
dpar)
   PROD="dpar"
   ;;
*)
   ;;
esac

BASE=`basename ${PKG}`
PWD=`pwd`

echo "Working... "

#
# slashlen will be length of path if it starts with a
# slash, 0 if not
#
slashlen=`expr "$PKG" : '/.*'`
if [ $slashlen -gt 0 ]
then
        # absolute path
        PKGFILE="$PKG"
else
        # relative path
        PKGFILE=`pwd`
        PKGFILE="${PKGFILE}/$PKG"
fi


#
#  Some of the packages have a "tar" file which is rooted in "/", and
#  others assume that a relative path will be used (relative to /tmp).
#  So, we use ROOTDIR to represent the "base" path that the tar file
#  expects, and the INSTDIR to represent the directory relative to that
#  path which extraction from that "tar" file creates.
#
ROOTDIR=""
INSTDIR=""


case $PROD in
ether | scsi)
        echo "\nThe installation on this CD-ROM is done from /tmp not /usr." 
        echo "If you are prompted to be in a directory in /usr it can be ignored."
        cp -f $PKG /tmp
        cd /tmp
        (./${BASE})
        cd $PWD
        echo "Press <Enter> to continue"
        read key
        exit 0
        ;;
apcx | apepcx | apxem | apxr)
        ROOTDIR="/"
        INSTDIR="tmp/epca.pkg"
        ;;
apras)
        ROOTDIR="/"
        INSTDIR="tmp/dgdxb.pkg"
        ;;
rp)
        ROOTDIR="/tmp/"
        INSTDIR="drp.pkg"
        ;;
dpar)
        ROOTDIR="/tmp/"
        INSTDIR="digidpar.pkg"
        ;;
esac


INSTPATH="${ROOTDIR}${INSTDIR}"


if [ "x${ROOTDIR}x" = "xx" ]
then
        echo "The installation of an unrecognized package type has"
        echo "been attempted.  Package installation aborted."
        echo "Press <Enter> to continue"
        read key
        exit 1
fi


(cd ${ROOTDIR}; rm -rf ${INSTDIR}; tar xvf ${PKGFILE} 2> /dev/null)
swreg -l depot ${INSTPATH} > /dev/null
swinstall -s ${INSTPATH}
if [ $? -ne 0 ]
then
        echo "The software installation process did not complete."
        echo "Press <Enter> to continue"
        read key
        exit 1
fi

echo "Press <Enter> to continue"
read key
exit 0
