home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World Komputer 1998 July & August
/
Pcwk78a98.iso
/
Wtestowe
/
Clico
/
UNIX
/
AB
/
SCO.Z
/
SCO
/
install
< prev
next >
Wrap
Text File
|
1997-03-13
|
24KB
|
1,124 lines
#!/bin/sh
#
# JSB ALPHABrowser
#
# @(#) install Version 1.12; Created 96/08/15 10:20:43
# ------------------------------------------------------------------------
# Copyright (C) JSB Computer Systems Ltd, 1996.
#
# This module contains proprietary information of JSB Computer Systems Ltd,
# and should be treated as Confidential.
##
# Common Environment Variables.
##
HOMEDIR=`pwd`
DEFAULTCENTRAL=/usr/jsbwww ## the default central directory for jsb.license
## NB #WWWDIR overrides $DEFAULTCENTRAL
CENTRAL=$DEFAULTCENTRAL ## the default central directory for install
BINDIR=/usr/bin
LFILE=.jsbweb
BRWBIN=alphabrowser
Browser=TRUE
Upgrade=FALSE
BLIST=browser.list
CLIST=common.list
InstallCFGS=FALSE
if [ -x /usr/5bin/echo ]
then
ECHO=/usr/5bin/echo
else
ECHO=echo
fi
PAGER=${PAGER:-more}
README=README
LICENSETXT=License.txt
WELCOMEHTML=Welcome.html
## make sure permissions in the central directory are OK
CHECK_PERMS=TRUE
##
## Internationalisation begins here
##
# Error Messages.
##
ERR01=" Could not find "
ERR02="failed with following error :"
ERR03="terminated\n"
ERR05=" Could not create directory "
ERR06=" Could not change permissions on directory "
ERR07=" You are installing from the wrong directory - check installation notes"
ERR08=" Missing file - "
ERR09=" Could not change ownership for "
ERR10=" Could not change group for "
ERR11=" Could not copy files "
ERR13=" Serialization terminated at user request "
ERR14=" Installation terminated at user request "
ERR15=" Could not change permissions for "
ERR16=" User refused to read the License Agreement and/or agree to its terms"
ERR18=" Invalid Activation Key "
ERR19=" Product Upgrade terminated at user request "
ERR20="Could not create license file"
ERR21="Out of memory"
ERR22="Could not decrypt license file"
ERR23="Could not write to license file"
ERR24="Could not open license file"
ERR25="Could not read from license file"
ERR26="Cannot upgrade from a Live copy to a Evaluation copy"
ERR27="Invalid serial number / Activation Key Combination"
ERR28="Could not update license file"
ERR29="License file corrupt"
ERR30="Cannot upgrade from a Evaluation copy to a Evaluation copy"
ERR31="Cannot upgrade from an Unlimited User License"
ERR32="Duplicate serial number / Activation Key Combination"
ERR33="\nInvalid directory"
ERR34="\nInvalid pathname"
ERR35="\nDirectory does not exist"
BRAND05="\nYou must run as root to install / upgrade."
LIC01="This procedure will update your JSB ALPHABrowser user license.\n\nDo you wish to continue \c"
##
# Prompts
##
PRM01="\nInstallation of JSB ALPHABrowser\n================================\n"
PRM02="\nJSB ALPHABrowser User License upgrade\n=====================================\n"
PRM03="\nDo you wish to try again \c"
PRM05="completed successfully."
PRM06="\n\nEnter serial number, or press enter for an evaluation copy,\nor q to quit ? \c"
PRM14="Checking file permissions\c"
PRM15="\nInstallation"
PRM16="\nUser License increase"
PRM17="\nThere is a readme file containing notes specific to this release.\nDo you wish to read it now \c"
PRM18="\nMoving files into place\c"
PRM19="\nHave you read the ALPHABrowser License Agreement and agree to its terms?\nEnter y if yes, n if you wish to read the file now, q to quit \c"
PRM20="\nProduct Upgrade"
PRM21="\n\nEnter Activation Key, or q to quit ? \c"
CHKYN00=Y
CHKYN01=y
CHKYN02=N
CHKYN03=n
CHKYN04=Q
CHKYN05=q
CHKYN06="(y/n)? \c"
CHKYNQ="(y/n/q)? \c"
##
## Internationalisation ends here
##
##
# UNIX Tools List
##
TOOLSLIST="/bin/cat /bin/chmod /bin/mkdir /bin/mv /bin/pwd /bin/rm \
/usr/bin/cut /bin/find /bin/cp /bin/cpio /bin/stty /bin/sed"
##
# infail() - report error and exit
##
infail()
{
if [ $Upgrade = FALSE ]
then
if [ $UpGradeProduct = FALSE ]
then
$ECHO "\n\n$PRM15 $ERR02\n"
else
$ECHO "\n\n$PRM20 $ERR02\n"
fi
else
$ECHO "\n\n$PRM16 $ERR02\n"
fi
$ECHO $1 $2
if [ $Upgrade = FALSE ]
then
if [ $UpGradeProduct = FALSE ]
then
$ECHO "$PRM15 $ERR03"
else
$ECHO "$PRM20 $ERR03"
fi
else
$ECHO "$PRM16 $ERR03"
fi
remove_licfile_copy
stty echo
exit 1
}
##
# infailtrap() - report error and exit on trap
##
infailtrap()
{
if [ $Upgrade = TRUE ]
then
infail "$ERR13"
else
if [ $UpGradeProduct = TRUE ]
then
infail "$ERR19"
else
infail "$ERR14"
fi
fi
}
##
# CopyFiles() - copy files from temp dir to installation dir
##
CopyFiles()
{
if [ $Upgrade = FALSE ]
then
$ECHO "\nCopying files to $CENTRAL \c"
mkdir $CENTRAL 2> /dev/null
if [ $Browser = TRUE ]
then
mkdir $CENTRAL/browser 2> /dev/null
fi
cp $LFILE $CENTRAL
cp licensor $CENTRAL
cp $HOMEDIR/install $CENTRAL/jsb.license
cp $CLIST $CENTRAL
cp $README $CENTRAL/$README
cp $LICENSETXT $CENTRAL/$LICENSETXT
if [ $UpGradeProduct = FALSE ]
then
############# fresh install ##########
if [ $Browser = TRUE ]
then
cd $HOMEDIR/browser
find . -print | cpio -pdu $CENTRAL/browser \
2> /dev/null || infail "$ERR11"
fi
else
########### UPGRADE ###############
if [ $Browser = TRUE ]
then
## This is to take care of the config file from an
## older version.
mv $CENTRAL/browser/alphabrowser.cfg \
$CENTRAL/browser/alphabrw.cfg >/dev/null 2>&1
cd $HOMEDIR/browser
UpgradeFiles="$WELCOMEHTML $BRWBIN $BLIST jsb_error.html"
for x in $UpgradeFiles
do
cp $x $CENTRAL/browser
done
if [ $InstallCFGS = TRUE ]
then
UpgradeFiles="alphabrw.cfg color.cfg .restrictions .usage"
for x in $UpgradeFiles
do
if [ ! -f $CENTRAL/browser/$x ]
then
cp $x $CENTRAL/browser
fi
done
fi
rm -rf $CENTRAL/browser/help >/dev/null 2>&1
mkdir $CENTRAL/browser/help >/dev/null 2>&1
cp $HOMEDIR/browser/help/* $CENTRAL/browser/help >/dev/null 2>&1
rm -rf $CENTRAL/browser/window >/dev/null 2>&1
mkdir $CENTRAL/browser/window >/dev/null 2>&1
cp $HOMEDIR/browser/window/* $CENTRAL/browser/window >/dev/null 2>&1
fi
fi
cd $HOMEDIR
fi
}
##
# MoveBin() - move files into place
##
MoveBin()
{
if [ $Upgrade = FALSE ]
then
$ECHO "\n$PRM18 \c"
if [ $Browser = TRUE ]
then
$ECHO ".\c"
mv -f $CENTRAL/browser/$BRWBIN $BINDIR || infail "$ERR11"
$ECHO ".\c"
chmod 555 $BINDIR/$BRWBIN || infail "$ERR15" $BRWBIN
$ECHO ".\c"
chown root $BINDIR/$BRWBIN || infail "$ERR15" $BRWBIN
$ECHO ".\c"
chgrp 1 $BINDIR/$BRWBIN || infail "$ERR15" $BRWBIN
$ECHO ".\c"
mv -f $CENTRAL/browser/$BLIST $CENTRAL || infail "$ERR11"
fi
fi
}
##
# chkyn() - Get yes or no answer
##
chkyn()
{
while :
do
$ECHO $CHKYN06
read reply
case $reply in
$CHKYN00*|$CHKYN01*) return 0 ;;
$CHKYN02*|$CHKYN03*) return 1 ;;
esac
done
}
##
# chkynq() - Get yes or no or quit answer
##
chkynq()
{
while :
do
$ECHO $CHKYNQ
read reply
case $reply in
$CHKYN00*|$CHKYN01*) return 0 ;;
$CHKYN02*|$CHKYN03*) return 1 ;;
$CHKYN04*|$CHKYN05*) return 2 ;;
esac
done
}
##
# start_up() - Start Up message
##
start_up()
{
UpGradeProduct=FALSE
if [ $SCRIPTNAME = "jsb.license" ]
then
Upgrade=TRUE
$ECHO $PRM02
$ECHO $LIC01
chkyn
if [ $? -eq 1 ]
then
exit 0
fi
else
Upgrade=FALSE
$ECHO $PRM01
fi
DIRNAME=`dirname $0`
if [ $DIRNAME != "." ]
then
infail "$ERR07"
fi
## we need to find the central directory
## first test for $WWWDIR environment variable
if [ -n "$WWWDIR" -a -d "$WWWDIR" ]
then
CENTRAL=$WWWDIR
else
WWWDIR=$CENTRAL
export WWWDIR
fi
if [ $Upgrade = FALSE -a ! -f "$CENTRAL/$LFILE" -a -d "$CENTRAL/browser" ]
then
infail "Install has detected a previous unlicensed installation in\n$CENTRAL"
fi
if [ -f "$CENTRAL/$LFILE" -a $Upgrade = FALSE ]
then
while [ TRUE ]
do
$ECHO "\nInstall has detected a previous installation in\n$CENTRAL"
$ECHO "\n\nChoose one of the following options;"
$ECHO "\n1. Upgrade the existing installation"
$ECHO "2. Create a new installation"
$ECHO "3. Quit"
$ECHO "\nSelect 1,2,3 or press enter for default <1> ? \c"
read REP
if [ "$REP" = "3" ]
then
infail "$ERR14"
fi
if [ "$REP" = "2" ]
then
CENTRAL=$DEFAULTCENTRAL
return
else
if [ "$REP" = "" -o "$REP" = "1" ]
then
UpGradeProduct=TRUE
cp $CENTRAL/$LFILE $HOMEDIR
return
fi
fi
done
fi
}
##
# unix_tools() - Ensure UNIX utilities are available.
##
unix_tools()
{
for tool in `$ECHO $TOOLSLIST`
do
[ -x $tool ] || infail "$ERR01" $tool
done
}
##
# SuCheck() - returns 0 if running root ( Super-user )
# 1 if not
##
SuCheck()
{
cd /tmp
TMP=ab.$$
cat /dev/null > $TMP
FIND=`find . -user 0 -name $TMP -print 2>/dev/null`
rm -f $TMP
if [ "$FIND" != ./$TMP ]
then
infail "$BRAND05"
fi
cd $HOMEDIR
}
##
# checkpermissions() - Ensure file permissions and ownerships
# file is read in on standard input and each line is set
# into the environment where
# $1 is the owner
# $2 is the group
# $3 is the permissions
# $4 is the filename
##
checkpermissions()
{
cd $CENTRAL
list=`line`
while [ -n "$list" ]
do
$ECHO ".\c"
set `$ECHO "$list`
FirstChar=`$ECHO $1 | cut -c1 `
if [ $FirstChar != "#" ] ## its a comment
then
if [ -f "$4" -o -d "$4" ]
then
chmod $3 $4 || $ECHO $PRM13 $ERR15 $4
chown $1 $4 || $ECHO $PRM13 $ERR09 $4
chgrp $2 $4 || $ECHO $PRM13 $ERR10 $4
else
$ECHO "\n$PRM13 $ERR08 $4"
fi
fi
list=`line`
done
cd $HOMEDIR
}
##
# do_links() - set file permissions
##
do_links()
{
if [ $Upgrade = FALSE ]
then
$ECHO ".\n"
if [ $CHECK_PERMS = TRUE ]
then
chmod 755 $CENTRAL
chown root $CENTRAL
chgrp 1 $CENTRAL
$ECHO "$PRM14 \c"
if [ -f $CENTRAL/$BLIST ]
then
cat $CENTRAL/$BLIST | checkpermissions
rm -f $CENTRAL/$BLIST
fi
if [ -f $CENTRAL/$CLIST ]
then
cat $CENTRAL/$CLIST | checkpermissions
rm $CENTRAL/$CLIST
fi
fi
fi
}
##
# page_license_txt() - page the License.txt file
##
page_license_txt()
{
if [ $Upgrade = FALSE ]
then
if [ -s $LICENSETXT ]
then
Finished=FALSE
while [ $Finished = FALSE ]
do
$ECHO "$PRM19" ## Have you read the ALPHABrowser License
## Agreement and agree to its terms?
chkynq ## y/n/q
REPCHKYNQ=$?
if [ `expr $REPCHKYNQ` -eq 0 ]
then
Finished=TRUE
else
if [ `expr $REPCHKYNQ` -eq 1 ]
then
cat $LICENSETXT | $PAGER ## page the License.txt file
else
infail "$ERR16"
fi
fi
done
fi
fi
}
##
# page_readme() - page the readme file if requested by user
##
page_readme()
{
if [ $Upgrade = FALSE ]
then
if [ -s $CENTRAL/$README ]
then
$ECHO "$PRM17" ## do yo want to see the readme file
chkyn ## y/n
if [ $? -eq 0 ]
then
cat $CENTRAL/$README | $PAGER ## page the readme file
fi
fi
fi
}
##
# GetLicense() - get a valid license number
##
GetLicense()
{
if [ $UpGradeProduct = FALSE ]
then
Finished=FALSE
while [ $Finished = FALSE ]
do
$ECHO $PRM06
read REP
if [ "$REP" = "$CHKYN04" -o "$REP" = "$CHKYN05" ]
then
if [ $Upgrade = TRUE ]
then
infail "$ERR13"
else
infail "$ERR14"
fi
fi
if [ -z "$REP" ]
then
BrowserIsDemo=TRUE
COMPREP=$REP
else
BrowserIsDemo=FALSE
$ECHO $PRM21
read AKREP
if [ "$AKREP" = "$CHKYN04" -o "$AKREP" = "$CHKYN05" ]
then
if [ $Upgrade = TRUE ]
then
infail "$ERR13"
else
infail "$ERR14"
fi
else
if [ -z "$AKREP" ]
then
$ECHO "$ERR18"
$ECHO "$PRM03"
chkyn
if [ $? -eq 1 ]
then
if [ $Upgrade = TRUE ]
then
infail "$ERR13"
else
infail "$ERR14"
fi
else
continue
fi
else
COMPREP=$REP$AKREP
fi
fi
fi
if [ -z "$COMPREP" -a $BrowserIsDemo = FALSE ]
then
$ECHO $ERR27
$ECHO $PRM03
chkyn
if [ $? -eq 1 ]
then
if [ $Upgrade = TRUE ]
then
infail "$ERR13"
else
infail "$ERR14"
fi
else
continue
fi
else
$HOMEDIR/licensor $COMPREP
ExitStatus=$?
if [ $ExitStatus -ne 0 ]
then
$ECHO "\nLicense failed : \c"
case $ExitStatus in
1) $ECHO "$ERR20"
;;
2) $ECHO "$ERR21"
;;
3) $ECHO "$ERR22"
;;
4) $ECHO "$ERR23"
;;
5) $ECHO "$ERR24"
;;
6) $ECHO "$ERR25"
;;
7) $ECHO "$ERR26"
;;
8) $ECHO "$ERR27"
;;
9) $ECHO "$ERR28"
;;
10) $ECHO "$ERR29"
;;
14) $ECHO "$ERR30"
;;
15) $ECHO "$ERR31"
;;
16) $ECHO "$ERR32"
;;
17) $ECHO "$ERR24"
;;
esac
$ECHO $PRM03
chkyn
if [ $? -eq 1 ]
then
if [ $Upgrade = TRUE ]
then
infail "$ERR13"
else
infail "$ERR14"
fi
fi
else
Finished=TRUE;
fi
fi
done
else
$HOMEDIR/licensor ""
ExitStatus=$?
if [ $ExitStatus -ne 0 ]
then
case $ExitStatus in
2) infail "$ERR21"
;;
3) infail "$ERR22"
;;
5) infail "$ERR24"
;;
6) infail "$ERR25"
;;
7) BrowserIsDemo=FALSE
;;
10) infail "$ERR29"
;;
14) BrowserIsDemo=TRUE
;;
15) BrowserIsDemo=FALSE
;;
esac
else
infail "$ERR29"
fi
fi
}
##
# GetDirs() - get valid set of dirs for custom install
##
GetDirs()
{
if [ $Upgrade = TRUE ]
then
return
fi
if [ $UpGradeProduct = TRUE ]
then
Op1Type="upgrade"
Op2Type="upgraded"
else
Op1Type="install"
Op2Type="installed"
fi
OK=FALSE
while [ $OK = FALSE ]
do
while [ $OK = FALSE -a $UpGradeProduct = FALSE ]
do
$ECHO "\nEnter directory in which to install product, q to quit\nor press enter for default of $CENTRAL ? \c"
read REP
if [ "$REP" = "$CHKYN04" -o "$REP" = "$CHKYN05" ]
then
infail "$ERR14"
fi
if [ -z "$REP" ]
then
REP=$CENTRAL
fi
if [ -f "$REP" ]
then
$ECHO "$ERR33"
continue
else
if [ ! -d `dirname $REP` ]
then
$ECHO "$ERR34"
continue
else
OK=TRUE
CENTRAL=$REP
fi
fi
done
OK=FALSE
while [ $OK = FALSE ]
do
$ECHO "\nEnter directory in which to $Op1Type program, q to quit\nor press enter for default of $BINDIR ? \c"
read REP
if [ "$REP" = "$CHKYN04" -o "$REP" = "$CHKYN05" ]
then
if [ $UpGradeProduct = TRUE ]
then
infail "$ERR19"
else
infail "$ERR14"
fi
fi
if [ -z "$REP" ]
then
REP=$BINDIR
fi
if [ ! -d "$REP" ]
then
$ECHO "$ERR35"
continue
else
if [ -f "$REP" ]
then
$ECHO "$ERR33"
continue
else
OK=TRUE
BINDIR=$REP
fi
fi
done
OK=FALSE
$ECHO "\nThe product will be $Op2Type as follows;"
$ECHO "\nProduct directory : $CENTRAL"
$ECHO "Program directory : $BINDIR"
$ECHO "\nContinue \c"
chkyn && OK=TRUE
done
if [ $UpGradeProduct = FALSE ]
then
if [ $CENTRAL != $DEFAULTCENTRAL ]
then
$ECHO "\n\nIMPORTANT"
$ECHO "========="
$ECHO "\nA custom installation has been selected."
$ECHO "\nMake sure that the environment variable WWWDIR is set"
$ECHO "for ALL users to $CENTRAL in the systems configuration"
$ECHO 'files (usually /etc/profile) before running the'
$ECHO "JSB ALPHABrowser."
$ECHO "\nPress enter to continue ... \c"
read REP
fi
fi
}
##
# UpgradeWarn() - Warn about things that could change because of an upgrade
##
UpgradeWarn()
{
$ECHO
}
##
# GetOptions() - get valid installation options
##
GetOptions()
{
if [ $Upgrade = TRUE ]
then
return
fi
if [ $UpGradeProduct = TRUE ]
then
Type="upgrade"
else
Type="installation"
fi
OK=FALSE
while [ $OK = FALSE ]
do
$ECHO "\n\nChoose one of the following $Type options;"
$ECHO "\n1. Default $Type"
$ECHO "2. Custom $Type"
$ECHO "3. Quit"
$ECHO "\nSelect 1,2,3 or press enter for default <1> ? \c"
read REP
if [ "$REP" = "3" ]
then
if [ $UpGradeProduct = TRUE ]
then
infail "$ERR19"
else
infail "$ERR14"
fi
fi
if [ "$REP" = "" -o "$REP" = "1" ]
then
if [ $UpGradeProduct = TRUE ]
then
UpgradeWarn
if [ $CENTRAL != $DEFAULTCENTRAL ]
then
$ECHO "\n\nAn existing custom installation has been detected"
fi
$ECHO
if [ ! -d $CENTRAL/browser -o ! -f $BINDIR/$BRWBIN ]
then
if [ ! -d $CENTRAL/browser ]
then
InstallCFGS=TRUE
fi
if [ ! -f $BINDIR/$BRWBIN -a $CENTRAL = $DEFAULTCENTRAL ]
then
$ECHO "Existing installation found to be incomplete"
$ECHO "Cannot locate the existing copy of program $BRWBIN in $BINDIR"
else
if [ ! -d $CENTRAL/browser ]
then
$ECHO "Existing installation found to be incomplete"
fi
fi
fi
if [ $CENTRAL != $DEFAULTCENTRAL ]
then
$ECHO "\n\nThe existing custom installation will be upgraded,"
$ECHO "but the program file will be installed in $BINDIR, Continue \c"
else
$ECHO "\nDefault $Type selected, Continue \c"
fi
else
$ECHO "\nDefault $Type selected, Continue \c"
fi
chkyn && OK=TRUE
else
if [ "$REP" = "2" ]
then
if [ $UpGradeProduct = TRUE ]
then
UpgradeWarn
if [ ! -d $CENTRAL/browser ]
then
$ECHO "Existing installation found to be incomplete"
fi
fi
GetDirs
OK=TRUE
fi
fi
done
}
##
# audit_trail
##
audit_trail()
{
if [ $UpGradeProduct = TRUE -o $Upgrade = TRUE ]
then
OP="upgraded"
else
OP="installed"
fi
$ECHO "\n\nThe JSB ALPHABrowser has been $OP as follows;\n"
$ECHO "ALPHABrowser : \c"
if [ $Browser = TRUE ]
then
if [ $BrowserIsDemo = TRUE ]
then
$ECHO "Evaluation copy $OP"
else
$ECHO "Live copy $OP"
fi
else
$ECHO "Not $OP"
fi
}
##
# remove_licfile_copy
##
remove_licfile_copy()
{
if [ -f $HOMEDIR/$LFILE -a $Upgrade = FALSE ]
then
rm -f $HOMEDIR/$LFILE
fi
}
##
# final_message
##
final_message()
{
if [ $Upgrade = FALSE ]
then
if [ $UpGradeProduct = FALSE ]
then
$ECHO "$PRM15 $PRM05" ## Installation successful
else
$ECHO "$PRM20 $PRM05" ## Product Upgrade successful
fi
if [ $Browser = TRUE ]
then
$ECHO "\nTo start ALPHABrowser type alphabrowser at the command prompt"
fi
else
$ECHO "$PRM16 $PRM05" ## User License increase successful
fi
$ECHO
}
##
# main()
##
##
# Catch any efforts to terminate
##
trap 'infailtrap' 1 2 4 9 15
SCRIPTNAME=`basename $0`
##
# initialisation messages
##
start_up
##
# Make sure that the user reads the License Agreement
# AND agrees to it.
##
page_license_txt
##
# check you're Super-User
##
SuCheck
##
# check that we have all the required utilities
##
unix_tools
##
# get license number from user
##
GetLicense
##
# get installation options default or custom
##
GetOptions
##
# copy files from temp dir into installation dir
##
CopyFiles
##
# move binaries etc into path
##
MoveBin
##
# check permissions of files
##
do_links
##
# Remove the unwanted copy of the License file
##
remove_licfile_copy
##
# show details of install
##
audit_trail
##
# Show the README file if the user wants to read it
##
page_readme
##
# Show final messages denoting successful operation
##
final_message
##
# Exit with a code denoting success
##
exit 0