home *** CD-ROM | disk | FTP | other *** search
/ Magazyn WWW 1999 April / cd24-www.iso / prog / linux / comm45 / netscape.linux.tar.gz / communicator-v45-export.x86-unknown-linux2.0.tar / communicator-v45.x86-unknown-linux2.0 / ns-install < prev    next >
Text File  |  1998-10-13  |  10KB  |  423 lines

  1. #!/bin/sh
  2. #################################################################################
  3. #                                        #
  4. #    NETSCAPE Platform-Independent Software Installation            #
  5. #    Copyright (c) 1997,1998 by Netscape Communications Corporation        #
  6. #                                        #
  7. #    File name:    ns-install                        #
  8. #                                        #
  9. #    Revision:    1.47                            #
  10. #                                        #
  11. #    Description:    This script installs Netscape software on a        #
  12. #            workstation and creates or updates the Version        #
  13. #            Registry to allow for the future use of Automatic    #
  14. #            Software Download (ASD).                #
  15. #                                        #
  16. #    Usage:        To execute the script, type:                #
  17. #                                        #
  18. #                ./ns-install [ -o ] [ -v ]            #
  19. #                                        #
  20. #            Where -v turns on the verbose flag for the        #
  21. #            interesting tar commands.  The -o flag is not        #
  22. #            supported on all versions of tar, so use it with    #
  23. #            caution.                        #
  24. #                                        #
  25. #    Exit codes:    0    Successful completion                #
  26. #            1    Package file is missing                #
  27. #            2    Can't create the target directory        #
  28. #            3    Unable to register the product            #
  29. #                                        #
  30. #    Author(s):    Brian Ostrom (briano@netscape.com)            #
  31. #                                        #
  32. #    Notes:        * Will use MOZILLA_HOME as the default if it is set.    #
  33. #                                        #
  34. #################################################################################
  35. #
  36. PACKAGE="netscape-v45.nif"
  37. PRODUCT="Communicator"
  38. RELEASE="4.5"
  39. BLDVERS="4.5.0.98286"
  40.  
  41. TESTFILE="testfile.ns.$$"
  42. REG_INFILE="nsreg.$$"
  43. VREGISTRY="registry"
  44. VR_PRODSTR="${PRODUCT}"
  45.  
  46. #
  47. # Process any arguments.  Let users see verbose output from tar (does
  48. # anyone even care?), and (for _some_ versions of tar) override the file
  49. # ownership when installing as root, if they wish.
  50. #
  51. TAR_OPTIONS=""
  52. while test $# -ne 0
  53. do
  54.     case $1 in
  55.         -o)
  56.             TAR_OPTIONS="${TAR_OPTIONS}o"
  57.             ;;
  58.  
  59.         -v)
  60.             TAR_OPTIONS="${TAR_OPTIONS}v"
  61.             ;;
  62.  
  63.         *)
  64.             ;;
  65.     esac
  66.     shift
  67. done
  68.  
  69. echo ""
  70. echo "=================================================================="
  71. echo ""
  72. echo "       NETSCAPE Platform-Independent Software Installation"
  73. echo "                 For ${PRODUCT} release ${RELEASE}"
  74. echo "       Copyright (c) 1997 by Netscape Communications Corp."
  75. echo ""
  76. echo "=================================================================="
  77. echo ""
  78. echo ""
  79.  
  80. #
  81. # Make sure the package we expect is where we expect it.
  82. #
  83. if test ! -f ${PACKAGE}
  84. then
  85.     echo "ERROR: ${PACKAGE}: no such file"
  86.     exit 1
  87. fi
  88.  
  89. #
  90. # If MOZILLA_HOME is set, assume that is the place to install.
  91. # Otherwise, make an educated guess at the "right" default
  92. # directory.
  93. #
  94. if test ! -z "${MOZILLA_HOME}"
  95. then
  96.     INSTALL_DIR="${MOZILLA_HOME}"
  97. else
  98.     if test -d /opt
  99.     then
  100.         INSTALL_DIR="/opt/netscape"
  101.     else
  102.         INSTALL_DIR="/usr/local/netscape"
  103.     fi
  104. fi
  105.  
  106. #
  107. # See if we have to use the lame SYS-V echo command flags.
  108. #
  109. if test "`/bin/echo 'blah\c'`" = "blah\c"
  110. then
  111.     EFLAG="-n"
  112.     ENDER=""
  113. else
  114.     EFLAG=""
  115.     ENDER="\c"
  116. fi
  117. ECHO="/bin/echo ${EFLAG}"
  118.  
  119. #
  120. # Even though the user has already used gzip to extract the file (or
  121. # we wouldn't be here), make sure we can find it.
  122. #
  123. GZIP="gzip"
  124. flag=1
  125. while test ${flag} -eq 1
  126. do
  127.     ${GZIP} -h >/dev/null 2>&1
  128.     if test $? -ne 0
  129.     then
  130.         echo ""
  131.         echo "Unable to locate 'gzip' in your path.  Please provide the fully-qualified"
  132.         echo "directory in which it can be found."
  133.         echo ""
  134.         ${ECHO} "Directory containing the 'gzip' binary: ${ENDER}"
  135.         read GZIP_DIR
  136.         GZIP="${GZIP_DIR}/gzip"
  137.     else
  138.         flag=0
  139.     fi
  140. done
  141.  
  142. echo ""
  143. echo "Please specify the directory path under which the software will be"
  144. echo "installed.  The default directory is ${INSTALL_DIR}, but you may"
  145. echo "install anywhere you wish (if you have permission to do so)."
  146. echo ""
  147. flag=1
  148. while test ${flag} -eq 1
  149. do
  150.     ${ECHO} "Location for ${PRODUCT} software [${INSTALL_DIR}]: ${ENDER}"
  151.     read TARGET
  152.     if test -z "${TARGET}"
  153.     then
  154.         TARGET="${INSTALL_DIR}"
  155.     fi
  156.     if test ! -z "`echo ${TARGET} | grep '~'`"
  157.     then
  158.         TARGET=`echo ${TARGET} | sed "s:~:${HOME}:"`
  159.     fi
  160.  
  161.     flag=0
  162.     if test ! -d ${TARGET}
  163.     then
  164.         echo ""
  165.         ${ECHO} "${TARGET}: No such directory.  Do you wish to create it? (y/n)[y] ${ENDER}"
  166.         read check
  167.         if test "${check}" = "n" -o "${check}" = "N"
  168.         then
  169.             flag=1
  170.         else
  171.             #
  172.             # The -p flag may cause an error on some HP-UX systems.
  173.             # Removing the -p will work for 'basename TARGET' as long
  174.             # as 'dirname TARGET' exists.
  175.             #
  176.             mkdir -p ${TARGET}
  177.             if test $? -ne 0
  178.             then
  179.                 echo "ERROR: Problem creating ${TARGET}"
  180.                 exit 2
  181.             fi
  182.         fi
  183.     else
  184.         echo ""
  185.         echo "Existing '${TARGET}' directory found."
  186.         echo ""
  187.         echo "The existing contents may be modified or replaced if you install in"
  188.         echo "this directory.  If you choose not to install in '${TARGET}',"
  189.         echo "you will be prompted for a different directory."
  190.         echo ""
  191.         ${ECHO} "Do you wish to install in '${TARGET}'? (y/n)[y] ${ENDER}"
  192.         read check
  193.         if test "${check}" = "n" -o "${check}" = "N"
  194.         then
  195.             flag=1
  196.         fi
  197.     fi
  198.  
  199.     if test ${flag} -eq 0
  200.     then
  201.         (echo "Write test." 2>/dev/null > ${TARGET}/${TESTFILE}) 2>/dev/null
  202.         if test $? -ne 0
  203.         then
  204.             echo ""
  205.             echo "You do not have write permission in ${TARGET}."
  206.             echo "Change the permissions, or select another directory, and try again."
  207.             echo ""
  208.             flag=1
  209.         else
  210.             /bin/rm -f ${TARGET}/${TESTFILE}
  211.         fi
  212.     fi
  213. done
  214.  
  215. #
  216. # Begin the installation.
  217. #
  218. echo ""
  219. echo ""
  220. echo "Installing ${PRODUCT} files..."
  221.  
  222. #
  223. # Make a list of the files in this package, so we can check for
  224. # existing files with the same names and save them.
  225. #
  226. FILELIST="`${GZIP} -dc ${PACKAGE} | tar -tvf - | awk '{print $NF}'`"
  227.  
  228. #
  229. # Keep a log of this installation for reference.
  230. #
  231. LOGFILE="ns-install.log-$$"
  232. date > ${LOGFILE}
  233. echo "Files installed:" >> ${LOGFILE}
  234. echo "================" >> ${LOGFILE}
  235.  
  236. #
  237. # Check for existing files and move them out of the way.
  238. #
  239. if test -d ${TARGET}/java/classes
  240. then
  241.     echo " ==> moving existing '${TARGET}/java/classes' to '${TARGET}/java/classes.old'"; \
  242.     /bin/rm -rf ${TARGET}/java/classes.old
  243.     mv ${TARGET}/java/classes ${TARGET}/java/classes.old
  244. fi
  245. for i in ${FILELIST}
  246. do
  247.     echo "${i}" >> ${LOGFILE}
  248.     if test ! -d ${TARGET}/${i}
  249.     then
  250.         (cd ${TARGET}; \
  251.          /bin/rm -f ${i}.old; \
  252.          if test -f ${i}; then \
  253.             echo " ==> moving existing '${TARGET}/${i}' to '${TARGET}/${i}.old'"; \
  254.             mv ${i} ${i}.old; \
  255.          fi)
  256.     fi
  257. done
  258.  
  259. #
  260. # Actually install the package in TARGET.
  261. #
  262. ${GZIP} -dc ${PACKAGE} | (cd ${TARGET}; tar -x${TAR_OPTIONS}f -)
  263.  
  264. /bin/rm -f ${REG_INFILE}
  265. echo "${VR_PRODSTR},${BLDVERS},${TARGET}" > ${REG_INFILE}
  266.  
  267. #
  268. # Install the Java class ARchive (JAR) files.
  269. #
  270. if test "${PRODUCT}" = "Communicator" -o "${PRODUCT}" = "Navigator"
  271. then
  272.     echo ""
  273.     echo "Installing ${PRODUCT} Java files..."
  274.     if test ! -d ${TARGET}/java/classes
  275.     then
  276.         (cd ${TARGET}; mkdir -p java/classes)
  277.     fi
  278.     for i in *.jar
  279.     do
  280.         if test -f ${TARGET}/java/classes/${i}
  281.         then
  282.             echo " ==> moving existing '${TARGET}/java/classes/${i}' to '${TARGET}/java/classes/${i}.old'"
  283.             /bin/rm -f ${TARGET}/java/classes/${i}.old
  284.             mv ${TARGET}/java/classes/${i} ${TARGET}/java/classes/${i}.old
  285.         fi
  286.         tar -cf - ${i} | (cd ${TARGET}/java/classes; tar -xf -)
  287.         echo "${i}" >> ${LOGFILE}
  288.         /bin/rm -f ${TARGET}/${i} ./${i}
  289.         echo "${i},${BLDVERS},${TARGET}/java/classes" >> ${REG_INFILE}
  290.     done
  291.  
  292.     #
  293.     # Try to properly deal with the font.properties files, to hopefully
  294.     # avoid users having to set MOZILLA_JAVA_FONT_PROPERTY_PATH, or
  295.     # just assuming Java font-handling is broken.
  296.     #
  297.     if test ! -z "`ls /bin/uname`"
  298.     then
  299.         MOVE_FONTS="TRUE"
  300.         case `/bin/uname` in
  301.             AIX)
  302.                 PLATFORM="aix"
  303.                 ;;
  304.             HP-UX)
  305.                 PLATFORM="hpux"
  306.                 ;;
  307.             IRIX | IRIX64)
  308.                 PLATFORM="irix"
  309.                 ;;
  310.             *)
  311.                 MOVE_FONTS="FALSE"
  312.                 ;;
  313.         esac
  314.         if test "${MOVE_FONTS}" = "TRUE"
  315.         then
  316.             mkdir ${TARGET}/java/classes/sun
  317.             chmod 755 ${TARGET}/java/classes/sun
  318.             mv ${TARGET}/java/classes/font.prop* ${TARGET}/java/classes/sun
  319.             mv ${TARGET}/java/classes/${PLATFORM}/* ${TARGET}/java/classes/.
  320.         fi
  321.     fi
  322.  
  323.     #
  324.     # Is this a virgin install?  If so, create the .netscape dir
  325.     # and put the default bookmark file in it.
  326.     #
  327.     if test ! -d ${HOME}/.netscape
  328.     then
  329.         # New install, or upgrade from 0.x or 1.x.
  330.         mkdir ${HOME}/.netscape
  331.         cp ${TARGET}/bookmark.htm ${HOME}/.netscape/bookmarks.html
  332.         chmod 644 ${HOME}/.netscape/bookmarks.html
  333.         echo "${HOME}/.netscape/bookmarks.html" >> ${LOGFILE}
  334.     fi
  335. fi
  336.  
  337. echo ""
  338. echo "Installing additional component files..."
  339. for pkg in *.nif
  340. do
  341.     if test "${pkg}" = "${PACKAGE}"
  342.     then
  343.         continue
  344.     fi
  345.     #
  346.     # Don't need to save the old files for these components,
  347.     # since the new ones are backwards-compatible.
  348.     #
  349.     case ${pkg} in
  350.         nethelp*)
  351.             /bin/rm -rf ${TARGET}/nethelp
  352.             echo "nethelp/" >> ${LOGFILE}
  353.             ;;
  354.         spellchk*)
  355.             /bin/rm -rf ${TARGET}/spell
  356.             echo "spell/" >> ${LOGFILE}
  357.             ;;
  358.     esac
  359.     ${GZIP} -dc ${pkg} | (cd ${TARGET}; tar -x${TAR_OPTIONS}f -)
  360.     echo "${pkg},${BLDVERS},${TARGET}" >> ${REG_INFILE}
  361.     /bin/rm -f ${pkg}
  362. done
  363.  
  364. #
  365. # Install the vreg binary in the TARGET directory.
  366. #
  367. if test -f ${TARGET}/vreg
  368. then
  369.     /bin/rm -f ${TARGET}/vreg.old
  370.     mv ${TARGET}/vreg ${TARGET}/vreg.old
  371.     # Handle the case where TARGET == . (meaning we just moved the file we just installed).
  372.     if test ! -f ./vreg
  373.     then
  374.         mv ${TARGET}/vreg.old ${TARGET}/vreg
  375.     else
  376.         mv ./vreg ${TARGET}/vreg
  377.     fi
  378. else
  379.     mv ./vreg ${TARGET}/vreg
  380. fi
  381.  
  382. #
  383. # Register the product so Automatic Software Download can work.
  384. # Just keeps track of the product name and version number for
  385. # comparison purposes later when newer versions become available.
  386. # Not necessary to run the product, but ASD will not be possible
  387. # without it....
  388. #
  389. echo ""
  390. echo "Registering ${PRODUCT} ${RELEASE}..."
  391. ${TARGET}/vreg ${TARGET}/${VREGISTRY} ${REG_INFILE} >/dev/null 2>&1
  392. if test $? -ne 0
  393. then
  394.     echo "ERROR: Installation completed, but unable to update/create the product"
  395.     echo "       version registry."
  396.     echo ""
  397.     echo "       If you are installing ${PRODUCT} from a platform other than"
  398.     echo "       that for which this package is intended, 'vreg' will not be"
  399.     echo "       able to run.  If this is the case, you may run 'vreg' manually"
  400.     echo "       (to enable ASD) on the appropriate platform using the following"
  401.     echo "       commands:"
  402.     echo ""
  403.     awk '{printf("\techo \"%s\" >>/tmp/infile\n", $0)}' ${REG_INFILE}
  404.     echo "    ${TARGET}/vreg ${TARGET}/${VREGISTRY} /tmp/infile"
  405.     echo ""
  406.     /bin/rm -f ns-install ${PACKAGE} ${REG_INFILE} core
  407.     exit 3
  408. fi
  409.  
  410. echo ""
  411. echo ""
  412. echo "The Netscape ${PRODUCT} software installation is complete."
  413. echo ""
  414. echo ""
  415.  
  416. #
  417. # Get rid of the trash.
  418. #
  419. /bin/rm -f ns-install ${PACKAGE} ${REG_INFILE}
  420.  
  421. echo ""
  422. exit 0
  423.