home *** CD-ROM | disk | FTP | other *** search
- #!/bin/sh
- #################################################################################
- # #
- # NETSCAPE Platform-Independent Software Installation #
- # Copyright (c) 1997 by Netscape Communications Corporation #
- # #
- # File name: ns-install #
- # #
- # Version: 0.9 #
- # #
- # Description: This script installs Netscape software on a #
- # workstation and creates or updates the Version #
- # Registry to allow for the future use of Automatic #
- # Software Download (ASD). #
- # #
- # Usage: To execute the script, type: #
- # #
- # ./ns-install [ -v ] #
- # #
- # Where -v turns on the verbose flag for the #
- # interesting tar commands. #
- # #
- # Exit codes: 0 Successful completion #
- # 1 Package file is missing #
- # 2 Can't create the target directory #
- # 3 Unable to register the product #
- # #
- # Author(s): Brian Ostrom (briano@netscape.com) #
- # #
- # Notes: * Will use MOZILLA_HOME as the default if it is set. #
- # #
- #################################################################################
- #
- PACKAGE="netscape-v404.nif"
- PRODUCT="Communicator"
- RELEASE="4.04"
- BLDVERS="4.04.0.97310"
-
- TESTFILE="testfile.ns.$$"
- REG_INFILE="nsreg.$$"
- VREGISTRY="registry"
- VR_PRODSTR="${PRODUCT}"
-
- #
- # Do not set tar option verbose, unless -v flag is specified.
- #
- case $1 in
- -v)
- v="v"
- ;;
-
- *)
- v=""
- ;;
- esac
-
- echo ""
- echo "=================================================================="
- echo ""
- echo " NETSCAPE Platform-Independent Software Installation"
- echo " For ${PRODUCT} release ${RELEASE}"
- echo " Copyright (c) 1997 by Netscape Communications Corp."
- echo ""
- echo "=================================================================="
- echo ""
- echo ""
-
- #
- # Make sure the package we expect is where we expect it.
- #
- if test ! -f ${PACKAGE}
- then
- echo "ERROR: ${PACKAGE}: no such file"
- exit 1
- fi
-
- #
- # If MOZILLA_HOME is set, assume that is the place to install.
- #
- if test ! -z "${MOZILLA_HOME}"
- then
- INSTALL_DIR="${MOZILLA_HOME}"
- else
- if test -d /opt
- then
- INSTALL_DIR="/opt/netscape"
- else
- INSTALL_DIR="/usr/local/netscape"
- fi
- fi
-
- #
- # See if we have to use the lame SYS-V echo command flags.
- #
- if test "`/bin/echo 'blah\c'`" = "blah\c"
- then
- EFLAG="-n"
- ENDER=""
- else
- EFLAG=""
- ENDER="\c"
- fi
- ECHO="/bin/echo ${EFLAG}"
-
- #
- # Even though the user has already used gzip to extract the file (or
- # we wouldn't be here), make sure we can find it.
- #
- GZIP="gzip"
- flag=1
- while test ${flag} -eq 1
- do
- ${GZIP} -h >/dev/null 2>&1
- if test $? -ne 0
- then
- echo ""
- echo "Unable to locate 'gzip' in your path. Please provide the fully-qualified"
- echo "directory in which it can be found."
- echo ""
- ${ECHO} "Directory containing the 'gzip' binary: ${ENDER}"
- read GZIP_DIR
- GZIP="${GZIP_DIR}/gzip"
- else
- flag=0
- fi
- done
-
- echo ""
- echo "Please specify the directory path under which the software will be"
- echo "installed. The default directory is ${INSTALL_DIR}."
- echo ""
- flag=1
- while test ${flag} -eq 1
- do
- ${ECHO} "Location for ${PRODUCT} software [${INSTALL_DIR}]: ${ENDER}"
- read TARGET
- if test -z "${TARGET}"
- then
- TARGET="${INSTALL_DIR}"
- fi
- if test ! -z "`echo ${TARGET} | grep '~'`"
- then
- TARGET=`echo ${TARGET} | sed "s:~:${HOME}:"`
- fi
-
- flag=0
- if test ! -d ${TARGET}
- then
- echo ""
- ${ECHO} "${TARGET}: No such directory. Do you wish to create it? (y/n)[y] ${ENDER}"
- read check
- if test "${check}" = "n" -o "${check}" = "N"
- then
- flag=1
- else
- #
- # The -p flag may cause an error on some HP-UX systems.
- # Removing the -p will work for 'basename TARGET' as long
- # as 'dirname TARGET' exists.
- #
- mkdir -p ${TARGET}
- if test $? -ne 0
- then
- echo "ERROR: Problem creating ${TARGET}"
- exit 2
- fi
- fi
- else
- echo ""
- echo "Existing '${TARGET}' directory found."
- echo ""
- echo "The existing contents may be modified or replaced if you install in"
- echo "this directory. If you choose not to install in '${TARGET}',"
- echo "you will be prompted for a different directory."
- echo ""
- ${ECHO} "Do you wish to continue with the installation in '${TARGET}'? (y/n)[y] ${ENDER}"
- read check
- if test "${check}" = "n" -o "${check}" = "N"
- then
- flag=1
- fi
- fi
-
- if test ${flag} -eq 0
- then
- (echo "Write test." 2>/dev/null > ${TARGET}/${TESTFILE}) 2>/dev/null
- if test $? -ne 0
- then
- echo ""
- echo "You do not have write permission in ${TARGET}."
- echo "Change the permissions, or select another directory, and try again."
- echo ""
- flag=1
- else
- /bin/rm -f ${TARGET}/${TESTFILE}
- fi
- fi
- done
-
- #
- # Begin the installation.
- #
- echo ""
- echo ""
- echo "Installing ${PRODUCT} files..."
-
- #
- # Make a list of the files in this package, so we can check for
- # existing files with the same names and save them.
- #
- FILELIST="`${GZIP} -dc ${PACKAGE} | tar -tvf - | awk '{print $NF}'`"
-
- #
- # Keep a log of this installation for reference.
- #
- LOGFILE="ns-install.log-$$"
- date > ${LOGFILE}
- echo "Files installed:" >> ${LOGFILE}
- echo "================" >> ${LOGFILE}
-
- #
- # Check for existing files and move them out of the way.
- #
- for i in ${FILELIST}
- do
- echo "${i}" >> ${LOGFILE}
- if test ! -d ${TARGET}/${i}
- then
- (cd ${TARGET}; \
- /bin/rm -f ${i}.old; \
- if test -f ${i}; then \
- echo " ==> moving existing '${TARGET}/${i}' to '${TARGET}/${i}.old'"; \
- mv ${i} ${i}.old; \
- fi)
- fi
- done
-
- #
- # Actually install the package in TARGET.
- #
- ${GZIP} -dc ${PACKAGE} | (cd ${TARGET}; tar -x${v}f -)
-
- /bin/rm -f ${REG_INFILE}
- echo "${VR_PRODSTR},${BLDVERS},${TARGET}" > ${REG_INFILE}
-
- #
- # Install the Java class ARchive (JAR) files.
- #
- if test "${PRODUCT}" = "Communicator" -o "${PRODUCT}" = "Navigator"
- then
- echo ""
- echo "Installing ${PRODUCT} Java files..."
- if test ! -d ${TARGET}/java/classes
- then
- (cd ${TARGET}; mkdir -p java/classes)
- fi
- for i in *.jar
- do
- if test -f ${TARGET}/java/classes/${i}
- then
- echo " ==> moving existing '${TARGET}/java/classes/${i}' to '${TARGET}/java/classes/${i}.old'"
- /bin/rm -f ${TARGET}/java/classes/${i}.old
- mv ${TARGET}/java/classes/${i} ${TARGET}/java/classes/${i}.old
- fi
- tar -cf - ${i} | (cd ${TARGET}/java/classes; tar -xf -)
- echo "${i}" >> ${LOGFILE}
- /bin/rm -f ${TARGET}/${i} ./${i}
- echo "${i},${BLDVERS},${TARGET}/java/classes" >> ${REG_INFILE}
- done
- #
- # Is this a virgin install? If so, create the .netscape dir
- # and put the default bookmark file in it.
- #
- if test ! -d ${HOME}/.netscape
- then
- # New install, or upgrade from 0.x or 1.x.
- mkdir ${HOME}/.netscape
- cp ${TARGET}/bookmark.htm ${HOME}/.netscape/bookmarks.html
- echo "${HOME}/.netscape/bookmarks.html" >> ${LOGFILE}
- fi
- fi
-
- echo ""
- echo "Installing additional component files..."
- for pkg in *.nif
- do
- if test "${pkg}" = "${PACKAGE}"
- then
- continue
- fi
- #
- # Don't need to save the old files for these components,
- # since the new ones are backwards-compatible.
- #
- case ${pkg} in
- nethelp*)
- /bin/rm -rf ${TARGET}/nethelp
- echo "nethelp/" >> ${LOGFILE}
- ;;
- spellchk*)
- /bin/rm -rf ${TARGET}/spell
- echo "spell/" >> ${LOGFILE}
- ;;
- esac
- ${GZIP} -dc ${pkg} | (cd ${TARGET}; tar -x${v}f -)
- echo "${pkg},${BLDVERS},${TARGET}" >> ${REG_INFILE}
- /bin/rm -f ${pkg}
- done
-
- #
- # Install the vreg binary in the TARGET directory.
- #
- if test -f ${TARGET}/vreg
- then
- /bin/rm -f ${TARGET}/vreg.old
- mv ${TARGET}/vreg ${TARGET}/vreg.old
- # Handle the case where TARGET == . (meaning we just moved the file we just installed).
- if test ! -f ./vreg
- then
- mv ${TARGET}/vreg.old ${TARGET}/vreg
- else
- mv ./vreg ${TARGET}/vreg
- fi
- else
- mv ./vreg ${TARGET}/vreg
- fi
-
- #
- # Register the product so Automatic Software Download can work.
- # Just keeps track of the product name and version number for
- # comparison purposes later when newer versions become available.
- # Not necessary to run the product, but ASD will not be possible
- # without it....
- #
- echo ""
- echo "Registering ${PRODUCT} ${RELEASE}..."
- ${TARGET}/vreg ${TARGET}/${VREGISTRY} ${REG_INFILE} >/dev/null 2>&1
- if test $? -ne 0
- then
- echo "ERROR: Installation completed, but unable to update/create the product"
- echo " version registry."
- echo ""
- echo " If you are installing ${PRODUCT} from a platform other than"
- echo " that for which this package is intended, 'vreg' will not be"
- echo " able to run. If this is the case, you may run 'vreg' manually"
- echo " (to enable ASD) on the appropriate platform using the following"
- echo " commands:"
- echo ""
- awk '{printf("\techo \"%s\" >>/tmp/infile\n", $0)}' ${REG_INFILE}
- echo " ${TARGET}/vreg ${TARGET}/${VREGISTRY} /tmp/infile"
- echo ""
- /bin/rm -f ns-install ${PACKAGE} ${REG_INFILE} core
- exit 3
- fi
-
- echo ""
- echo ""
- echo "The Netscape ${PRODUCT} software installation is complete."
- echo ""
- echo ""
-
- #
- # Get rid of the trash.
- #
- /bin/rm -f ns-install ${PACKAGE} ${REG_INFILE}
-
- echo ""
- exit 0
-