home *** CD-ROM | disk | FTP | other *** search
/ WordPerfect for Linux Bible / WP4LinuxBible.iso / install.wp next >
Text File  |  1999-06-25  |  40KB  |  1,146 lines

  1. #!/bin/sh
  2. # /* @(#) install.wp 1.10 02/10/98 10:02:18 */
  3. # install.wp - WordPerfect Install Script (MAIN)
  4.  
  5. if [ "x$1" = x-v ]; then Vflag=$1; set -x; shift; fi;    # See if verbose mode
  6. if [ "x$1" != x-l -a "x$1" != x-p -a "x$1" != x-t \
  7.     -a "x$1" != x-e -a "x$1" != "x" ]; then
  8.     echo; echo "  Usage: install.wp [-l -p -t -e ]"; echo; exit; fi;
  9. if [ "`echo -n`" = "" ]; then N="-n"; else C="\c"; fi;
  10. Parm0=$0; Parms=$*;
  11. ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ"; abc="abcdefghijklmnopqrstuvwxyz";
  12. SHLIB=shlib10; SHBIN=shbin10; WPBIN=wpbin; WPLIB=wplib;
  13. SHARED="[Ss][Hh][Aa][Rr][Ee][Dd]"; INS="[Ii][Nn][Ss]";
  14.  
  15. do_err() { echo; echo "  $*"; echo; do_exit; }
  16.  
  17. ck_cddir() {                        # cd to the install.wp being run
  18.     if [ "x$Vflag" = x-v ]; then set -x; fi;
  19.     PWD=`pwd`;
  20.     if   [ "$0" = install.wp ]; then
  21.         if [ -f $0 ]; then return; else DirWork=`which $0`; fi;
  22.     elif [ "$0" = "./install.wp" ]; then DirWork=$PWD/$0;   # curr dir
  23.     elif [ "$0" = "/tmp/install.wp" ]; then DirWork=$PWD/install.wp;
  24.     elif [ "$0" = "/tmp/remove.wp" ]; then DirWork=$PWD/remove.wp;
  25.     elif [ `echo $0 | sed 's|/.*$|/|'` = "/" ]; then DirWork=$0;# root path
  26.     else DirWork=$PWD/$0;                                       # relative path
  27.     while [ "`echo $DirWork | grep '\.\.'`" != "" ]; do     # simplify it
  28.         DirWork=`echo $DirWork | sed 's|[^/]*/\.\./||'`; done; fi;
  29.     cd `echo $DirWork | sed 's|/[^/]*.$||g'`;
  30. }
  31.  
  32. do_first() {                        # Initialize information
  33.     if [ "x$Vflag" = x-v ]; then set -x; fi;
  34.     if [ "$TMPDIR" = "" ]; then TMPDIR=/tmp; fi;
  35.  
  36.     FromDir=`pwd`;
  37.     while [ ! -d $FromDir/$SHARED ]; do        # must be in CD area to start
  38.         echo; echo $N "  Please enter the CD directory: $C"; read FromDir;
  39.     done;
  40.     cd $FromDir;
  41.  
  42.     echo; echo $N "  Please Wait $C";
  43.     id | egrep "root" >/dev/null 2>/dev/null;    # being root adds some menues
  44.     if [ "$?" = 0 ]; then User=root; edrc=edrc; mgic=mgic; fi;
  45.  
  46.     Version=1;
  47.     while [ -d $TMPDIR/WpTmP$Version ]; do
  48.         Version=`expr $Version + 1`;
  49.     done;
  50.     LinkDir=$TMPDIR/WpTmP$Version; mkdir $LinkDir;
  51.  
  52.     Ok="0"; Cancel="51"; Reverse="52";
  53.     ls -d */$INS | sed 's|/.*$||' | sed "y/$ABC/$abc/" > $LinkDir/.plts;
  54.  
  55.     UNAME_N=`uname -n`;
  56.     trap 'do_exit' 1 2 3 14 15
  57. }
  58.  
  59. do_plats() {                        # Determine what platform to run
  60.     if [ "x$Vflag" = x-v ]; then set -x; fi;
  61.     UNAME_A=`uname -a`;
  62.     uname -X > /tmp/junk 2>/dev/null;
  63.     Work=`cat /tmp/junk | grep Release | sed 's/.*v//' | sed 's/\..*$//'`;
  64.     rm -f /tmp/junk;
  65.     if [ "$Work" = "" ]; then
  66.         OSVer=`uname -v | awk '{ print substr($1,1,1) }'`;
  67.     else
  68.         OSVer=$Work; fi;
  69.     SYNam=`uname -r | sed 's/\..*/-/g'`;
  70.     HWNam=`uname -m | awk '{ print substr($1,1,1) }'`;
  71.     set $SYNam $OSVer $HWNam;
  72.  
  73.     PlatInfo=`ls */*[Ll]_[Ii][Nn][Ff][Oo]*`;
  74.     Platform=`grep " Platform " $PlatInfo | sed 's/ * /:/g' \
  75.     | grep ":$1" | grep ":$2" | grep ":$3"'$' | cut -d":" -f1`;
  76.  
  77.     WPTEST=[Ww][Pp][Tt][Ee][Ss][Tt];
  78.     if [ "$Platform" = "" ]; then
  79.         # the following order is important
  80.         for Platwork in *[Ss] *9000 *6000 *86 *[Xx] *[Oo]; do
  81.             WORK=`$Platwork/$INS/$WPTEST* 2>/dev/null | grep -v Killed`;
  82.             if [ "$WORK" = "Good" ]; then
  83.                 Platform=`echo $Platwork | sed 's/\/.*$//'`; break;
  84.             fi;
  85.         done;
  86.     fi;
  87.  
  88.     # if unknown platform, display choices and ask for input
  89.     while [ "$Platform" = "" -o "`grep '^'$Platform $PlatInfo`" = "" ]; do 
  90.         echo; echo; echo "  Available Platforms:"; echo;
  91.         grep '^[a-z]' $PlatInfo | cut -d" " -f1 | sort -u | sed 's/^/  /'; echo;
  92.         echo $N "  Enter Selection: $C"; read Platform;
  93.     done;
  94.  
  95.     PLATFORM=$Platform;
  96.     if [ -d SHARED ]; then PLATFORM=`echo $Platform | sed "y/$abc/$ABC/"`; fi;
  97.  
  98.     if [ "$Platform" = linux ]; then
  99.         UNAME_R=`uname -r`;
  100.         Maj=`echo $UNAME_R | sed 's/[^\.]*$//' | sed 's/\.$//'`
  101.         Min=`echo $UNAME_R | sed 's/.*\.//'`
  102.  
  103.         if [ "$Maj" != 2.0 -o "$Min" -lt 18 ]; then echo;
  104.             echo $N "  Linux $Maj.$Min not certified.  Continue? (y/n) $C";
  105.             read Cont;
  106.             if [ "$Cont" != y ]; then echo; do_exit; else echo $N "  $C"; fi;
  107.         fi;
  108.     fi;
  109. }
  110.  
  111. mylink() {                            # create symbolic links
  112.     if [ "x$Vflag" = x-v ]; then set -x; fi;
  113.     LinkFile=$LinkDir/LinkFile;
  114.     echo > $LinkFile
  115.     ls -1F $1 | sed 's/[@\*]//' | sed '/\/$/d
  116.         h
  117.         y/'$ABC'/'$abc'/
  118.         s|\.$||
  119.         G
  120.         s|\(.*\)\n\(.*\)|ln -s '$1'/\2 \1|' | sed '/YMTRANS.TBL/d' >> $LinkFile
  121.     chmod 755 $LinkFile;
  122.     $LinkFile;                        # execute the link file
  123.     rm -f $LinkFile;
  124. }
  125.  
  126. ck_media() {                        # Initialize for tape or cd
  127.     if [ "x$Vflag" = x-v ]; then set -x; fi;
  128.     Dirs=`ls -d $SHARED */$INS`;
  129.     for Dir in $Dirs; do
  130.         DirLow=$LinkDir/`echo $Dir | sed "y/$ABC/$abc/"`;
  131.         rm -rf $DirLow; mkdir -p $DirLow; cd $DirLow; mylink $FromDir/$Dir;
  132.     done
  133.     cd $LinkDir
  134.     mv shared/wpdata shared/wpdata.bk;
  135.     cp shared/wpdata.bk shared/wpdata;
  136.     chmod u+w shared/wpdata;
  137. }
  138.  
  139. mk_plats() {                        # Make the platform list
  140.     if [ "x$Vflag" = x-v ]; then set -x; fi;
  141.     echo `date` >> shared/log;
  142.     WorkList="zzz";
  143.     for work in `ls -d */ins | sed 's/\/.*$//' | sed 's/ /|/g'`; do
  144.         WorkList="$WorkList|<$work>";
  145.         if [ "$Platform" = "$work" ];
  146.         then Values=$Values"1";
  147.         else Values=$Values"0";
  148.         fi
  149.     done
  150.                                     # show menu if multiple platforms
  151.     if [ 1"$Values" -gt 11 ]; then
  152.         rm -f shared/m_plat;
  153.         sed -n '1,/DONE/p' shared/l_plat > shared/m_plat
  154.         egrep "$WorkList" shared/l_plat | sed 's/<.*$//' >> shared/m_plat
  155.         plat=plat; RetCode=$Ok; Menu=plat; echo "$Values" > .wptemp; savdata;
  156.     fi
  157. }
  158.  
  159. do_parms() {                        # Process command line parameters
  160.     if [ "x$Vflag" = x-v ]; then set -x; fi;
  161.  
  162.     Plim=100;
  163.     Menu=eula; eula=eula; agre=agre;
  164.     lnum=lnum; lses=lses; lnu2=lnu2; flex=flex;
  165.     FullPart="Full";
  166.     Work=`echo $0 | sed 's/^.*\///'`;
  167.     if [ "$Work" = "REMOVE.WP" -o "$Work" = remove.wp ]; then
  168.         Menu=rm01; last=rm03; Remove=Remove; stat="remove";
  169.         SMsg="  Removing Files..."; EMsg="  Installation Removed.";
  170.     else
  171.         last=last; stat="install";
  172.         SMsg="  Installing Files..."; EMsg="  Installation Complete.";
  173.     fi;
  174.     CMsg="  Installation Cancelled.";
  175.     set dumb $Parms; shift;
  176.     while [ "x$1" != "x" ]; do
  177.         if [ "x$1" = x-l ]; then
  178.             Lflag=$1; FullPart="Part"; prod=prod; size=size; lngs=lngs;
  179.         elif [ "x$1" = x-p ]; then
  180.             Pflag=$1; FullPart="Part"; lngs=lngs; prod=prod; prnt=prnt;
  181.         elif [ "x$1" = x-t ]; then
  182.             Tflag=$1; FullPart="Part"; Prod="3 "; term=term;
  183.         elif [ "x$1" = x-e ]; then
  184.             Eflag=$1; FullPart="Part";
  185.             prod=; size=; lngs=; term=; prnt=; extr=extr;
  186.         elif [ "x$1" = x-a ]; then
  187.             Aflag=$1; FullPart="Full";
  188.         fi
  189.         shift;
  190.     done
  191.  
  192.     if [ "$FullPart" = "Full" ]; then
  193.         Lflag="-l"; Pflag="-p"; Tflag="-t"; Eflag="-e"; Aflag="-a";
  194.         prod=prod; size=size; lngs=lngs; defl=defl;
  195.         lnum=lnum; lses=lses; lnu2=lnu2; flex=flex; lsvr=lsvr;
  196.         term=term; prnt=prnt; asgn=asgn; extr=extr; fi;
  197.  
  198.     if [ -f shared/xkysymdb ]; then cp shared/xkysymdb shared/XKeysymDB; fi
  199.  
  200.     if [ -f shared/wpprod ]; then Prod=`cat shared/wpprod`;
  201.         if   [ "$Prod" = "2 " ]; then term=; prod=;
  202.         elif [ "$Prod" = "3 " ]; then prod=; size=; fi;
  203.     fi;
  204.  
  205.     Temp=`sed -n '/#ifdef.*'$Platform'$/,/#endif.*'$Platform'$/p' \
  206.         shared/l_extr | sed '/^#/d'`;
  207.     if [ "$Temp" = "" ]; then extr=; Eflag=; fi;    # no extra options
  208.  
  209.     if [ -f shared/l_s ]; then lnum=; Lnum="Single";
  210.         lses=; Lses=1; lnu2=; flex=; lsvr=; Lsvr=`uname -n`; edrc=; fi;
  211.     if [ -f shared/l_l ]; then lnum=lnum;
  212.         lses=; Lses=1; lnu2=; flex=; lsvr=; Lsvr=`uname -n`; edrc=; fi;
  213. }
  214.  
  215. get_set_def() {                        # get printer settings files
  216.     if [ "x$Vflag" = x-v ]; then set -x; fi;
  217.     if [ "$FullPart" = Part ]; then return; fi;
  218.     rm -f shared/.prlist
  219.     if [ ! -d .wpset ]; then mkdir .wpset; fi;
  220.  
  221.     rm -f .wpset/.wpc* .wpset/.wp*.def;
  222.  
  223.     for DirFile in \
  224.         shdrive/.wpc.set shlib/.wpc51.set \
  225.         $SHLIB/.wpc52.set $SHLIB/.wpc7c.set $SHLIB/.wpc8c.set \
  226.         $SHLIB/.wpc60.set $SHLIB/.wpc7x.set $SHLIB/.wpc8x.set \
  227.         shdrive/wpport.def shlib/wpport.def \
  228.         $SHLIB/wpdest.def
  229.     do
  230.         if [ -f $WRKDIR/$DirFile ]; then cp $WRKDIR/$DirFile .wpset; fi;
  231.     done
  232.  
  233.     if   [ -f .wpset/.wpc.set ];   then CHR_WPCSET=".wpc.set";
  234.     elif [ -f .wpset/.wpc51.set ]; then CHR_WPCSET=".wpc51.set";
  235.     elif [ -f .wpset/.wpc52.set ]; then CHR_WPCSET=".wpc52.set";
  236.     elif [ -f .wpset/.wpc7c.set ]; then CHR_WPCSET=".wpc7c.set";
  237.     elif [ -f .wpset/.wpc8c.set ]; then CHR_WPCSET=".wpc8c.set"; fi;
  238.  
  239.     if   [ -f .wpset/.wpc60.set ]; then GUI_WPCSET=".wpc60.set";
  240.     elif [ -f .wpset/.wpc7x.set ];  then GUI_WPCSET=".wpc7x.set";
  241.     elif [ -f .wpset/.wpc8x.set ];  then GUI_WPCSET=".wpc8x.set"; fi;
  242.  
  243.     if   [ -f .wpset/wpport.def ]; then DEST_INFO="wpport.def";
  244.     elif [ -f .wpset/wpdest.def ]; then DEST_INFO="wpdest.def"; fi;
  245.  
  246.     if [ -f .wpset/$DEST_INFO ]; then mv .wpset/$DEST_INFO .; fi;
  247. }
  248.  
  249. pretest() {                            # Get the menu values from wpdata
  250.     if [ "x$Vflag" = x-v ]; then set -x; fi;
  251.     Values=`sed -n '/^'$Menu'=/p' $LinkDir/shared/wpdata \
  252.         | sed 's/^'$Menu'=//'`;
  253.     case $Menu in
  254.         agre)
  255.             rm -f shared/m_agre;
  256.             grep '^00 ' shared/l_agre | sed 's/^00 //' > shared/m_agre;
  257.             grep '^0'"$Eula" shared/l_agre | sed 's/^0[1-9] //' \
  258.             >> shared/m_agre;
  259.             echo  > shared/license;
  260.             cat shared/license.$Eula | while read Info; do
  261.                 echo "${Info}" >> shared/license;
  262.                 echo  >> shared/license;
  263.                 echo  >> shared/license;
  264.             done;;
  265.         idir) rm -f shared/m_idir;
  266.             if [ "$FullPart" = Full ]; then warn_work="warn_inst";
  267.             else warn_work="warn_miss"; fi;
  268.             sed -n -e '/#ifdef.*'$Platform'$/,/#endif.*'$Platform'$/p' \
  269.                 -e '/#ifdef ALL/,/#endif ALL/p' shared/l_idir \
  270.                 | sed -e '/^#/d' -e '/^$/d' | sed 's/warn_inst/'$warn_work'/' \
  271.                 > shared/m_idir;;
  272.         size) rm -f shared/m_size;
  273.             if [ "$Prod" = "3 " ]; then Values=1; fi;
  274.             sed -n '/#ifdef ALL/,/#endif ALL/p' shared/l_size \
  275.                 | sed -e '/^#/d' > shared/m_size;
  276.             sed -n '/#ifdef.*'$Platform'$/,/#endif.*'$Platform'$/p' \
  277.                 shared/l_size | sed -e '/^#/d' -e '/^$/d' \
  278.                 | grep '^'"$Prod" | sed 's/^[123] //' >> shared/m_size;;
  279.         lsvr) if [ "$Values" = "" ]; then Values="$UNAME_N"; fi;;
  280.         lngs) rm -f shared/m_lngs; LDirs="zzz";
  281.             for LDir in `cat $LinkDir/shared/wplngs`; do
  282.                 LDirs="$LDirs| $LDir "; done;
  283.             grep '^[^ ]' shared/l_lngs > shared/m_lngs;
  284.             egrep "$LDirs" shared/l_lngs | sed 's/^ .. //' >> shared/m_lngs;;
  285.         defl) rm -f shared/m_defl;
  286.             grep '^[^ ]' shared/l_defl > shared/m_defl;
  287.             egrep "$LDirs" shared/l_defl | sed 's/^ .. //' >> shared/m_defl;;
  288.         term) rm -f shared/m_term;
  289.             cat shared/l_term > shared/m_term;
  290.             echo "InputTrs=shared/trs_c.us" >> shared/m_term;
  291.             if [ "$Ptrn" ]; then
  292.                 echo "PATTERN_DIR=$Ptrn/$SHLIB" >> shared/m_term; fi;;
  293.         prnt) rm -f shared/m_prnt;
  294.             cat shared/l_prnt > shared/m_prnt;
  295.             if [ "$Ptrn" != "" ]; then WRKDIR=$Ptrn; get_set_def;
  296.             else WRKDIR=$Idir; get_set_def; fi;
  297.  
  298.             if [ "$FullPart" = Full ]; then
  299.                 if [ "$Prod" = "1 " -o "$Prod" = "2 " ]; then
  300.                     for cnv in prs5028 prs5128 sf5028 sf5128
  301.                     do    if [ ! -f .wpset/$cnv.$DEFL ]; then
  302.                             cp shared/$cnv.us .wpset/$cnv.$DEFL; fi;
  303.                     done
  304.                 fi
  305.                 if [ "$Prod" = "1 " -o "$Prod" = "3 " ]; then
  306.                     for cnv in prs5028c prs5128c sf5028c sf5128c
  307.                     do    if [ ! -f .wpset/$cnv.$DEFL ]; then
  308.                             cp shared/$cnv.us .wpset/$cnv.$DEFL; fi;
  309.                     done
  310.                 fi
  311.  
  312.                 if [ "$GUI_WPCSET" != "" ]; then 
  313.                     echo "SETTING_GUI=$GUI_WPCSET" >> shared/m_prnt; fi;
  314.                 if [ "$CHR_WPCSET" != "" ]; then
  315.                     echo "SETTING_CHR=$CHR_WPCSET" >> shared/m_prnt; fi;
  316.             fi;
  317.             if   [ "$Prod" = "1 " ]; then
  318.                 echo "PRINTERS_BTH=shared/prs_b.us" >> shared/m_prnt;
  319.             elif [ "$Prod" = "2 " ]; then
  320.                 echo "PRINTERS_GUI=shared/prs_g.us" >> shared/m_prnt;
  321.             elif [ "$Prod" = "3 " ]; then
  322.                 echo "PRINTERS_CHR=shared/prs_c.us" >> shared/m_prnt; fi;
  323.             ;;
  324.         asgn) rm -f shared/m_asgn;
  325.             cat shared/l_asgn > shared/m_asgn;
  326.             if [ "$GUI_WPCSET" != "" ]; then 
  327.                 echo "SETTING_GUI=$GUI_WPCSET" >> shared/m_asgn; fi;
  328.             if [ "$CHR_WPCSET" != "" ]; then
  329.                 echo "SETTING_CHR=$CHR_WPCSET" >> shared/m_asgn; fi;
  330.             if [ "$DEST_INFO" != "" ]; then
  331.                 echo "DEST_FILE=$DEST_INFO" >> shared/m_asgn; fi;
  332.             touch .wptemp .wplist;
  333.             ;;
  334.         extr) rm -f shared/m_extr;
  335.             sed -n -e '/#ifdef.*'$Platform'$/,/#endif.*'$Platform'$/p' \
  336.                 -e '/#ifdef ALL/,/#endif ALL/p' shared/l_extr \
  337.                 | sed -e '/^#/d' -e '/^$/d' > shared/m_extr;;
  338.         ndir) if [ "$Values" = "" ]; then Values=$Idir/netscape; fi;;
  339.         last|rm03) Review=; getmenu; Menu=$last;;
  340.     esac;
  341.     if [ "$First" = "$Menu" -a "$Menu" != eula ]; then
  342.         touch shared/m_$Menu.bk;
  343.         cp shared/m_$Menu shared/m_$Menu.bk;
  344.         rm -f shared/m_$Menu;
  345.         mv shared/m_$Menu.bk shared/m_$Menu;
  346.         echo PREV_BUTTON= >> shared/m_$Menu; fi;
  347. }
  348.  
  349. runprog() {                            # Start the gui or the char version
  350.     if [ "$Vflag" = -v ]; then set -x; fi;
  351.     if [ "$Exec" = "" ]; then Exec="wpinstg";
  352.         if [ "$DISPLAY" = "" ]; then Exec="wpinstc";
  353.             if [ "x$Vflag" != x-v ]; then clear; fi;
  354.             $Platform/ins/$Exec $Menu $Values 2>>shared/log; RetCode=$?;
  355.             if [ "$RetCode" = 1 ]; then
  356.                 do_err "Error: The character install has failed."; fi;
  357.             if [ -s .wpterm ]; then
  358.                 TERM=`cat .wpterm`; rm -f .wpterm; export TERM; fi;
  359.         else
  360.             if $Platform/ins/wpinstg color grey 1>/dev/null 2>/dev/null; then
  361.                 bgcolor="-bg grey"; fi;
  362.             $Platform/ins/$Exec $Menu $Values $bgcolor; RetCode=$?;
  363.             if [ "$RetCode" != 0 -a "$RetCode" != 51 ]; then
  364.                 echo; echo "Warning: The graphical install program has failed.";
  365.                 sleep 2;
  366.                 echo "Trying to run the character-based install program.";
  367.                 sleep 2;
  368.                 Exec="wpinstc";
  369.                 if [ "x$Vflag" != x-v ]; then clear; fi;
  370.                 $Platform/ins/$Exec $Menu $Values 2>>shared/log; RetCode=$?;
  371.                 if [ "$RetCode" = 1 ]; then
  372.                     do_err "Error: The character install has failed."; fi;
  373.                 if [ -s .wpterm ]; then
  374.                     TERM=`cat .wpterm`; rm -f .wpterm; export TERM; fi;
  375.             fi
  376.         fi
  377.     else
  378.         if [ "x$Vflag" != x-v -a "$Exec" = wpinstc ]; then clear; fi;
  379.         $Platform/ins/$Exec $Menu "$Values" $bgcolor \
  380.             2>>shared/log; RetCode=$?;
  381.     fi;
  382.     if [ "$RetCode" = "$Cancel" ]; then do_exit; fi;
  383.     if [ -f shared/m_$Menu.bk ]; then    # Restore PREV_BUTTON= adjustment
  384.         mv shared/m_$Menu.bk shared/m_$Menu; fi;
  385. }
  386.  
  387. savdata() {                        # Save new values in the wpdata file
  388.     if [ "x$Vflag" = x-v ]; then set -x; fi;
  389.     if [ "$Menu" = "$agre" -o "$Menu" = "$last" ]; then return; fi;
  390.  
  391.     echo "$Menu=xxx" >> $LinkDir/shared/wpdata
  392.     WPTEMP=`cat .wptemp`;
  393.     sed 's|^'$Menu'=.*$|'$Menu'='"$WPTEMP"'|' $LinkDir/shared/wpdata \
  394.         | sort -u > $LinkDir/shared/wpdata.new;
  395.     rm -f $LinkDir/shared/wpdata;
  396.     mv $LinkDir/shared/wpdata.new $LinkDir/shared/wpdata;
  397. }
  398.  
  399. savwork() {                            # Save information for later processing
  400.     if [ "x$Vflag" = x-v ]; then set -x; fi;
  401.     case $Menu in                    # .wptemp is ascii or binary numbers
  402.         eula) Eula=`cat .wplist`;
  403.             if [ "$Review" != "" ]; then Review=`echo $Review \
  404.                 | sed 's/agre//' | sed 's/eula/eula agre/'`; fi;;
  405.         plat) Plat=`cat .wplist`; Plat=`echo $Plat | sed 's/ //'`;
  406.             Platform=`sed -n $Plat'p' $LinkDir/.plts`;;
  407.         tape) Tape=`cat .wptemp`;;
  408.         rm02) Rm02=`cat .wptemp`;;
  409.         idir) Idir=`cat .wptemp`;
  410.             if [ -d "$Idir" ]; then    # Remove it since it could change
  411.                 rmdir $Idir 2>/dev/null; fi;
  412.             if [ -f $Idir/.install_log ]; then
  413.                 mv $Idir/.install_log $Idir/.install_log.bk; fi;
  414.  
  415.             if [ "`sed -n 2,2'p' shared/wplngs`" = "" ]; then
  416.                 LNGS=`sed "y/$ABC/$abc/" shared/wplngs`;
  417.                 defl=; DEFL=$LNGS; fi;;
  418.         prod) Prod=`cat .wplist`;
  419.             prod=; size=; prnt=; asgn=; term=;
  420.             if   [ "x$Lflag" = x-l ]; then
  421.                 prod=prod; size=size; fi;
  422.             if [ "x$Pflag" = x-p ]; then prod=prod; prnt=prnt; asgn=asgn; fi;
  423.             if [ "x$Tflag" = x-t ]; then term=term; fi;
  424.             if [ "x$Eflag" = x-e ]; then extr=extr; fi;
  425.  
  426.             rm -f shared/m_prnt;
  427.             if   [ "$Prod" = "1 " ]; then cp shared/l_prnt shared/m_prnt; 
  428.             elif [ "$Prod" = "2 " ]; then term=;
  429.                 sed '/prs_c/d' shared/l_prnt > shared/m_prnt;
  430.             elif [ "$Prod" = "3 " ]; then
  431.                 size=; extr=; ndir=;
  432.                 sed '/prs_b/d' shared/l_prnt > shared/m_prnt; fi;;
  433.         size) Size=`cat .wplist`;;
  434.         ptrn) Ptrn=`cat .wptemp`;;
  435.         lerr) Lerr=`cat .wptemp`;;
  436.         lnum) Lnum=`cat .wptemp`;
  437.             lerr=;
  438.             if [ "$Review" != "" ]; then
  439.                 Review=`echo $Review | sed 's/lerr//'`; fi;
  440.             if [ "$RetCode" = "$Ok" ]; then
  441.                 $LinkDir/$Platform/ins/veruxkey -r $Lnum;
  442.                 if [ "$?" = 0 ]; then lerr=;
  443.                 else Menu=ptrn; lerr=lerr;
  444.                     if [ "$Review" != "" ]; then Review=`echo $Review \
  445.                         | sed 's/lerr//' | sed 's/lnum/lerr lnum/'`; fi;
  446.                 fi;
  447.             fi;;
  448.         lses) Lses=`cat .wptemp`;
  449.             if [ "$Lses" -le "1" ]; then lnu2=;
  450.                 if [ "$Review" != "" ]; then Review=`echo $Review \
  451.                     | sed -e 's/lnu2//' -e 's/ler2//'`; fi;
  452.             fi;
  453.             if [ "$Lses" -gt "1" ]; then lnu2=lnu2;
  454.                 if [ "$Review" != "" ]; then
  455.                     Review=`echo $Review | sed -e 's/lnu2//' -e 's/ler2//' \
  456.                         -e 's/lses/lses lnu2/'`; fi;
  457.             fi;;
  458.         ler2) Ler2=`cat .wptemp`;;
  459.         lnu2) Lnu2=`cat .wptemp`;
  460.             ler2=;
  461.             if [ "$Review" != "" ]; then
  462.                 Review=`echo $Review | sed 's/ler2//'`; fi;
  463.             if [ "$RetCode" = "$Ok" ]; then
  464.                 $LinkDir/$Platform/ins/veruxkey -a $Lnu2;
  465.                 if [ "$?" = 0 ]; then ler2=;
  466.                 else Menu=lses; ler2=ler2;
  467.                     if [ "$Review" != "" ]; then Review=`echo $Review \
  468.                         | sed 's/ler2//' | sed 's/lnu2/ler2 lnu2/'`; fi;
  469.                 fi;
  470.             fi;;
  471.         flex) Flex=`cat .wplist`;
  472.             if [ "$Review" != "" ]; then Review=`echo $Review \
  473.                 | sed 's/lsvr//' | sed 's/edrc//'`; fi;
  474.             if   [ "$Flex" = "1 " ]; then lsvr=; edrc=;
  475.             elif [ "$Flex" = "2 " ]; then lsvr=lsvr;
  476.                 if [ "$User" = root ]; then edrc=edrc; fi;
  477.                 if [ "$Review" != "" ]; then Review=`echo $Review \
  478.                     | sed 's/flex/ flex '$lsvr' '$edrc'/'`; fi;
  479.             fi;;
  480.         lsvr) Lsvr=`cat .wptemp`;;
  481.         edrc) Edrc=`cat .wplist`;;
  482.         mgic) Mgic=`cat .wplist`;;
  483.         lngs) Lngs=`cat .wplist`;
  484.             for Lng in $Lngs; do
  485.                 LNG=`sed -n $Lng'p' $LinkDir/shared/wplngs | sed "y/$ABC/$abc/"`;
  486.                 LNGS="$LNGS $LNG";
  487.             done;
  488.             TMPWRK=`wc -l .wplist | sed 's/^/ /' | sed 's/ * / /g' \
  489.                 | cut -d" " -f2`;
  490.             if [ "$TMPWRK" -gt 1 ]; then defl="defl";
  491.                 if [ "$Review" != "" -a "$Aflag" = "-a" ]; then
  492.                     Review=`echo $Review \
  493.                     | sed 's/defl//' | sed 's/lngs/lngs defl/'`; fi;
  494.             else defl=; DEFL=$LNG; fi;;
  495.         defl) Defl=`cat .wplist | sed 's/ //g'`;
  496.             DEFL=`sed -n $Defl'p' $LinkDir/shared/wplngs | sed "y/$ABC/$abc/"`;;
  497.         term) Trsi=`cat .wptemp`;
  498.             rm -f shared/.trlist; mv .wplist shared/.trlist;;
  499.         prnt) Prnt=`cat .wptemp`;
  500.             if [ -s .wplist -a "$FullPart" = Full ]; then asgn="asgn";
  501.                 if [ "$Review" != "" ]; then Review=`echo $Review \
  502.                     | sed 's/asgn//' | sed 's/prnt/prnt asgn/'`; fi;
  503.             else asgn=; fi;
  504.             rm -f shared/.prlist; mv .wplist shared/.prlist;;
  505.         asgn) Asgn=`cat .wptemp`;;
  506.         extr) Icon=; Oman=; Net1=; Net2=;
  507.             echo Junk > .list1; sed 's/ /:/' .wplist >> .list1;
  508.             grep '^'Multi shared/m_extr | grep -n . | egrep -f .list1 > .list2;
  509.             Icon=`grep Icon .list2 | sed 's/:.*$//'`;
  510.             Oman=`grep Manual .list2 | sed 's/:.*$//'`;
  511.             Net1=`grep Netscape  .list2 | sed 's/:.*$//'`;
  512.             rm -f .list1 .list2;
  513.  
  514.             if [ "$Net1" -a "$Net2" ]; then Net2=; fi; ecnt=0;
  515.             for eopt in $Icon $Oman $Net1 $Net2; do ecnt=`expr $ecnt + 1`; done;
  516.             Plim=`expr 100 - $ecnt`;
  517.  
  518.             ndir=;
  519.             Review=`echo $Review \
  520.                 | sed -e 's/ndir//g'`;
  521.             if [ "$Net1" -o "$Net2" ]; then ndir=ndir; fi;
  522.             Review=`echo $Review \
  523.                 | sed 's/extr/ extr '$ndir'/'`;;
  524.         ndir) Ndir=`cat .wptemp`;
  525.             for Dir in $Ndir $Idir; do    # Remove them since they could change
  526.                 if [ -d $Dir ]; then rmdir $Dir 2>/dev/null; fi; done;;
  527.         rm03|last) Review=;
  528.             if [ -s .wplist ]; then
  529.                 set dumb $MenuList; Work=0;
  530.                 for Num in `cat .wplist`; do
  531.                     shift `expr $Num - $Work`;
  532.                     Review="$Review $1";
  533.                     Work=$Num; done
  534.                 set $Review; First=$1;
  535.                 Work=$last;
  536.                 Review="$Review $Work"; fi;;
  537.     esac
  538.     rm -f .wplist .wptemp;    # Remove work files
  539. }
  540.  
  541. getmenu() {                        # Make the menus list
  542.     if [ "$Vflag" = -v ]; then set -x; fi;
  543.  
  544.     Part1="$eula $agre $plat $tape idir $prod $size";
  545.     Part2="$lerr $lnum $lses $ler2 $lnu2 $flex $lsvr";
  546.     Part3="$term $prnt $asgn $extr $ndir $last";
  547.  
  548.     if   [ "$Remove" = "Remove" ]; then MenuList="rm01 rm02 rm03";
  549.     elif [ "$FullPart" = "Part" ]; then MenuList="$Part1 $lngs $Part3";
  550.     else MenuList="$Part1 ptrn $Part2 $edrc $mgic $lngs $defl $Part3"; fi;
  551.  
  552.     if [ "$Review" != "" ]; then MenuList=$Review; fi;
  553.  
  554.     if [ "$RetCode" = "$Reverse" ]; then
  555.         Menu=`echo $MenuList | sed 's/ * '$Menu'.*//' \
  556.         | sed 's/.* //'`; return; fi;
  557.  
  558.     Work=$last;
  559.     if [ "$Menu" = "$Work" ]; then
  560.         TempList=`echo $MenuList | sed 's/ * /|/g'`;
  561.         rm -f shared/t_$Work;
  562.         egrep "$TempList" shared/l_$Work | sed 's/[^ ]* //' > shared/t_$Work;
  563.  
  564.         if [ "$Review" != "" ]; then 
  565.             Menu=`echo $MenuList | sed 's/ .*//'`; return; fi;
  566.         return 1; fi;
  567.  
  568.     Menu=`echo $MenuList | sed 's/ * / /g' \
  569.         | sed 's/.*'$Menu' //' | sed 's/ .*//'`;
  570. }
  571.  
  572. do_menus() {                        # Loop through the menu list
  573.     if [ "$Vflag" = -v ]; then set -x; fi;
  574.     while true; do
  575.         pretest;                    # Pre Test
  576.         runprog;                    # Start the gui or the char version
  577.         savdata;                    # Update the wpdata file
  578.         savwork;                    # Update macros for later processing
  579.         getmenu;
  580.         if [ "$?" = 1 ]; then break; fi;
  581.     done
  582. }
  583.  
  584. decomp() {                            # decompress files
  585.     if [ "$Vflag" = -v ]; then set -x; fi;
  586.     if [ -s "$1" ]; then
  587.         $Platform/ins/wpdecom -s $1 $2 2>> shared/log; RetCode=$?;
  588.         if [ "$RetCode" = 2 ]; then cp $1 $2;
  589.         elif [ "$RetCode" = 1 ]; then do_err "Error: Unable to go on."; fi
  590.     fi
  591. }
  592.  
  593. do_pcnt() {
  594.     while [ "$last_pcnt" -lt "$pcnt" ]; do
  595.         last_pcnt=`expr $last_pcnt + 1`;
  596.         if [ "$Exec" = wpinstg ]; then
  597.             if [ "$last_pcnt" -le "$Plim" ]; then
  598.                 echo $N "1$C" >> shared/l_pcnt; fi;
  599.             if [ -f shared/cancel ]; then exit; fi;    # exit while
  600.         else
  601.             if [ $CNT = 1 ]; then S1="$S1 "; B1="$B1"; fi;
  602.             if [ $CNT = 3 ]; then S2="$S2 "; B2="$B2"; fi;
  603.             if [ $last_pcnt = 10 -o $last_pcnt = 100 ]; then P1="$P1"; fi;
  604.             if [ "$last_pcnt" = "$pcnt" ]; then
  605.                 TPUT=tput;
  606.                 if [ -f /usr/5bin/tput ]; then TPUT=/usr/5bin/tput; fi;
  607.                 $TPUT rev 2>>/dev/null;
  608.                 echo $N "$S1$pcnt%$S2$B1$P1$B2$C";
  609.                 $TPUT rmso 2>>/dev/null;
  610.             fi;
  611.             if [ $CNT = 4 ]; then CNT=1; else CNT=`expr $CNT + 1`; fi;
  612.         fi;
  613.     done
  614. }
  615.  
  616. do_stat() {                            # Start the percent complete status
  617.     if [ "$Vflag" = -v ]; then set -x; fi;
  618.     Desc="Percent Complete:"
  619.     rm -f shared/l_pcnt shared/cancel;
  620.     touch shared/l_pcnt;
  621.     if [ "$FullPart" = Part -o "$Remove" = Remove ]; then
  622.         sed -n '$'p shared/l_xpm2 > shared/l_xpm2.new;
  623.         rm -f shared/l_xpm2; mv shared/l_xpm2.new shared/l_xpm2; fi;
  624.     if [ "$Exec" = wpinstg ]; then
  625.         ($Platform/ins/wpinstg $stat $bgcolor 2>>shared/log &); sleep 1; fi;
  626.     if [ "$Vflag" != -v -a "$Exec" = wpinstc ]; then
  627.         clear; echo; echo "$SMsg"; fi;
  628.     if [ "$Exec" = wpinstc ]; then
  629.         fil_cnt=0; tot_cnt=20; last_pcnt=0;
  630.         echo; P1=; CNT=1; echo $N "  $Desc  $C"; fi;
  631.  
  632.     if [ "$Remove" = Remove ]; then
  633.         for dir in acroread netscape samples junk junk \
  634.             shbin10 shlib10 xpdf junk junk \
  635.             wpbin wpexpdocs wpgraphics junk junk \
  636.             wplearn wplib wpmacros xpdf junk; do
  637.             echo $N "12345$C" >> shared/l_pcnt;
  638.             if [ -d $Rm02/$dir ]; then
  639.                 chmod u+w $Rm02/$dir; rm -rf $Rm02/$dir; fi;
  640.             if [ "$Exec" = wpinstc ]; then
  641.                 fil_cnt=`expr $fil_cnt + 1`;
  642.                 work=`expr $fil_cnt \* 100`;
  643.                 pcnt=`expr $work / $tot_cnt`;
  644.                 do_pcnt;
  645.             fi;
  646.             sleep 2;
  647.         done;
  648.         echo $N "1234567890$C" >> shared/l_pcnt;
  649.         sleep 4;
  650.         do_exit;
  651.     fi;
  652. }
  653.  
  654. mk_list() {                            # Build a list of files to install
  655.     if [ "$Vflag" = -v ]; then set -x; fi;
  656.     SHIP="shared/ship";
  657.     WORK="shared/worklist"; rm -f $WORK;
  658.     sed -n -e '/^#ifdef.*'$Platform'$/,/^#endif.*'$Platform'$/p' \
  659.         -e '/^#ifdef ALL$/,/^#endif ALL$/p' $SHIP \
  660.         | sed -e '/^#/d' -e '/^$/d' | sort -u > $WORK
  661.  
  662.     rm -f shared/t_ship; touch shared/t_ship;
  663.  
  664.     if [ "$FullPart" = "Full" ]; then egrep " bin | dat " $WORK \
  665.         >> shared/t_ship; fi;
  666.  
  667.     if [ "x$Lflag" = "x-l" -a "$LNGS" != "" ]; then    # add selected lang files
  668.         for LNG in `echo $LNGS $DEFL`; do
  669.             egrep "\.$LNG$|$LNG\....$" $WORK | sed -e '/cmp /d' -e '/ trm /d' \
  670.                 >> shared/t_ship;
  671.         done
  672.     fi;
  673.  
  674.     if [ "$Pflag" = -p ]; then        # add selected printer files
  675.         for File in `sed -n 's/\.ALL//gp' shared/.prlist \
  676.         | sed 's///' | sort -u | sed "y/$ABC/$abc/"`; do
  677.             egrep "$File\.all$" $WORK | sed 's/\.us\.all$/\.'$DEFL'\.all/' \
  678.             >> shared/t_ship; done
  679.         if [ "$Prod" = "1 " -o "$Prod" = "2 " ]; then
  680.             egrep "wp60dm03\.us\.all$|wp60hp01\.us\.all$|wp60ms01\.us\.all$|wp60ps01\.us\.all$|wp60ps02\.us\.all$" $WORK \
  681.             | sed 's/\.us\.all$/\.'$DEFL'\.all/' >> shared/t_ship; fi;
  682.         if [ "$Prod" = "1 " -o "$Prod" = "3 " ]; then
  683.             egrep "wpdm3\.all$|wphp1\.all$|wpms1\.all$|wpps1\.all$|wpps2\.all$" $WORK >> shared/t_ship; fi;
  684.     fi;
  685.  
  686.     if [ "$Tflag" = -t ]; then
  687.         if [ "$Prod" = "1 " -o "$Prod" = "3 " ]; then
  688.             if [ -f shared/.trlist ]; then        # add selected terminal drivers
  689.                 cat shared/.trlist | while read trsfile newname; do
  690.                     grep " $trsfile.trs"'$' $SHIP \
  691.                     | sed 's/ '$trsfile'\.trs$/ '$newname'\.trs/' \
  692.                     >> shared/t_ship
  693.                 done;
  694.             fi;
  695.             if [ "$FullPart" = "Full" ]; then
  696.                 sed -n -e '/^#ifdef.*'$Platform'$/,/^#endif.*'$Platform'$/p' \
  697.                 $SHIP | sed -e '/^#/d' -e '/^$/d' | grep " trm " \
  698.                 >> shared/t_ship;
  699.             fi;
  700.         fi;
  701.     fi;
  702.  
  703.     rm -f $WORK;
  704.     if   [ "$Prod" = "2 " ]; then        # remove character entries
  705.         sed '/ [c][sml]. /d' shared/t_ship > temp; mv temp shared/t_ship;
  706.     elif [ "$Prod" = "3 " ]; then        # remove gui entries
  707.         sed '/ [g][sml]. /d' shared/t_ship > temp; mv temp shared/t_ship; fi;
  708.  
  709.     if   [ "$Size" = "2 " ]; then        # remove max install entries
  710.         sed '/ [cgb][l]. /d' shared/t_ship > temp; mv temp shared/t_ship;
  711.     elif [ "$Size" = "3 " ]; then        # remove med/max install entries
  712.         sed '/ [cgb][lm]. /d' shared/t_ship > temp; mv temp shared/t_ship; fi;
  713.     sort -u shared/t_ship | sed '/ shared /d' > temp; mv temp shared/t_ship;
  714.  
  715.     sort -u shared/t_ship | egrep " bin | dat | lng | prn | trm " \
  716.         | awk '{ print $3"/"$2 }' | sed 's/^/'$Platform'\//' | sort -u \
  717.         > shared/t_file;
  718. }
  719.  
  720. do_media() {                        # See if we are CD or tape
  721.     if [ "$Vflag" = -v ]; then set -x; fi;
  722.     Dirs="bin dat prn/ch prn/gu trm";
  723.     for Lng in `egrep " lng/" shared/t_ship | sed 's/ * / /g' \
  724.         | cut -d" " -f3 | sed 's|lng/||g' | sort -u`; do
  725.         Dirs="$Dirs lng/$Lng";
  726.     done
  727.     DIRS=$Dirs;
  728.     if [ ! -f $FromDir/shared/ship ]; then    # names and dirs are not ok
  729.         DIRS=`echo $Dirs | sed "y/$abc/$ABC/"`; fi;
  730.  
  731.     PLATLN="[Pp][Ll][Aa][Tt].[Ll][Nn]";
  732.     mkdir $LinkDir/$Platform/prn $LinkDir/$Platform/lng;
  733.     for Dir in $DIRS; do
  734.         Test=`echo $Dir | sed 's/\/.*$//'`;
  735.         LNPLAT=`cat $FromDir/$PLATFORM/$Test/$PLATLN 2>/dev/null`;
  736.         if [ "$LNPLAT" = "" ]; then LNPLAT=$PLATFORM;
  737.         else
  738.             if [ ! -d $FromDir/$LNPLAT ]; then
  739.                 LNPLAT=`echo $LNPLAT | sed "y/$abc/$ABC/"`; fi;
  740.             if [ ! -d $FromDir/$LNPLAT ]; then
  741.                 echo "  Error: CD missing $LNPLAT"; continue; fi;
  742.         fi;
  743.         if [ -f $FromDir/shared/ship ]; then    # names and dirs are ok
  744.             ln -s $FromDir/$LNPLAT/$Dir $LinkDir/$Platform/$Dir; continue; fi;
  745.         echo $N "1$C" > $LinkDir/shared/l_pcnt;
  746.         DirLow=`echo $Dir | sed "y/$ABC/$abc/"`;
  747.         mkdir -p $LinkDir/$Platform/$DirLow;
  748.         cd $LinkDir/$Platform/$DirLow;
  749.         mylink $FromDir/$LNPLAT/$Dir;
  750.     done;
  751.     cd $LinkDir;
  752.     rm -f $LinkDir/shared/l_pcnt; touch $LinkDir/shared/l_pcnt;
  753. }
  754.  
  755. linkcopy() {                        # link or copy files to install dir
  756.     if [ "$Vflag" = -v ]; then set -x; fi;
  757.     if [ "$Dir1/$Nam1" = "$sDir1/$sNam1" -a -f $Idir/$sDir2/$sNam2 ]; then
  758.         rm -f $Idir/$Dir2/$Nam2;
  759.         ln $Idir/$sDir2/$sNam2 $Idir/$Dir2/$Nam2;
  760.     else
  761.         rm -f $Idir/$Dir2/$Nam2;
  762.         decomp $Platform/$Dir1/$Nam1 $Idir/$Dir2/$Nam2;
  763.         chmod $Perm $Idir/$Dir2/$Nam2;
  764.     fi
  765. }
  766.  
  767. do_inst() {                            # Install the files
  768.     if [ "$Vflag" = -v ]; then set -x; fi;
  769.     for Dir in $Idir/$WPBIN $Idir/$SHBIN; do
  770.         if [ -d $Dir ]; then chmod 755 $Dir; fi; done;
  771.     for Work in $Idir/$SHBIN/wplicense $Idir/$SHBIN/wpexc; do
  772.         if [ -f $Work ]; then $Work -k >> shared/log 2>>shared/log; fi; done;
  773.  
  774.     touch $LinkDir/.Execs
  775.     if [ ! -d "$Idir" ]; then mkdir $Idir 2>/dev/null; chmod 755 $Idir; fi;
  776.     for Dir in `sed 's/ * / /g' shared/t_ship | cut -d" " -f6 | sort -u`; do
  777.         if [ ! -d "$Idir/$Dir" ]; then
  778.             mkdir -p $Idir/$Dir; chmod 755 $Idir/$Dir; fi;
  779.     done
  780.  
  781.     fil_cnt=0;
  782.     tot_cnt=`wc -l shared/t_ship | sed 's/^ * //' | sed 's/ .*$//'`
  783.  
  784.     sDir1="junk"; sNam1="junk";
  785.     last_pcnt=0;
  786.     cat shared/t_ship | while read J1 Nam1 Dir1 Opt Perm Dir2 Nam2; do
  787.         Type=`echo $Opt | sed 's/^..//'`;
  788.         if   [ "$Type" = c ]; then linkcopy;
  789.         elif [ "$Type" = b ]; then
  790.             if [ -f $Idir/$Dir2/$Nam2 ]; then
  791.                 mv -f $Idir/$Dir2/$Nam2 $Idir/$Dir2/$Nam2.bk; fi;
  792.             linkcopy;
  793.         elif [ "$Type" = d ]; then
  794.             if [ ! -f $Idir/$Dir2/$Nam2 ]; then linkcopy; fi;
  795.         elif [ "$Type" = a ]; then
  796.             linkcopy; rm -rf $Idir/$Dir2/temp; mkdir $Idir/$Dir2/temp;
  797.             ( cd $Idir/$Dir2/temp; \
  798.             $LinkDir/$Platform/ins/wxar ../$Nam2; rm -f ../$Nam2;
  799.             chmod $Perm * .??* 2>/dev/null;
  800.             mv * .??* .. 2>>$LinkDir/shared/log;
  801.             cd ..; rmdir $Idir/$Dir2/temp );
  802.         elif [ "$Type" = t ]; then
  803.             linkcopy; ( cd $Idir/$Dir2; tar xf $Nam2; rm -f $Nam2;)
  804.         elif [ "$Type" = x ]; then
  805.             linkcopy; echo $Dir2/$Nam2 >> $LinkDir/.Execs;
  806.         elif [ "$Type" = z ]; then continue;
  807.         fi
  808.  
  809.         sDir1=$Dir1; sNam1=$Nam1; sDir2=$Dir2; sNam2=$Nam2;
  810.         fil_cnt=`expr $fil_cnt + 1`;
  811.         work=`expr $fil_cnt \* 100`;
  812.         pcnt=`expr $work / $tot_cnt`;
  813.         do_pcnt;
  814.     done
  815.     if [ "$Exec" = wpinstc ]; then echo; echo; fi;
  816.     if [ -f shared/cancel ]; then do_exit; fi;        # exit install.wp
  817. }
  818.  
  819. do_full() {
  820.     if [ "$FullPart" = "Part" ]; then return; fi;
  821.     echo $N "1$C" >> shared/l_pcnt;
  822. }
  823.  
  824. do_part() {
  825.     if [ "$FullPart" = "Full" ]; then return; fi;
  826.     echo $N "$eout$C" >> shared/l_pcnt; sleep 2;
  827. }
  828.  
  829. do_extr() {
  830.     if [ "$Vflag" = -v ]; then set -x; fi;
  831.  
  832.     if [ "$ecnt" = 0 -o "$ecnt" = "" ]; then return; fi;
  833.     einc=`expr 100 / $ecnt / 4`;        # percentage increment value
  834.     emod=`expr 100 % $einc`;
  835.     while [ "$emod" -gt 0 ]; do
  836.         eout="1$eout"; emod=`expr $emod - 1`; done;
  837.     do_part; eout=;
  838.     while [ "$einc" -gt 0 ]; do eout="1$eout"; einc=`expr $einc - 1`; done;
  839.  
  840.     if [ "$Icon" ]; then
  841.         do_part; (cd $Idir/$WPLIB; tar xf $LinkDir/shared/cde.dt)
  842.         do_part; (cd $Idir/$WPLIB/dt/appconfig/types/C; \
  843.             sed 's|<Idir>|'$Idir'|' wp8.dt > wp8.dt.new; \
  844.             mv wp8.dt.new wp8.dt;)
  845.         do_part;
  846.         if [ -x /usr/dt/bin/dtappintegrate ]; then
  847.             if [ "$User" = root ]; then
  848.                 /usr/dt/bin/dtappintegrate -s $Idir/$WPLIB 2>> shared/log; fi;
  849.             echo "Note: See $WPBIN/README.icon to complete icon processing.";
  850.         fi;
  851.         do_part;
  852.         do_full; fi;
  853.  
  854.     if [ "$Oman" ]; then
  855.         MANUAL="[Mm][Aa][Nn][Uu][Aa][Ll]";
  856.         MTAR="[Mm].[Tt][Aa][Rr]";
  857.         ARCMP="[Aa][Rr].[Cc][Mm][Pp]";
  858.         if [ "$Platform" = sco -o "$Platform" = sol86 ];
  859.             then Reader=xpdf; else Reader=acroread; fi;
  860.         do_part; mkdir $Idir/$Reader 2>/dev/null; chmod 755 $Idir/$Reader;
  861.         (cd $Idir/$WPLIB; tar xf $FromDir/$MANUAL/$MTAR);
  862.         do_part;
  863.         (cd $Idir/$Reader; rm -f /tmp/errs;
  864.             cp $FromDir/$MANUAL/$PLATFORM/$ARCMP ar.Z;
  865.             uncompress -c ar | tar xf - 2>/tmp/errs; rm -f ar.Z;);
  866.         grep -v "cannot create" /tmp/errs;
  867.         do_part; rm -f $Idir/$SHBIN/pdf_read
  868.         do_part; ln -s $Idir/$Reader/bin/$Reader $Idir/$SHBIN/pdf_read
  869.         if [ "$Platform" = linux ]; then
  870.             (cd $Idir/acroread/bin; \
  871.             sed "s|/wp_inst_dir|$Idir|" acroread > acroread.o; \
  872.             cp acroread.o acroread; rm -f acroread.o;) fi;
  873.         do_full; fi;
  874.  
  875.     if [ "$Net1" -o "$Net2" ]; then
  876.         NETSCAPE="[Nn][Ee][Tt][Ss][Cc][Aa][Pp][Ee]";
  877.         NSCMP="[Nn][Ss].[Cc][Mm][Pp]";
  878.         do_part; mkdir $Ndir 2>/dev/null; chmod 755 $Ndir;
  879.         do_part;
  880.         (cd $Ndir; rm -f /tmp/errs;
  881.             cp $FromDir/$NETSCAPE/$PLATFORM/$NSCMP ns.Z;
  882.             uncompress -c ns | tar xf - 2>/tmp/errs; rm -f ns.Z;);
  883.         do_part; rm -f $Idir/$SHBIN/webbrowser;
  884.         if [ "$Net1" ]; then ln -s $Ndir/netscape $Idir/$SHBIN/webbrowser;
  885.             else ln -s $Ndir/netscape_dns $Idir/$SHBIN/webbrowser; fi;
  886.         do_part;
  887.         do_full; fi;
  888. }
  889.  
  890. do_log() { echo $* >> $Idir/.install_log 2>>shared/log; }
  891.  
  892. do_dflt() {                            # Make adjustments for default language
  893.     if [ "$Vflag" = -v ]; then set -x; fi;
  894.     for Dir in $WPLIB $SHLIB; do \
  895.         echo $DEFL > $Idir/$Dir/.def.lang; done;
  896.     for file in $WPLIB/.wp8styles; do
  897.         if [ -f $Idir/$file.$DEFL ]; then
  898.             rm -f $Idir/$file; ln $Idir/$file.$DEFL $Idir/$file;
  899.         fi;
  900.     done;
  901.     for Dir in wpexpdocs wplearn wpmacros; do
  902.         if [ -d $Idir/$Dir/$DEFL ]; then
  903.             for File in `ls $Idir/$Dir/$DEFL`; do
  904.                 rm -f $Idir/$Dir/$File;
  905.                 ln $Idir/$Dir/$DEFL/$File $Idir/$Dir/$File;
  906.             done
  907.         fi
  908.     done
  909. }
  910.  
  911. dodest() {
  912.     if [ "$Vflag" = -v ]; then set -x; fi;
  913.     PTR=$Idir/$SHLIB/.ptrdest.ins; PTRV=shared/.ptrdest$Ver.ins;
  914.  
  915.     if [ -f $PTRV ]; then cp $PTRV $PTR;
  916.         $Idir/$SHBIN/$DSTEXC -F -a$Idir/$SHLIB/; cp $PTR $PTRV;
  917.     else $Idir/$SHBIN/$DSTEXC -F -au; fi;
  918.  
  919.     if [ -f $PTRV -o -f shared/.ptr3$Ver ]; then
  920.         if [ -f $PTRV ]; then tail +3c $PTRV > shared/.ptr2$Ver; fi;
  921.         cat shared/.ptr?"$Ver" 2>/dev/null > $PTR;
  922.         $Idir/$SHBIN/$PTREXC -PTRCHARINST $Prod; fi;
  923. }
  924.  
  925. ck_asgn() {                         # See if selected printers to assign
  926.     if [ -f $Idir/$WPBIN/instadm ]; then
  927.         $Idir/$WPBIN/instadm 2>>shared/log; rm -f $Idir/$WPBIN/instadm; fi;
  928.     if [ "$Vflag" = -v ]; then set -x; fi;
  929.     if [ "$DEST_INFO" ]; then cp $DEST_INFO $Idir/$SHLIB; fi; 
  930.     if [ "$Prod" = "1 " -o "$Prod" = "2 " ]; then
  931.         DSTEXC=xwpdest; PTREXC=xwppmgr; Ver="g"; dodest; fi;
  932.     if [ "$Prod" = "1 " -o "$Prod" = "3 " ]; then
  933.         DSTEXC=wpdest; PTREXC=ptrinst; Ver="c"; dodest; fi;
  934.     rm -f $Idir/$SHBIN/.ptrinst?.ins $Idir/$SHBIN/ptrinst;
  935. }
  936.  
  937. ck_magic() {                            # See if we update magic files
  938.     if [ "$Vflag" = -v ]; then set -x; fi;
  939.     if [ "$Mgic" = "1 " ]; then            # If running as root
  940.         if [ ! -f /etc/magic ]; then touch /etc/magic; fi;
  941.         WorkDir=`grep " wpmagic " $SHIP \
  942.             | sed 's/ * / /g' | cut -d" " -f6 | sort -u`;
  943.         WPMagic=$Idir/$WorkDir/wpmagic; # WordPerfect magic list
  944.         Magic=/etc/magic;                # System magic file
  945.         Search="WordPerfect type";        # Our key word to search for
  946.         WorkSch=`grep "$Search" $Magic`;
  947.  
  948.         if [ "$WorkSch" = "" ]; then
  949.             if [ ! -f $Magic.bk ]; then cp $Magic $Magic.bk; fi;
  950.             cat $WPMagic >> $Magic;
  951.         else ed -s $Magic << EOF >>shared/log
  952. /$Search
  953. kz
  954. /$Search
  955. 'z,.d
  956. . r $WPMagic
  957. w
  958. q
  959. EOF
  960.         fi
  961.     fi
  962. }
  963.  
  964. ck_boot() {                                    # Check for boot file update
  965.     if [ "$Vflag" = -v ]; then set -x; fi;
  966.     if [ "$Platform" = rs6000 ]; then
  967.         if [ "`grep rc.wp /etc/inittab`" = "" ]; then
  968.             echo "rc.wp:2:once:/etc/rc.wp" >> /etc/inittab; fi;
  969.     fi;
  970.     if [ "$Platform" = sol86 ]; then
  971.         if [ "`grep '^'wp: /etc/inittab`" = "" ]; then
  972.             echo "wp:2:once:/etc/rc.wp" >> /etc/inittab; fi;
  973.     fi;
  974.     if [ "$Edrc" != "1 " -o "$Flex" = "1 " ]; then return; fi
  975.     if [ "$Lsvr" != "$UNAME_N" ]; then return; fi;
  976.  
  977.     for File in `grep "$Platform Bootfile" shared/l_info | cut -d" " -f3-`; do
  978.         if [ -f $File ]; then break; fi;    # found
  979.     done;
  980.     if [ ! -f $File ]; then return; fi;        # none found
  981.  
  982.     BootVer="wp8"
  983.     BootWrk=`grep "wplicense -s" $File 2>>shared/log | grep "#$BootVer"`
  984.     EditAdd=Edit; if [ "$BootWrk" = "" ]; then EditAdd=Add;    fi;
  985.     if [ -f $File.bk ]; then cp $File $File.bk; fi;
  986.  
  987.     echo > SvrTemp1;                        # create wplicense lines
  988.     echo "# Startup license daemon" >> SvrTemp1;
  989.     echo "if [ -f $Idir/$SHBIN/wplicense ]; then" > SvrTemp2;
  990.     echo "    $Idir/$SHBIN/wplicense -s   #$BootVer" >> SvrTemp2;
  991.     echo "fi" > SvrTemp3;
  992.  
  993.     if [ "$EditAdd" = Add ]; then cat SvrTemp* >> $File;
  994.     elif [ "$EditAdd" = Edit ]; then ed -s $File << EOF >> shared/log;
  995. /wplicense -s   #
  996. .-1,.d
  997. .-1r ./SvrTemp2
  998. w
  999. q
  1000. EOF
  1001.     fi;
  1002.     rm -f SvrTemp*;                    # clean up
  1003. }
  1004. wpzm() {
  1005.     touch $Idir/$SHLIB/.wp8.lm; chmod 644 $Idir/$SHLIB/.wp8.lm;
  1006.     sed -e 's/<lnum>/'"$Lnum"'/' -e 's/ 0 / '$Lses' /' $Idir/$SHLIB/wpdm.dat \
  1007.     > $Idir/$SHLIB/license.dat;
  1008. }
  1009. do_excs() {                            # Execute programs specified.
  1010.     if [ "$Vflag" = -v ]; then set -x; fi;
  1011.     for File in `cat $LinkDir/.Execs`; do
  1012.         if [ "$File" = $SHBIN/wplicense ]; then
  1013.             if [ ! -f $Idir/$SHBIN/wpcreatlic ]; then continue; fi;
  1014.             if [ "$Flex" = "1 " ]; then wpzm; continue; fi;
  1015.             $Idir/$SHBIN/wpcreatlic -u $Lses "$Lnum" $Lsvr 2>>shared/log;
  1016.             chmod ugo+r $Idir/$SHLIB/license.dat;
  1017.             chmod u+w $Idir/$SHLIB/license.dat;
  1018.             if [ "$User" = root -a "$Lsvr" = "$UNAME_N" ]; then
  1019.                 $Idir/$SHBIN/wplicense -k \
  1020.                     >> shared/log 1>>shared/log 2>>shared/log;
  1021.                 sleep 2;
  1022.                 $Idir/$SHBIN/wplicense -s 2>>shared/log;
  1023.             fi;
  1024.         elif [ "$File" = $SHBIN/wpexc ]; then
  1025.             $Idir/$File -k 2>>shared/log; $Idir/$File -s 2>>shared/log;
  1026.         elif [ "$File" = $SHBIN/wpcreatlic ]; then
  1027.             continue;
  1028.         else
  1029.             $Idir/$File 2>>shared/log; fi;
  1030.     done
  1031.     if [ -f $LinkDir/shared/l_l ]; then wpzm; fi
  1032. }
  1033.  
  1034. ck_ping() {                            # See if tcpip is running
  1035.     if [ "$Vflag" = -v ]; then set -x; fi;
  1036.     if [ "$flex" = "" ]; then return; fi;
  1037.     for Ping in /etc/ping /usr/etc/ping /bin/ping /usr/bin/ping /usr/sbin/ping; do
  1038.         if [ -f $Ping ]; then break; else Ping=; fi;
  1039.     done
  1040.  
  1041.     if [ "$Platform" = rs6000 -o "$Platform" = sco \
  1042.         -o "$Platform" = linux -o "$Platform" = netwindr ];
  1043.     then PingParms="-q -c 1 localhost"; else PingParms="localhost 8 1"; fi;
  1044.  
  1045.     if [ "$Ping" != "" ]; then
  1046.         PingData=`$Ping $PingParms \
  1047.             | egrep "alive| 0% packet loss" 2>>shared/log`; fi;
  1048.  
  1049.     if [ "$PingData" = "" ]; then
  1050.         touch $Idir/$SHLIB/.wp8.lm; fi;
  1051. }
  1052.  
  1053. do_reg() {                            # Try to register the product
  1054.     if [ "$Vflag" = -v ]; then set -x; fi;
  1055.     Display=`echo $DISPLAY`;
  1056.     NetCheck=`$Ping www.sdcorp.com | grep alive`;
  1057.     if [ "$Display" != "" -a -f $Idir/$WPBIN/xwp -a "$NetCheck" != "" ]; then
  1058.         $Ndir/netscape www.sdcorp.com; fi;
  1059. }
  1060.  
  1061. do_readme() {
  1062.     if [ "$Vflag" = -v ]; then set -x; fi;
  1063.     Ename="wp or xwp";
  1064.     if [ "$Prod" = "2 " ]; then Ename=`echo $Ename | sed 's/wp or //'`; fi;
  1065.     if [ "$Prod" = "3 " ]; then Ename=`echo $Ename | sed 's/ or xwp//'`; fi;
  1066.     rm -f shared/m_read;
  1067.     sed -e 's|<Idir>|'$Idir'|' -e 's|<Exec>|'"$Ename"'|' shared/l_read \
  1068.     > shared/m_read;
  1069.  
  1070.     if [ -f $Idir/$WPBIN/README.$Eula ]; then
  1071.         mv $Idir/$WPBIN/README.$Eula $Idir/$WPBIN/README.lic; fi;
  1072.     if [ -d "$Idir/$WPBIN" ]; then rm -f $Idir/$WPBIN/README.?; fi;
  1073.  
  1074.     rm -f shared/t_read;
  1075.     Help_Reads=`grep HELP_READS= shared/m_read | sed 's/.*=//'`
  1076.     ls -1 $Idir/$WPBIN/README* | grep -n . | sed 's/:/ /' \
  1077.     | while read Count ReadMe; do
  1078.         sed -n 1'p' $ReadMe | sed 's/$//' >> shared/t_read;
  1079.         rm -f shared/h_$Help_Reads$Count;
  1080.         ln -s $ReadMe shared/h_$Help_Reads$Count;
  1081.     done;
  1082.  
  1083.     sleep 1; echo "123456789" >> shared/l_pcnt; sleep 2;
  1084.     if [ "$Exec" = wpinstc ]; then Values=1; else Values=; fi;
  1085.     Menu=read; runprog;
  1086.     rm -f shared/l_pcnt;
  1087. }
  1088.  
  1089. do_exit() {                            # Clean up temp files and exit
  1090.     if [ "$Vflag" = -v ]; then set -x; fi;
  1091.     if [ -f shared/log ]; then
  1092.         echo `date` >> shared/log; echo >> shared/log; fi;
  1093.     if [ -f shared/l_pcnt ]; then
  1094.         sleep 2; echo "123456789" >> shared/l_pcnt; sleep 2; fi;
  1095.     if [ -d $Idir/$WPLIB ]; then
  1096.         touch $Idir/$WPLIB/log 2>/dev/null;
  1097.         cat shared/log >> $Idir/$WPLIB/log 2>/dev/null; fi;
  1098.     for Dir in $Idir/$SHLIB $Idir/$WPLIB; do
  1099.         if [ -d $Dir ]; then chmod 777 $Dir; fi; done
  1100.     if [ -f $Idir/$SHLIB/.wpc.admin ]; then
  1101.         chmod 666 $Idir/$SHLIB/.wpc.admin; fi;
  1102.     if [ "$Vflag" = -v ]; then
  1103.         echo; echo $N "Press any key to clean up. $C"; read done; fi
  1104.     cp shared/wpdata $FromDir/.wpdata 2>/dev/null;
  1105.     if [ -f $FromDir/shared/cleanup ]; then
  1106.         for FD in MANUAL manual NETSCAPE netscape SDK sdk \
  1107.         $Platform $PLATFORM INSTALL.WP \
  1108.         install.wp REMOVE.WP remove.wp shared SHARED; do
  1109.             rm -rf $FromDir/$FD 2>/dev/null;
  1110.         done; fi;
  1111.     cd $TMPDIR; rm -rf $TMPDIR/WpTmP$Version &
  1112.     if [ "$Remove" = Remove -a "$RetCode" != $Cancel ]; then
  1113.         if [ "$Exec" = wpinstc ]; then echo; fi; fi;
  1114.     if [ "$RetCode" = $Cancel ]; then
  1115.         echo; echo "$CMsg"; echo; exit 1;
  1116.     else echo; echo "$EMsg"; echo; exit; fi;
  1117. }
  1118.  
  1119. # MAIN entry point
  1120.  
  1121. ck_cddir;
  1122. do_first; echo $N ".$C";            # Initialize information
  1123. do_plats;                            # Get the platform information
  1124. ck_media; echo $N ".$C";            # Initialize for tape or cd
  1125. mk_plats;                            # Make the platform list
  1126. do_parms; echo $N ".$C"; echo;    # Process command line parameters
  1127.  
  1128. do_menus;                            # Loop through the menu list
  1129.  
  1130. do_stat;                            # Start the percent complete status
  1131. mk_list;                            # Build a list of files to install
  1132. do_media;                            # See if we are CD or tape
  1133. do_inst;                            # Install the files
  1134. do_extr;                            # Add extra features to the install
  1135. if [ "$FullPart" = "Full" ]; then
  1136.     do_dflt;                        # Make adjustments for default language
  1137.     do_excs;                        # Execute programs specified
  1138.     ck_asgn;                        # See if selected printers to assign
  1139.     ck_magic;                        # See if we update magic files
  1140.     ck_boot;                        # See if boot file update is requested
  1141.     ck_ping;                        # See if tcpip is running
  1142.     do_readme;                        # Display readme files
  1143. fi
  1144. do_exit DONE;                        # Clean up temp files and exit
  1145.  
  1146.