home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 1998 July & August / Pcwk78a98.iso / Wtestowe / Clico / UNIX / AB / AIX.Z / AIX / install < prev    next >
Text File  |  1997-03-13  |  24KB  |  1,124 lines

  1. #!/bin/sh
  2. #
  3. # JSB ALPHABrowser
  4. #
  5. # @(#) install Version 1.12; Created 96/08/15 10:20:43
  6. # ------------------------------------------------------------------------
  7. # Copyright (C) JSB Computer Systems Ltd, 1996.
  8. #
  9. # This module contains proprietary information of JSB Computer Systems Ltd,
  10. # and should be treated as Confidential.
  11.  
  12.  
  13. ##
  14. #  Common Environment Variables.
  15. ##
  16. HOMEDIR=`pwd`
  17. DEFAULTCENTRAL=/usr/jsbwww ## the default central directory for jsb.license
  18.                            ## NB #WWWDIR overrides $DEFAULTCENTRAL 
  19. CENTRAL=$DEFAULTCENTRAL    ## the default central directory for install
  20. BINDIR=/usr/bin
  21. LFILE=.jsbweb
  22. BRWBIN=alphabrowser
  23. Browser=TRUE
  24. Upgrade=FALSE
  25. BLIST=browser.list
  26. CLIST=common.list
  27. InstallCFGS=FALSE
  28.  
  29. if [ -x /usr/5bin/echo ]
  30. then
  31.     ECHO=/usr/5bin/echo
  32. else
  33.     ECHO=echo
  34. fi
  35.  
  36. PAGER=${PAGER:-more}
  37. README=README
  38. LICENSETXT=License.txt
  39. WELCOMEHTML=Welcome.html
  40.  
  41. ## make sure permissions in the central directory are OK
  42. CHECK_PERMS=TRUE
  43.  
  44.  
  45. ##
  46. ## Internationalisation begins here
  47. ##
  48. #  Error Messages.
  49. ##
  50. ERR01="    Could not find "
  51. ERR02="failed with following error :"
  52. ERR03="terminated\n"
  53. ERR05="    Could not create directory "
  54. ERR06="    Could not change permissions on directory "
  55. ERR07="    You are installing from the wrong directory - check installation notes"
  56. ERR08="    Missing file - "
  57. ERR09="    Could not change ownership for  "
  58. ERR10="    Could not change group for  "
  59. ERR11="    Could not copy files "
  60. ERR13="    Serialization terminated at user request "
  61. ERR14="    Installation terminated at user request "
  62. ERR15="    Could not change permissions for "
  63. ERR16="    User refused to read the License Agreement and/or agree to its terms"
  64. ERR18="    Invalid Activation Key "
  65. ERR19="    Product Upgrade terminated at user request "
  66. ERR20="Could not create license file"
  67. ERR21="Out of memory"
  68. ERR22="Could not decrypt license file"
  69. ERR23="Could not write to license file"
  70. ERR24="Could not open license file"
  71. ERR25="Could not read from license file"
  72. ERR26="Cannot upgrade from a Live copy to a Evaluation copy"
  73. ERR27="Invalid serial number / Activation Key Combination"
  74. ERR28="Could not update license file"
  75. ERR29="License file corrupt"
  76. ERR30="Cannot upgrade from a Evaluation copy to a Evaluation copy"
  77. ERR31="Cannot upgrade from an Unlimited User License"
  78. ERR32="Duplicate serial number / Activation Key Combination"
  79. ERR33="\nInvalid directory"
  80. ERR34="\nInvalid pathname"
  81. ERR35="\nDirectory does not exist"
  82.  
  83. BRAND05="\nYou must run as root to install / upgrade."
  84.  
  85. LIC01="This procedure will update your JSB ALPHABrowser user license.\n\nDo you wish to continue \c"
  86.  
  87.  
  88. ##
  89. #  Prompts
  90. ##
  91. PRM01="\nInstallation of JSB ALPHABrowser\n================================\n"
  92. PRM02="\nJSB ALPHABrowser User License upgrade\n=====================================\n"
  93. PRM03="\nDo you wish to try again \c"
  94. PRM05="completed successfully."
  95. PRM06="\n\nEnter serial number, or press enter for an evaluation copy,\nor q to quit ? \c"
  96. PRM14="Checking file permissions\c"
  97. PRM15="\nInstallation"
  98. PRM16="\nUser License increase"
  99. PRM17="\nThere is a readme file containing notes specific to this release.\nDo you wish to read it now \c"
  100. PRM18="\nMoving files into place\c"
  101. 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"
  102. PRM20="\nProduct Upgrade"
  103. PRM21="\n\nEnter Activation Key, or q to quit ? \c"
  104.  
  105. CHKYN00=Y
  106. CHKYN01=y
  107. CHKYN02=N
  108. CHKYN03=n
  109. CHKYN04=Q
  110. CHKYN05=q
  111. CHKYN06="(y/n)? \c"
  112. CHKYNQ="(y/n/q)? \c"
  113. ##
  114. ## Internationalisation ends here
  115. ##
  116.  
  117.  
  118. ##
  119. #  UNIX Tools List
  120. ##
  121. TOOLSLIST="/bin/cat /bin/chmod /bin/mkdir /bin/mv /bin/pwd /bin/rm \
  122.            /usr/bin/cut /bin/find /bin/cp /bin/cpio /bin/stty /bin/sed"
  123.  
  124.  
  125. ##
  126. #  infail() - report error and exit
  127. ##
  128. infail()
  129. {
  130.     if [ $Upgrade = FALSE ]
  131.     then
  132.        if [ $UpGradeProduct = FALSE ]
  133.        then
  134.          $ECHO "\n\n$PRM15 $ERR02\n"
  135.        else
  136.          $ECHO "\n\n$PRM20 $ERR02\n"
  137.        fi
  138.     else
  139.         $ECHO "\n\n$PRM16 $ERR02\n"
  140.     fi
  141.  
  142.     $ECHO $1 $2
  143.  
  144.     if [ $Upgrade = FALSE ]
  145.     then
  146.        if [ $UpGradeProduct = FALSE ]
  147.        then
  148.      $ECHO "$PRM15 $ERR03"
  149.        else
  150.      $ECHO "$PRM20 $ERR03"
  151.        fi
  152.     else
  153.     $ECHO "$PRM16 $ERR03"
  154.     fi
  155.  
  156.     remove_licfile_copy
  157.  
  158.     stty echo
  159.  
  160.     exit 1
  161. }
  162.  
  163. ##
  164. #  infailtrap() - report error and exit on trap
  165. ##
  166. infailtrap()
  167. {
  168.     if [ $Upgrade = TRUE ]
  169.     then
  170.        infail "$ERR13"
  171.     else
  172.        if [ $UpGradeProduct = TRUE ]
  173.        then
  174.            infail "$ERR19"
  175.        else
  176.            infail "$ERR14"
  177.        fi
  178.     fi
  179. }
  180.  
  181. ##
  182. #  CopyFiles() - copy files from temp dir to installation dir
  183. ##
  184. CopyFiles()
  185. {
  186.     if [ $Upgrade = FALSE ]
  187.     then
  188.     $ECHO "\nCopying files to $CENTRAL \c"
  189.  
  190.         mkdir $CENTRAL 2> /dev/null
  191.  
  192.     if [ $Browser = TRUE ]
  193.     then
  194.         mkdir $CENTRAL/browser 2> /dev/null
  195.     fi
  196.  
  197.         cp $LFILE $CENTRAL
  198.         cp licensor $CENTRAL
  199.         cp $HOMEDIR/install $CENTRAL/jsb.license
  200.         cp $CLIST $CENTRAL
  201.         cp $README $CENTRAL/$README
  202.         cp $LICENSETXT $CENTRAL/$LICENSETXT
  203.  
  204.         if [ $UpGradeProduct = FALSE ]
  205.         then
  206.  
  207.             ############# fresh install ##########
  208.  
  209.             if [ $Browser = TRUE ]
  210.             then
  211.         cd $HOMEDIR/browser
  212.         find . -print | cpio -pdu $CENTRAL/browser \
  213.                    2> /dev/null || infail "$ERR11"
  214.             fi
  215.         else 
  216.  
  217.             ########### UPGRADE ###############
  218.  
  219.             if [ $Browser = TRUE ]
  220.             then 
  221.                 ## This is to take care of the config file from an
  222.                 ## older version.
  223.                 mv $CENTRAL/browser/alphabrowser.cfg \
  224.                    $CENTRAL/browser/alphabrw.cfg >/dev/null 2>&1
  225.  
  226.         cd $HOMEDIR/browser
  227.            
  228.         UpgradeFiles="$WELCOMEHTML $BRWBIN $BLIST jsb_error.html"
  229.         for x in $UpgradeFiles
  230.         do
  231.             cp $x $CENTRAL/browser
  232.         done
  233.  
  234.                 if [ $InstallCFGS = TRUE ]
  235.                 then
  236.            UpgradeFiles="alphabrw.cfg color.cfg .restrictions .usage"
  237.            for x in $UpgradeFiles
  238.            do
  239.                        if [ ! -f $CENTRAL/browser/$x ]
  240.                        then
  241.                    cp $x $CENTRAL/browser
  242.                        fi
  243.            done
  244.                 fi
  245.  
  246.                 rm -rf $CENTRAL/browser/help >/dev/null 2>&1
  247.                 mkdir $CENTRAL/browser/help >/dev/null 2>&1
  248.         cp $HOMEDIR/browser/help/* $CENTRAL/browser/help >/dev/null 2>&1
  249.  
  250.                 rm -rf $CENTRAL/browser/window >/dev/null 2>&1
  251.                 mkdir $CENTRAL/browser/window >/dev/null 2>&1
  252.         cp $HOMEDIR/browser/window/* $CENTRAL/browser/window >/dev/null 2>&1
  253.             fi
  254.         fi
  255.         cd $HOMEDIR
  256.     fi
  257. }
  258.  
  259.  
  260. ##
  261. #  MoveBin() - move files into place
  262. ##
  263. MoveBin()
  264. {
  265.     if [ $Upgrade = FALSE ]
  266.     then
  267.     $ECHO "\n$PRM18 \c"
  268.  
  269.         if [ $Browser = TRUE ]
  270.         then
  271.         $ECHO ".\c"
  272.         mv -f $CENTRAL/browser/$BRWBIN $BINDIR || infail "$ERR11"
  273.  
  274.         $ECHO ".\c"
  275.         chmod 555 $BINDIR/$BRWBIN || infail "$ERR15" $BRWBIN
  276.  
  277.         $ECHO ".\c"
  278.         chown root $BINDIR/$BRWBIN || infail "$ERR15" $BRWBIN
  279.  
  280.         $ECHO ".\c"
  281.         chgrp 1 $BINDIR/$BRWBIN || infail "$ERR15" $BRWBIN
  282.  
  283.         $ECHO ".\c"
  284.         mv -f $CENTRAL/browser/$BLIST $CENTRAL || infail "$ERR11"
  285.         fi
  286.     fi
  287. }
  288.  
  289.  
  290. ##
  291. #  chkyn() - Get yes or no answer
  292. ##
  293. chkyn()
  294. {
  295.    while :
  296.    do
  297.       $ECHO $CHKYN06
  298.       read reply 
  299.  
  300.       case $reply in
  301.     $CHKYN00*|$CHKYN01*)    return 0    ;;
  302.     $CHKYN02*|$CHKYN03*)    return 1    ;;
  303.       esac
  304.    done
  305. }
  306.  
  307.  
  308. ##
  309. #  chkynq() - Get yes or no or quit answer
  310. ##
  311. chkynq()
  312. {
  313.    while :
  314.    do
  315.       $ECHO $CHKYNQ
  316.       read reply 
  317.  
  318.       case $reply in
  319.     $CHKYN00*|$CHKYN01*)    return 0    ;;
  320.     $CHKYN02*|$CHKYN03*)    return 1    ;;
  321.     $CHKYN04*|$CHKYN05*)    return 2    ;;
  322.       esac
  323.    done
  324. }
  325.  
  326.  
  327. ##
  328. #  start_up() - Start Up message 
  329. ##
  330. start_up()
  331. {
  332.    UpGradeProduct=FALSE
  333.  
  334.    if [ $SCRIPTNAME = "jsb.license" ]
  335.    then                                    
  336.        Upgrade=TRUE
  337.        $ECHO $PRM02
  338.        $ECHO $LIC01
  339.        chkyn
  340.        if [ $? -eq 1 ]
  341.        then
  342.          exit 0
  343.        fi
  344.    else
  345.        Upgrade=FALSE
  346.        $ECHO $PRM01
  347.    fi
  348.  
  349.    DIRNAME=`dirname $0`
  350.  
  351.    if [ $DIRNAME != "." ]
  352.    then
  353.        infail "$ERR07"
  354.    fi
  355.  
  356.    ## we need to find the central directory
  357.    ## first test for $WWWDIR environment variable
  358.  
  359.    if [ -n "$WWWDIR"  -a -d "$WWWDIR" ]
  360.    then
  361.        CENTRAL=$WWWDIR
  362.    else
  363.        WWWDIR=$CENTRAL
  364.        export WWWDIR
  365.    fi
  366.  
  367.    if [ $Upgrade = FALSE -a ! -f "$CENTRAL/$LFILE" -a -d "$CENTRAL/browser" ]
  368.    then
  369.       infail "Install has detected a previous unlicensed installation in\n$CENTRAL"
  370.    fi
  371.  
  372.    if [ -f "$CENTRAL/$LFILE" -a $Upgrade = FALSE ]
  373.    then
  374.        while [ TRUE ]
  375.        do
  376.        $ECHO "\nInstall has detected a previous installation in\n$CENTRAL"
  377.            $ECHO "\n\nChoose one of the following options;"
  378.        $ECHO "\n1. Upgrade the existing installation"
  379.            $ECHO "2. Create a new installation"
  380.            $ECHO "3. Quit"
  381.  
  382.        $ECHO "\nSelect 1,2,3 or press enter for default <1> ? \c"
  383.  
  384.        read REP
  385.  
  386.            if [ "$REP" = "3" ]
  387.            then
  388.                infail "$ERR14"
  389.            fi
  390.  
  391.        if [ "$REP" = "2" ]
  392.        then
  393.                CENTRAL=$DEFAULTCENTRAL 
  394.            return
  395.        else
  396.            if [ "$REP" = "" -o "$REP" = "1" ]
  397.            then
  398.            UpGradeProduct=TRUE
  399.            cp $CENTRAL/$LFILE $HOMEDIR
  400.            return
  401.            fi
  402.        fi
  403.        done
  404.    fi
  405. }
  406.  
  407.  
  408. ##
  409. #  unix_tools() - Ensure UNIX utilities are available.
  410. ##
  411. unix_tools()
  412. {
  413.     for tool in `$ECHO $TOOLSLIST`
  414.     do
  415.     [ -x $tool ] || infail "$ERR01" $tool
  416.     done
  417. }
  418.  
  419.  
  420. ##
  421. #  SuCheck() - returns 0 if running root ( Super-user )
  422. #                              1 if not
  423. ##
  424. SuCheck()
  425. {
  426.    cd /tmp
  427.    TMP=ab.$$
  428.    cat /dev/null > $TMP
  429.    FIND=`find . -user 0 -name $TMP -print 2>/dev/null`
  430.    rm -f $TMP
  431.    if [ "$FIND" != ./$TMP ]
  432.    then
  433.       infail "$BRAND05"
  434.    fi
  435.    cd $HOMEDIR
  436. }
  437.  
  438.  
  439.  
  440. ##
  441. #  checkpermissions() - Ensure file permissions and ownerships
  442. #  file is read in on standard input  and each line is set 
  443. #  into the environment where 
  444. #  $1 is the owner 
  445. #  $2 is the group 
  446. #  $3 is the permissions 
  447. #  $4 is the filename 
  448. ##
  449. checkpermissions()
  450. {
  451.    cd $CENTRAL
  452.    list=`line`
  453.    while [ -n "$list" ]
  454.    do
  455.       $ECHO ".\c"
  456.       set `$ECHO "$list`
  457.       FirstChar=`$ECHO $1 | cut -c1 `
  458.       if [ $FirstChar != "#" ]   ## its a comment
  459.       then
  460.          if [ -f "$4" -o -d "$4" ]
  461.          then
  462.             chmod $3 $4 || $ECHO $PRM13 $ERR15 $4
  463.             chown $1 $4 || $ECHO $PRM13 $ERR09 $4
  464.             chgrp $2 $4 || $ECHO $PRM13 $ERR10 $4
  465.          else
  466.             $ECHO "\n$PRM13 $ERR08 $4"
  467.          fi
  468.       fi
  469.       list=`line`
  470.    done
  471.    cd $HOMEDIR
  472. }
  473.  
  474.  
  475. ##
  476. #  do_links() - set file permissions 
  477. ##
  478. do_links()
  479. {
  480.    if [ $Upgrade = FALSE ]
  481.    then
  482.      $ECHO ".\n"
  483.    
  484.      if [ $CHECK_PERMS  = TRUE ]
  485.      then
  486.        chmod 755 $CENTRAL
  487.        chown root $CENTRAL
  488.        chgrp 1 $CENTRAL
  489.  
  490.        $ECHO "$PRM14 \c"
  491.  
  492.        if [ -f $CENTRAL/$BLIST ]
  493.        then
  494.           cat $CENTRAL/$BLIST | checkpermissions 
  495.           rm -f $CENTRAL/$BLIST
  496.        fi
  497.  
  498.        if [ -f $CENTRAL/$CLIST ]
  499.        then
  500.           cat $CENTRAL/$CLIST | checkpermissions 
  501.           rm $CENTRAL/$CLIST
  502.        fi
  503.      fi
  504.    fi
  505. }
  506.  
  507.  
  508. ##
  509. #  page_license_txt() - page the License.txt file
  510. ##
  511. page_license_txt()
  512. {
  513.    if [ $Upgrade = FALSE ]
  514.    then
  515.       if [ -s $LICENSETXT ]
  516.       then
  517.          Finished=FALSE
  518.          while [ $Finished = FALSE ]
  519.          do
  520.             $ECHO "$PRM19"   ## Have you read the ALPHABrowser License 
  521.                              ## Agreement and agree to its terms?
  522.             chkynq           ## y/n/q
  523.             REPCHKYNQ=$?
  524.  
  525.             if [ `expr $REPCHKYNQ` -eq 0 ]
  526.             then
  527.               Finished=TRUE
  528.             else
  529.                if [ `expr $REPCHKYNQ` -eq 1 ]
  530.                then
  531.                   cat $LICENSETXT | $PAGER  ## page the License.txt file
  532.                else
  533.                   infail "$ERR16"
  534.                fi
  535.             fi
  536.          done
  537.       fi
  538.    fi
  539. }
  540.  
  541.  
  542. ##
  543. #  page_readme() - page the readme file if requested by user
  544. ##
  545. page_readme()
  546. {
  547.    if [ $Upgrade = FALSE ]
  548.    then
  549.      if [ -s $CENTRAL/$README ]
  550.      then
  551.         $ECHO "$PRM17"   ## do yo want to see the readme file
  552.         chkyn            ## y/n
  553.         if [ $? -eq 0 ]
  554.         then
  555.           cat $CENTRAL/$README | $PAGER  ## page the readme file
  556.         fi
  557.      fi
  558.    fi
  559. }
  560.  
  561.  
  562. ##
  563. # GetLicense() - get a valid license number
  564. ##
  565. GetLicense()
  566. {
  567.     if [ $UpGradeProduct = FALSE ]
  568.     then
  569.         Finished=FALSE
  570.         while [ $Finished = FALSE ]
  571.         do
  572.             $ECHO $PRM06 
  573.             read REP
  574.     
  575.             if [ "$REP" = "$CHKYN04" -o "$REP" = "$CHKYN05" ]
  576.             then
  577.                 if [ $Upgrade = TRUE ]
  578.                 then
  579.                     infail "$ERR13"
  580.                 else
  581.                     infail "$ERR14"
  582.                 fi
  583.             fi
  584.     
  585.             if [ -z "$REP" ]
  586.             then
  587.                 BrowserIsDemo=TRUE
  588.     
  589.                 COMPREP=$REP
  590.             else
  591.                 BrowserIsDemo=FALSE
  592.         
  593.                 $ECHO $PRM21 
  594.             read AKREP
  595.         
  596.                 if [ "$AKREP" = "$CHKYN04" -o "$AKREP" = "$CHKYN05" ]
  597.                 then
  598.                     if [ $Upgrade = TRUE ]
  599.                     then
  600.                         infail "$ERR13"
  601.                     else
  602.                         infail "$ERR14"
  603.                     fi
  604.                 else
  605.                     if [ -z "$AKREP" ]
  606.                     then
  607.                        $ECHO  "$ERR18"
  608.                        $ECHO  "$PRM03"
  609.                        chkyn
  610.                        if [ $? -eq 1 ]
  611.                        then
  612.                            if [ $Upgrade = TRUE ]
  613.                            then
  614.                                infail "$ERR13"
  615.                            else
  616.                                infail "$ERR14"
  617.                            fi
  618.                        else
  619.                            continue
  620.                        fi
  621.                     else
  622.                        COMPREP=$REP$AKREP
  623.                     fi
  624.                 fi
  625.             fi
  626.     
  627.             if [ -z "$COMPREP" -a $BrowserIsDemo = FALSE ]
  628.             then
  629.                $ECHO $ERR27
  630.                $ECHO $PRM03
  631.                chkyn
  632.                if [ $? -eq 1 ]
  633.                then
  634.                    if [ $Upgrade = TRUE ]
  635.                    then
  636.                        infail "$ERR13"
  637.                    else
  638.                        infail "$ERR14"
  639.                    fi
  640.                else
  641.                    continue
  642.                fi
  643.             else
  644.                $HOMEDIR/licensor $COMPREP
  645.                ExitStatus=$?
  646.                if [ $ExitStatus -ne 0 ]
  647.                then
  648.                    $ECHO "\nLicense failed : \c"
  649.     
  650.                    case $ExitStatus in
  651.                    1) $ECHO "$ERR20"
  652.                       ;;
  653.     
  654.                    2) $ECHO "$ERR21"
  655.                       ;;
  656.     
  657.                    3) $ECHO "$ERR22"
  658.                       ;;
  659.     
  660.                    4) $ECHO "$ERR23"
  661.                       ;;
  662.     
  663.                    5) $ECHO "$ERR24"
  664.                       ;;
  665.     
  666.                    6) $ECHO "$ERR25"
  667.                       ;;
  668.     
  669.                    7) $ECHO "$ERR26"
  670.                       ;;
  671.     
  672.                    8) $ECHO "$ERR27"
  673.                       ;;
  674.     
  675.                    9) $ECHO "$ERR28"
  676.                       ;;
  677.     
  678.                    10) $ECHO "$ERR29"
  679.                       ;;
  680.     
  681.                    14) $ECHO "$ERR30"
  682.                       ;;
  683.     
  684.                    15) $ECHO "$ERR31"
  685.                       ;;
  686.     
  687.                    16) $ECHO "$ERR32"
  688.                       ;;
  689.  
  690.                    17) $ECHO "$ERR24"
  691.                       ;;
  692.                    esac
  693.        
  694.                    $ECHO $PRM03
  695.                    chkyn
  696.                    if [ $? -eq 1 ]
  697.                    then
  698.                        if [ $Upgrade = TRUE ]
  699.                        then
  700.                            infail "$ERR13"
  701.                        else
  702.                            infail "$ERR14"
  703.                        fi
  704.                    fi
  705.                else
  706.                    Finished=TRUE;
  707.                fi
  708.             fi
  709.         done
  710.     else
  711.         $HOMEDIR/licensor ""
  712.         ExitStatus=$?
  713.         if [ $ExitStatus -ne 0 ]
  714.         then
  715.             case $ExitStatus in
  716.             2) infail "$ERR21"
  717.                ;;
  718.     
  719.             3) infail "$ERR22"
  720.                ;;
  721.     
  722.             5) infail "$ERR24"
  723.                ;;
  724.     
  725.             6) infail "$ERR25"
  726.                ;;
  727.     
  728.             7) BrowserIsDemo=FALSE
  729.                ;;
  730.     
  731.             10) infail "$ERR29"
  732.                 ;;
  733.     
  734.             14) BrowserIsDemo=TRUE
  735.                 ;;
  736.     
  737.             15) BrowserIsDemo=FALSE
  738.                 ;;
  739.             esac
  740.         else
  741.             infail "$ERR29"
  742.         fi
  743.     fi
  744. }
  745.  
  746.  
  747. ##
  748. #  GetDirs() - get valid set of dirs for custom install
  749. ##
  750. GetDirs()
  751. {
  752.     if [ $Upgrade = TRUE ]
  753.     then
  754.     return
  755.     fi
  756.  
  757.     if [ $UpGradeProduct = TRUE ]
  758.     then
  759.         Op1Type="upgrade"
  760.         Op2Type="upgraded"
  761.     else
  762.         Op1Type="install"
  763.         Op2Type="installed"
  764.     fi
  765.  
  766.     OK=FALSE
  767.     while [ $OK = FALSE ]
  768.     do
  769.     while [ $OK = FALSE -a $UpGradeProduct = FALSE ]
  770.     do
  771.         $ECHO "\nEnter directory in which to install product, q to quit\nor press enter for default of $CENTRAL ? \c"
  772.         read REP
  773.  
  774.         if [ "$REP" = "$CHKYN04" -o "$REP" = "$CHKYN05" ]
  775.         then
  776.         infail "$ERR14"
  777.         fi
  778.  
  779.             if [ -z "$REP" ]
  780.             then
  781.                 REP=$CENTRAL
  782.             fi
  783.  
  784.         if [ -f "$REP" ]
  785.         then
  786.         $ECHO "$ERR33"
  787.                 continue
  788.         else
  789.                 if [ ! -d `dirname $REP` ]
  790.                 then
  791.                     $ECHO "$ERR34"
  792.                     continue
  793.                 else
  794.             OK=TRUE
  795.             CENTRAL=$REP
  796.                 fi
  797.         fi
  798.     done
  799.  
  800.     OK=FALSE
  801.     while [ $OK = FALSE ]
  802.     do
  803.         $ECHO "\nEnter directory in which to $Op1Type program, q to quit\nor press enter for default of $BINDIR ? \c"
  804.         read REP
  805.  
  806.         if [ "$REP" = "$CHKYN04" -o "$REP" = "$CHKYN05" ]
  807.         then
  808.                 if [ $UpGradeProduct = TRUE ]
  809.                 then
  810.             infail "$ERR19"
  811.                 else
  812.             infail "$ERR14"
  813.                 fi
  814.         fi
  815.  
  816.             if [ -z "$REP" ]
  817.             then
  818.                 REP=$BINDIR
  819.             fi
  820.  
  821.         if [ ! -d "$REP" ]
  822.         then
  823.         $ECHO "$ERR35"
  824.                 continue
  825.         else
  826.         if [ -f "$REP" ]
  827.         then
  828.             $ECHO "$ERR33"
  829.                     continue
  830.         else
  831.             OK=TRUE
  832.             BINDIR=$REP
  833.         fi
  834.         fi
  835.     done
  836.  
  837.     OK=FALSE
  838.  
  839.     $ECHO "\nThe product will be $Op2Type as follows;"
  840.  
  841.     $ECHO "\nProduct directory  : $CENTRAL"
  842.     $ECHO   "Program directory  : $BINDIR"
  843.  
  844.     $ECHO "\nContinue \c"
  845.  
  846.     chkyn && OK=TRUE
  847.     done
  848.  
  849.     if [ $UpGradeProduct = FALSE ]
  850.     then
  851.     if [ $CENTRAL != $DEFAULTCENTRAL ]
  852.     then
  853.         $ECHO "\n\nIMPORTANT"    
  854.         $ECHO "========="
  855.         $ECHO "\nA custom installation has been selected."
  856.  
  857.             $ECHO "\nMake sure that the environment variable WWWDIR is set"
  858.             $ECHO "for ALL users to $CENTRAL in the systems configuration"
  859.             $ECHO 'files (usually /etc/profile) before running the'
  860.             $ECHO "JSB ALPHABrowser."
  861.  
  862.         $ECHO "\nPress enter to continue ... \c"
  863.         read REP
  864.     fi
  865.     fi
  866. }
  867.  
  868. ##
  869. #  UpgradeWarn() - Warn about things that could change because of an upgrade
  870. ##
  871. UpgradeWarn()
  872. {
  873.     $ECHO
  874. }
  875.  
  876. ##
  877. #  GetOptions() - get valid installation options
  878. ##
  879. GetOptions()
  880. {
  881.     if [ $Upgrade = TRUE ]
  882.     then
  883.         return
  884.     fi
  885.  
  886.     if [ $UpGradeProduct = TRUE ]
  887.     then
  888.         Type="upgrade"
  889.     else
  890.         Type="installation"
  891.     fi
  892.  
  893.     OK=FALSE
  894.     while [ $OK = FALSE ]
  895.     do
  896.         $ECHO "\n\nChoose one of the following $Type options;"
  897.     $ECHO "\n1. Default $Type"
  898.         $ECHO "2. Custom $Type"
  899.         $ECHO "3. Quit"
  900.         $ECHO "\nSelect 1,2,3 or press enter for default <1> ? \c"
  901.     read REP
  902.  
  903.     if [ "$REP" = "3" ]
  904.     then
  905.             if [ $UpGradeProduct = TRUE ]
  906.             then
  907.             infail "$ERR19"
  908.             else
  909.             infail "$ERR14"
  910.             fi
  911.     fi
  912.  
  913.     if [ "$REP" = "" -o "$REP" = "1" ]
  914.     then
  915.             if [ $UpGradeProduct = TRUE ]
  916.         then
  917.            UpgradeWarn
  918.  
  919.                if [ $CENTRAL != $DEFAULTCENTRAL ] 
  920.                then
  921.           $ECHO "\n\nAn existing custom installation has been detected"
  922.                fi
  923.  
  924.                $ECHO
  925.  
  926.                if [ ! -d $CENTRAL/browser -o ! -f $BINDIR/$BRWBIN ] 
  927.                then
  928.                   if [ ! -d $CENTRAL/browser ]
  929.                   then
  930.                      InstallCFGS=TRUE
  931.                   fi
  932.  
  933.                   if [ ! -f $BINDIR/$BRWBIN -a $CENTRAL = $DEFAULTCENTRAL ] 
  934.                   then
  935.              $ECHO "Existing installation found to be incomplete"
  936.              $ECHO "Cannot locate the existing copy of program $BRWBIN in $BINDIR"
  937.                   else
  938.                      if [ ! -d $CENTRAL/browser ]
  939.                      then
  940.                    $ECHO "Existing installation found to be incomplete"
  941.                      fi
  942.                   fi
  943.                fi
  944.  
  945.                if [ $CENTRAL != $DEFAULTCENTRAL ] 
  946.                then
  947.           $ECHO "\n\nThe existing custom installation will be upgraded,"
  948.           $ECHO "but the program file will be installed in $BINDIR, Continue \c"
  949.                else
  950.                   $ECHO "\nDefault $Type selected, Continue \c"
  951.                fi
  952.             else
  953.                $ECHO "\nDefault $Type selected, Continue \c"
  954.             fi
  955.  
  956.         chkyn && OK=TRUE 
  957.         else
  958.             if [ "$REP" = "2" ]
  959.             then 
  960.                 if [ $UpGradeProduct = TRUE ]
  961.                 then
  962.            UpgradeWarn
  963.  
  964.                    if [ ! -d $CENTRAL/browser ] 
  965.                    then
  966.               $ECHO "Existing installation found to be incomplete"
  967.                    fi
  968.                 fi
  969.  
  970.                 GetDirs
  971.  
  972.                 OK=TRUE
  973.             fi
  974.     fi
  975.     done
  976. }
  977.  
  978. ##
  979. # audit_trail
  980. ##
  981. audit_trail()
  982. {
  983.     if [ $UpGradeProduct = TRUE -o $Upgrade = TRUE ]
  984.     then
  985.         OP="upgraded"
  986.     else
  987.         OP="installed"
  988.     fi
  989.  
  990.     $ECHO "\n\nThe JSB ALPHABrowser has been $OP as follows;\n"
  991.  
  992.     $ECHO "ALPHABrowser : \c"
  993.  
  994.     if [ $Browser = TRUE ]
  995.     then
  996.         if [ $BrowserIsDemo = TRUE ]
  997.         then
  998.             $ECHO "Evaluation copy $OP"
  999.         else
  1000.             $ECHO "Live copy $OP"
  1001.         fi
  1002.     else
  1003.         $ECHO "Not $OP"
  1004.     fi
  1005. }
  1006.  
  1007. ##
  1008. #  remove_licfile_copy 
  1009. ##
  1010. remove_licfile_copy()
  1011. {
  1012.    if [ -f $HOMEDIR/$LFILE -a $Upgrade = FALSE ]
  1013.    then
  1014.        rm -f $HOMEDIR/$LFILE
  1015.    fi
  1016. }
  1017.  
  1018. ##
  1019. #  final_message
  1020. ##
  1021. final_message()
  1022. {
  1023.    if [ $Upgrade = FALSE ]
  1024.    then
  1025.       if [ $UpGradeProduct = FALSE ]
  1026.       then
  1027.          $ECHO "$PRM15 $PRM05" ## Installation successful
  1028.       else
  1029.          $ECHO "$PRM20 $PRM05" ## Product Upgrade successful
  1030.       fi
  1031.    
  1032.       if [ $Browser = TRUE ]
  1033.       then
  1034.           $ECHO "\nTo start ALPHABrowser type alphabrowser at the command prompt"
  1035.       fi
  1036.    else
  1037.       $ECHO "$PRM16 $PRM05" ## User License increase successful
  1038.    fi
  1039.  
  1040.    $ECHO
  1041. }
  1042.  
  1043. ##
  1044. #  main()
  1045. ##
  1046.  
  1047. ##
  1048. #  Catch any efforts to terminate
  1049. ##
  1050. trap 'infailtrap' 1 2 4 9 15
  1051.  
  1052. SCRIPTNAME=`basename $0` 
  1053.  
  1054. ## 
  1055. #  initialisation messages
  1056. ##
  1057. start_up
  1058.  
  1059. ##
  1060. #  Make sure that the user reads the License Agreement 
  1061. #  AND agrees to it.
  1062. ##
  1063. page_license_txt
  1064.  
  1065. ##
  1066. #  check you're Super-User
  1067. ##
  1068. SuCheck 
  1069.  
  1070. ## 
  1071. #  check that we have all the required utilities
  1072. ## 
  1073. unix_tools
  1074.  
  1075. ##
  1076. #  get license number from user
  1077. ##
  1078. GetLicense
  1079.  
  1080. ##
  1081. #  get installation options default or custom
  1082. ##
  1083. GetOptions
  1084.  
  1085. ##
  1086. #  copy files from temp dir into installation dir
  1087. ##
  1088. CopyFiles
  1089.  
  1090. ##
  1091. #  move binaries etc into path
  1092. ##
  1093. MoveBin
  1094.  
  1095. ##
  1096. #  check permissions of files
  1097. ##
  1098. do_links
  1099.  
  1100. ##
  1101. #  Remove the unwanted copy of the License file
  1102. ##
  1103. remove_licfile_copy
  1104.  
  1105. ##
  1106. #  show details of install
  1107. ##
  1108. audit_trail
  1109.  
  1110. ##
  1111. #  Show the README file if the user wants to read it
  1112. ##
  1113. page_readme           
  1114.  
  1115. ##
  1116. #  Show final messages denoting successful operation
  1117. ##
  1118. final_message
  1119.  
  1120. ##
  1121. #  Exit with a code denoting success
  1122. ##
  1123. exit 0
  1124.