--- mozilla-linux-setup-0.3.3 Tue Nov 12 06:44:48 2002 +++ mozilla-linux-setup-0.3.4 Wed Nov 20 10:57:02 2002 @@ -1,7 +1,7 @@ -#!/bin/bash +#! /bin/bash echo # ---------------------------------------------------------------------------- -echo "Mozilla Setup Wizard for GNU/Linux 0.3.3" +echo -e "\033[1mMozilla Setup Wizard for GNU/Linux 0.3.4\033[m" echo "Copyright (c) 2002 Thomas Lahn " # # This program is free software; you can redistribute it and/or modify @@ -22,6 +22,22 @@ # # ChangeLog: # +# 0.3.5 (future) +# --------------- +# * Plugin import: Allow overwrite, allow import of libnullplugin.so if desired +# * XUL applications setup: Allow uninstall +# +# 0.3.4 (2002-11-20) +# ------------------- +# * XUL applications setup: Try `file.xpi' if `file' does not exist +# * Check before calling Flash Plugin Installer +# * Added import of Netscape plugins except of libnullplugin.so (default plugin) +# * Cosmetics: +# - Headers for setup steps, use bold font for the title and them +# - Complete Help redesign, now also including exit codes documentation +# - Added note for e-mail feedback +# - Use escape codes for status display +# # 0.3.3 (2002-11-07) # ------------------- # * Added version sort support for archive path detection @@ -34,59 +50,123 @@ # # ---------------------------------------------------------------------------- +rc_done="\033[1mdone\033[m" +rc_failed="\033[1m\033[31mfailed\033[m" +rc_missed="\033[1m\033[31mnot found\033[m" + +function msg_done { + if [ -n "$rc_done" ]; then + echo -e $rc_done + else + echo "done" + fi +} + +function msg_failed { + if [ -n "$rc_failed" ]; then + echo -e $rc_failed + else + echo "failed" + fi +} + +function msg_missed { + if [ -n "$rc_missed" ]; then + echo -e $rc_missed + else + echo "not found" + fi +} + function help { - echo "Usage: `basename $0` [-? | -v] [src | -] [target | -]" - echo " [-F [plugin_dir | -] [inst_path | -]] [-A [xpi_file] [...]]" -# version 0.3.4 proposal: -# echo " [-F [plugin_dir | -] [inst_path | -]" -# echo " [-C | -L | -H [-o] [src] [plugin_dir]] [-A [xpi_file] [...]]" echo - echo "-?, --help Show this help page. Must be the first argument." - echo "-v, --verbose Activate verbose mode. Must be the first argument." - echo "src, - mozilla-installer *sea.t*gz archive path. Required." + echo "`basename $0` [-?v] SOURCE [TARGET]" + echo " [-CLH [-o] [SOURCE] [PLUGIN_DIR]] [-F [PLUGIN_DIR] [INST_PATH]]" + echo " [-A [XPI_PACKAGE] [...]]" + echo + echo -e "\033[1mFirst argument options (exclusive)\033[m" + echo + echo " -?, --help Show this help page." + echo " -v, --verbose Activate verbose mode." + echo + echo -e "\033[1mBasic user-agent setup\033[m" + echo + echo "`basename $0` [-?v] SOURCE [TARGET] [...]" + echo + echo " SOURCE mozilla-installer tarball path. Required." echo " Use - for the default (Mozilla Setup Wizard directory)." echo " Use 0 (zero) to skip the setup." echo " If this argument can only be resolved to a directory, the" echo " newest file in this directory is used (with version sort)" echo " that matches the pattern \`mozilla*pc-linux*sea.t*gz'." - echo "target, - User-defined directory where to store the setup directory." + echo " TARGET User-defined directory where to store the setup directory." echo " If left out or -, the default (/tmp) will be used." echo " (Write access to the specified directory is required!)" - echo "-F, --flash Install Flash plugin using PE's Flash Plugin Installer." - echo " plugin_dir, - Mozilla plugin directory after installation. Leave this out" + echo + echo -e "\033[1mPlugin and add-on setup\033[m" + echo + echo "`basename $0` [...] [-CLH [-o] [SOURCE] [PLUGIN_DIR]]" +# version 0.3.5 proposal +# echo " [-F [PLUGIN_DIR] [INST_PATH]] [-AU XPI_PACKAGE [...]]" + echo " [-F [PLUGIN_DIR] [INST_PATH]] [-A XPI_PACKAGE [...]]" + echo + echo " -C, --copy Copy plugin files from another installation of Mozilla or" + echo " Netscape. Mozilla will then be able to use those plugins" + echo " independently of the 'source' browser." + echo " -L, --link Do not copy plugin files but create symbolic links instead." + echo " Note that plugins are no longer available for Mozilla if" + echo " you eventually decide to deinstall the 'source' browser." + echo " -H, --hard Do not copy plugin files but create hard links instead." + echo " CAUTION! Removing one of those links will then remove the" + echo " plugins from two or more browsers. Restrictions to hard links" + echo " such as containment to one file system, will also apply." +# echo " -0, --null Also import the libnullplugin.so file, housing the default" +# echo " plugin that \"handles plugin data for mimetypes and" +# echo " extensions that are not specified and facilitates downloading" +# echo " of new plugins\" (from its description)." +# echo " CAUTION! This should only be used with newer or not very" +# echo " versions of Mozilla than you are setting up as files of" +# echo " of much older versions and of Netscape are likely to be" +# echo " incompatible." +# echo " -f, --force Overwrite existing plugins. The default is not to overwrite." + echo " SOURCE Source plugin directory or file(s). If this is a directory," + echo " all files in it will be copied to the specified plugin" + echo " directory or (symbolic) links are created there for each" + echo " file. If it is a file or a regular expression, only files" + echo " with matching names are copied/linked to. Leave this out" + echo " or use - for the default (/usr/local/netscape/plugins)," + echo " which should make all Netscape plugins available for this" + echo " Mozilla installation." + echo " PLUGIN_DIR Mozilla plugin directory after installation. Leave this out" echo " or use - for the default (/usr/local/mozilla/plugins)." - echo " inst_path, - PE's Flash Plugin Installer path. Leave this out or use -" + echo " -F, --flash Install Flash plugin using PE's Flash Plugin Installer." + echo " PLUGIN_DIR Mozilla plugin directory after installation. Leave this out" + echo " or use - for the default (/usr/local/mozilla/plugins)." + echo " If -C, -L or -H was used before with specifying PLUGIN_DIR" + echo " (including \`-'), that value is used instead and this" + echo " option is ignored." + echo " INST_PATH PE's Flash Plugin Installer path. Leave this out or use -" echo " for the default (./flash-linux-installer)." -# echo "-C, --copy Copy plugin files from another installation of Mozilla or" -# echo " Netscape. Mozilla will then be able to use those plugins" -# echo " independently of the 'source' browser." -# echo "-L, --link Do not copy plugin files but create symbolic links instead." -# echo " Note that plugins are no longer available for Mozilla if" -# echo " you eventually decide to deinstall the 'source' browser." -# echo "-H, --hardlink Do not copy plugin files but create hard links instead." -# echo " CAUTION! Removing one of those links will then remove the" -# echo " plugins from two or more browsers. Restrictions to hard" -# echo " links, such as containment to one file system, will also" -# echo " apply." -# echo " -o Overwrite existing files. The default is not to overwrite." -# echo " src, - Source plugin directory or file(s). If this is a directory," -# echo " all files in it will be copied to the specified plugin" -# echo " directory or (symbolic) links are created there for each" -# echo " file. If it is a file or a regular expression, only files" -# echo " with matching names are copied/linked to. Leave this out" -# echo " or use - for the default (/usr/local/netscape/plugins)," -# echo " which should make all Netscape plugins available for this" -# echo " Mozilla installation." -# echo " plugin_dir Mozilla plugin directory after installation. Leave this out" -# echo " for the default (/usr/local/mozilla/plugins). If -F was used" -# echo " before (with a plugin_dir option), that value or the default" -# echo " value is used instead and this option is ignored." - echo "-A, --apps Install applications (plugins, add-ons). This must be the" - echo " last option on the command line." - echo " xpi_file Cross-platform installation (*.xpi) package(s) for applications." - echo " Two or more packages are separated by spaces." -# echo " The Setup Wizard will automagically try \`file.xpi' if \`file'" -# echo " does not exist." + echo " -A, --apps Install XUL applications (plugins, add-ons). This must be" + echo " the last option on the command line." +# echo " -U, --uninst Uninstall XUL applications (plugins, add-ons). This must be" +# echo " the last option on the command line." + echo " XPI_PACKAGE Cross-platform installation package(s) for XUL applications." + echo " Two or more filenames are separated by spaces." + echo " The Setup Wizard will automagically try \`file.xpi'" + echo " if \`file' does not exist." + echo + echo -e "\033[1mExit codes\033[m" + echo + echo " 0 Success" + echo " 255 Argument missing" + echo " 254 \`tar' not found" + echo " 253 \`gzip' not found" + echo " 252 \`mozilla-installer' tarball not found" + echo " 251 Unable to locate \`mozilla-installer' target directory" + echo " 250 General error while extracting \`mozilla-installer' tarball" + echo " 249 Unable to locate \`mozilla-installer' executable" + echo " 248 General error while executing \`mozilla-installer'" echo } @@ -95,31 +175,32 @@ echo -n "sending all Mozilla instances the TERM signal... " killall mozilla-bin 2> /dev/null if [ $? -ne 0 ]; then - echo "failed." + msg_failed echo "You should close all Mozilla windows before continuing." echo "Press any key when ready." read -n 1 -s echo else - echo "done" + msg_done fi fi } echo "Protected under the terms of the GNU General Public License (GPL)." echo "See COPYING file or http://www.fsf.org/copyleft/gpl.html for details." -echo "This is work in progress. Feel free to report any bugs." -echo - +help=0 if [ -z "$1" ] || [ "$1" = "-?" ] || [ "$1" = "--help" ]; then + help=1; help - exit 255 fi +echo "Send suggestions and bug reports to " +echo +test $help -eq 1 && exit 255 verbose=0 if [ "$1" = "-v" ] || [ "$1" = "--verbose" ]; then verbose=1 - echo "working in verbose mode." + echo -e "\033[1mWorking in verbose mode.\033[m" shift fi @@ -130,10 +211,16 @@ src="-" target="-" -if [ "$1" != "-F" ] && [ "$1" != "--flash" ] && [ "$1" != "-A" ] && [ "$1" != "--apps" ]; then +if [ "$1" != "-C" ] && [ "$1" != "--copy" ] && [ "$1" != "-L" ] && [ "$1" != "--link" ] \ +&& [ "$1" != "-H" ] && [ "$1" != "--hard" ] \ +&& [ "$1" != "-F" ] && [ "$1" != "--flash" ] \ +&& [ "$1" != "-A" ] && [ "$1" != "--apps" ]; then if [ -n "$1" ] && [ "$1" != "-" ]; then src=$1; fi shift - if [ "$1" != "-F" ] && [ "$1" != "--flash" ] && [ "$1" != "-A" ] && [ "$1" != "--apps" ]; then + if [ "$1" != "-C" ] && [ "$1" != "--copy" ] && [ "$1" != "-L" ] && [ "$1" != "--link" ] \ + && [ "$1" != "-H" ] && [ "$1" != "--hard" ] \ + && [ "$1" != "-F" ] && [ "$1" != "--flash" ] \ + && [ "$1" != "-A" ] && [ "$1" != "--apps" ]; then if [ -n "$1" ] && [ "$1" != "-" ]; then target=$1; fi shift fi @@ -143,6 +230,32 @@ echo target=\"$target\" fi +import=0 +import_source="/usr/local/netscape/plugins" +import_target="/usr/local/mozilla/plugins" +if [ "$1" = "-C" ] || [ "$1" = "--copy" ] || [ "$1" = "-L" ] || [ "$1" = "--link" ] \ +|| [ "$1" = "-H" ] || [ "$1" = "--hard" ] ; then + case $1 in + -C | --copy) import=1;; + -L | --link) import=2;; + -H | --hard) import=3;; + esac + shift + if [ -n "$1" ] && [ "$1" != "-F" ] && [ "$1" != "--flash" ] && [ "$1" != "-A" ] && [ "$1" != "--apps" ]; then + if [ "$1" != "-" ]; then import_source=$1; fi + shift + if [ -n "$1" ] && [ "$1" != "-F" ] && [ "$1" != "--flash" ] && [ "$1" != "-A" ] && [ "$1" != "--apps" ]; then + if [ "$1" != "-" ]; then import_target=$1; fi + shift + fi + fi +fi +if [ $verbose -eq 1 ]; then + echo import=$import + echo import_source=\"$import_source\" + echo import_target=\"$import_target\" +fi + # * (-F | --flash) [-] install Mozilla setup from $1 to $2 and install flash plugin # to /usr/local/mozilla/plugins using ./flash-linux-installer # * (-F | --flash) $4 [-] like above but use $4 as plugin directory @@ -184,18 +297,20 @@ echo apps=\"$apps\" fi +echo -e "\n\033[1mBasic user-agent setup\033[m\n" + if [ "$src" = "0" ]; then - echo "skipping Mozilla setup." + echo "Skipped." else echo -n "checking for tar... " chk=`which tar 2> /dev/null` if [ -n "$chk" ]; then echo "`tar --version | head -n 1 -` ($chk)" else - echo "ERROR!" + msg_missed echo echo "`basename $0`: Could not find \`tar' which is required to extract the archive." - exit 255 + exit 254 fi echo -n "checking for gzip... " @@ -203,10 +318,10 @@ if [ -n "$chk" ]; then echo "`gzip --version | head -n 1 -` ($chk)" else - echo "ERROR!" + msg_missed echo echo "`basename $0`: Could not find \`gzip' which is required to extract the archive." - exit 254 + exit 253 fi echo -n "checking for source path... " @@ -214,24 +329,24 @@ src=`dirname $0` fi if [ -d "$src" ]; then - echo "directory: $src" + echo "directory: $src" | fold -s echo -n "checking for archive... " srcf=`(ls -1vr $src/mozilla*pc-linux*sea.t*gz 2> /dev/null) | head -n 1 -` if [ -n "$srcf" ]; then echo "$srcf" src=$srcf else - echo "not found" + msg_missed echo - exit 253 + exit 252 fi else echo "file: $src" echo -n "checking for archive... " if [ -f "$src" ]; then - echo done + msg_done else - echo "not found" + msg_missed echo exit 252 fi @@ -252,22 +367,22 @@ tar_out=`tar xvzf $src -C $target 2>&1` fi if [ $? -ne 0 ]; then - echo "ERROR!" + msg_failed echo if [ $verbose -eq 0 ]; then echo "$tar_out"; fi echo exit 250 else - echo "... done" + msg_done fi echo -n "checking for mozilla-installer... " if [ -x "$target/mozilla-installer/mozilla-installer" ]; then - echo "done" + msg_done KillMoz echo "starting mozilla-installer..." $target/mozilla-installer/mozilla-installer if [ $? -eq 0 ]; then - echo "... done"; echo + msg_done; echo answer="0" while [ "$answer" != "y" ] && [ "$answer" != "n" ]; do read -p "Clean up NOW ([y]es / [n]o / [i]nfo)? " -n 1 answer @@ -277,9 +392,9 @@ echo -n "cleaning up... " rm -r $target/mozilla-installer &> /dev/null if [ $? -eq 0 ]; then - echo "done" + msg_done else - echo "ERROR!" + msg_failed fi elif [ "$answer" = "n" ]; then echo @@ -292,7 +407,7 @@ fi done else - echo "ERROR!" + msg_failed echo exit 248 fi @@ -302,7 +417,7 @@ exit 249 fi else - echo "ERROR!" + msg_missed echo echo "`basename $0`: $target: Unable to find target directory." echo @@ -310,34 +425,117 @@ fi fi +if [ $import -ge 1 ]; then + echo -e "\n\n\033[1mPlugin import\033[m\n" + echo -n "checking for target directory... " + if [ -d "$import_target" ]; then + echo $import_target + echo -n "checking for source path... " + if [ -d "$import_source" ]; then + echo "directory: $import_source" + case $import in + 1) # copy + echo "Copying all plugins..." + for i in `ls $import_source/`; do + if [ "$i" != "libnullplugin.so" ]; then + cp -apv $import_source/$i $import_target + fi + done + ;; + 2) # create symlinks + echo "Creating symbolic links for all plugins..." + for i in `ls $import_source/`; do + if [ "$i" != "libnullplugin.so" ]; then + cp -asv $import_source/* $import_target + fi + done + ;; + 3) # create hard links + echo "Creating hard links for all plugins..." + for i in `ls $import_source/`; do + if [ "$i" != "libnullplugin.so" ]; then + cp -lapv $import_source/* $import_target + fi + done + ;; + *) echo "Invalid \$import value ---> BUG!" + esac + if [ $? -ne 0 ]; then + msg_failed + echo + else + msg_done + fi + elif [ -f "$import_source" ]; then + echo "file: $import_source" + case $import in + 1) # copy + echo "Copying $import_source..." + cp -irpv $import_source $import_target + ;; + 2) # create symlinks + echo "Creating symbolic link for $import_source..." + cp -irpsv $import_source $import_target + ;; + 3) # create hardlinks + echo "Creating hard link for $import_source..." + cp -ilrpv $import_source $import_target + ;; + *) echo "Invalid \$import value ---> BUG!" + esac + if [ $? -ne 0 ]; then + msg_failed + echo + else + msg_done + fi + else + msg_missed + fi + else + msg_missed + fi + echo +fi + if [ $flash -eq 1 ]; then - echo "Starting Flash Plugin Installer... " - $flash_inst_path $flash_plugin_dir - if [ $? -eq 0 ]; then - echo "...done" + echo -e "\n\n\033[1mMacromedia Flash plugin setup\033[m" + if [ -x $flash_inst_path ] && [ -f $flash_inst_path ]; then + $flash_inst_path $flash_plugin_dir + else + echo -e "\nCould not find PointedEars' Flash Plugin Installer as" + echo -e "\`$flash_inst_path'. Skipped.\n" fi fi if [ "$apps" != "" ]; then - echo "installing applications. You need to quit Mozilla after each installation." + echo -e "\n\033[1mXUL applications setup\033[m\n" + echo -e "You need to quit Mozilla after each installation.\n" for a in $apps; do KillMoz echo -n " $a... " + if [ ! -f "$a" ]; then + msg_missed + echo "not found." + echo -n " trying $a.xpi... " + if [ -f "$a.xpi" ]; then + a=$a.xpi + else + msg_failed + continue + fi + fi if [ -f "$a" ]; then mozilla "file://`pwd`/$a" if [ $? -eq 0 ]; then - echo " done" + msg_done + continue KillMoz else - echo " ERROR!" + msg_failed fi - else - echo "not found." fi done fi -echo -echo Setup complete. -echo -exit 255 +echo -e "\n\n\033[1mSetup complete.\033[m\n"