#!/bin/bash

# modified on Jan 12th, 1997 so that this step is not
# absolutely necessary. Incase netscape wrapper is
# already installed.

# update: August 10th, 1997. Changed 'if [ -f "/tmp/$i" ]; then'
# just below by replacing the -f with a -e. I think this will fix
# the case when someone only makes a symbolic link from /tmp
# to the netscape .tar.gz file.

# update: Nov 18th. Added support for 128 bit encription US version
# of netscape software (communicator, navigator etc.) Fix provided
# by adam@lynx.msc.cornell.edu

dlist='4.04 4.04n 4.03 4.03n 3.04 3.01 4.02b7'
flist='communicator-v404-*.x86-unknown-linux2.0.tar.gz navigator-v404-*.x86-unknown-linux2.0.tar.gz communicator-v403-*.x86-unknown-linux2.0.tar.gz navigator-v403-*.x86-unknown-linux2.0.tar.gz netscape-v304-*.x86-unknown-linux-elf.tar.gz netscape-v301-*.x86-unknown-linux-elf.tar.gz communicator-v402b7-*.x86-unknown-linux2.0.tar.gz'
def_nsv=none

vfound=none

let j=0
for i in $flist
do
  let j=j+1
  dfound=$(echo $dlist | cut -f$j -d' ')
  if [ -e /tmp/$i ]; then
    vfound=$dfound
    cfound=$(echo $dfound | grep 4.0 | wc -w)
    if [ -f /usr/lib/X11/netscape/$dfound/netscape ]; then
      rm -rf /usr/lib/X11/netscape/$dfound;
    fi
    echo Installing version $vfound
    nstarfn=$i
    if [ ! -d /usr/lib/X11/netscape/$dfound ]; then
      mkdir -p /usr/lib/X11/netscape/$dfound
    fi
    (cd /usr/lib/X11/netscape/$dfound;tar zxvf /tmp/$nstarfn)
    if [ $cfound = 1 ]; then
      echo installing a communicator .nif files
      lwd=$(pwd)
      cd /usr/lib/X11/netscape/$dfound
      for i in *.nif
      do
       echo untaring $i
       tar zxf $i
      done
      cd $lwd
    fi
  else
    if [ -f /usr/lib/X11/netscape/$dfound/netscape ]; then
      vfound=$i
      echo Found previous netscape install version $dfound
    fi
  fi
done

if [ $vfound = none ]; then

  echo Error during install, netscape tar file not found or
  echo previous netscape wrapper $vlist installation not found
  echo Looking for any of the following files or directories

  let j=0
  for i in $flist
  do
    let j=j+1
    dfound=$(echo $dlist | cut -f$j -d' ')
    echo /tmp/$i
    echo /usr/lib/X11/netscape/$dfound/netscape
  done

  exit

fi

