home *** CD-ROM | disk | FTP | other *** search
/ ftp.uv.es / 2014.11.ftp.uv.es.tar / ftp.uv.es / pub / linux / comm472.tar.gz / communicator-v472-export.x86-unknown-linux2.2.tar / communicator-v472.x86-unknown-linux2.2 / ns-install < prev    next >
Text File  |  2000-01-31  |  11KB  |  433 lines

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