--- ../releases/mozilla-linux-setup-0.3.4 Fri Mar 14 14:03:32 2003 +++ latest/mozilla-linux-setup Sat May 3 09:58:01 2003 @@ -1,8 +1,12 @@ - #! /bin/bash - echo + #!/bin/bash + appname=`basename "$0"` + ver="0.3.5a.2003050309" + copy="2002, 2003" + mail="PointedEars@gmx.de" + mail_feedback="bug-mozilla@PointedEars.de" # ---------------------------------------------------------------------------- - echo -e "\033[1mMozilla Setup Wizard for GNU/Linux 0.3.4\033[m" - echo "Copyright (c) 2002 Thomas Lahn " + # Mozilla Setup Wizard for GNU/Linux 0.3.5a + # Copyright (c) 2002, 2003 Thomas Lahn # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -18,524 +22,1592 @@ echo "Copyright (c) 2002 Thomas Lahn

# - # ChangeLog: + # ChangeLog + # ========== # - # 0.3.5 (future) - # --------------- - # * Plugin import: Allow overwrite, allow import of libnullplugin.so if desired - # * XUL applications setup: Allow uninstall + # 0.3.5a (future) + # ---------------- # - # 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 + # Enhancements: # - # 0.3.3 (2002-11-07) - # ------------------- - # * Added version sort support for archive path detection - # * First public release (GPL) + # * Basic setup + # - `-D', `--download': + # Defines the resource from where to download the gzipped tarball first + # (uses wget). The file is downloaded to the location specified by SOURCE. + # - Show $distribution`/'build_type`/'$build_ID before install + # - Show $installer and `rm' output (incl. stderr) after "done"/"failed" + # - Show free disk space on /tmp before asking for clean-up, uses -h option + # if supported + # * Plugin import + # - Show verbose output of import of all plugins only in verbose mode + # * XUL applications setup + # - Uninstall as described under + # http://white.sakura.ne.jp/~piro/xul/doc/installation.html.en#uninstall; + # - Install all apps that match the Netscape installer quasi-standard + # (-f && -x $archive/$installer/$installer) + # - Added general `chmod go+r' in chrome/ to prevent later permission bugs + # with XUL apps (such as `mozgest') + # * Allow repair of an existing installation, removing XUL cache file + # * Approaching POSIX conformance: Order of options does not matter any longer + # * `-T', `--truetype': + # Modifies /usr/local/mozilla/defaults/pref/unix.js to use FreeType2 for + # TrueType fonts. The directory /usr/X11R6/lib/X11/fonts/truetype is then + # used by default, other font directories must be specified with the + # `pref("font.directory.truetype.X", )' statement in unix.js or the + # `user_pref(...)' statement in ~/.mozilla/...slt/unix.js; + # See http://www.mozilla.org/projects/fonts/unix/enabling_truetype.html + # * Cosmetics + # - Removed unused code (previously imported completely + # from /etc/rc.status) + # - Reversed exit codes (255 --> 1, 254 --> 2, ...) + # - Use MozKill and isMozRunning funct's from the + # Mozilla Process Manager (moz), version 0.2.2b+ + # (by this h4> /dev/null + result=$? + if [ $result -ne 0 ]; then + echo $rc_failed + else + ping=1 + mozilla -remote "ping()" 2> /dev/null + error=$? + test $verbose -eq 1 && echo -n $error" " >&2 + while [ $error -eq 0 ] && [ $ping -le 50 ]; do + let ping++ + mozilla -remote "ping()" 2> /dev/null + error=$? + test $verbose -eq 1 && echo -n $error" " >&2 + if [ $ping -eq 25 ]; then + echo " + " + L "Mozilla was pinged $ping times without response, trying + $ping more times before giving up. Press Ctrl+C to quit." \ + "Mozilla wurde $ping Mal erfolglos gepingt, es werden weitere + $ping Versuche unternommen. Drücken Sie Strg+C, um abzubrechen." | $fmt >&2 + echo -n " + ... " >&2 + fi + done + if [ $error -ne 0 ]; then + echo $rc_done + test $verbose -eq 1 && \ + L "Mozilla was pinged "$ping" times until shutdown was complete." \ + "Mozilla wurde "$ping" Mal gepingt, bevor er vollständig beendet \ + war." | $fmt >&2 + else + echo $rc_failed + test $verbose -eq 1 && \ + L " + Mozilla was pinged "$ping" times without response. + Please check your Mozilla installation." \ + " + Mozilla wurde "$ping" Mal erfolglos gepingt. + Bitte überprüfen Sie ihre Mozilla-Installation." | $fmt >&2 + fi + fi + fi + + return $(( $result )) + } + + function RunMoz { + # check if the current user has Mozilla already run + # AFAIK mozilla -remote "ping()" does not pay respect to different accounts + local chk=`ps -fu $(whoami) 2> /dev/null | grep mozilla-bin | grep -v grep` + if [ -z "$chk" ]; then + mozilla "$1" & + local ping=1 + mozilla -remote "ping()" 2> /dev/null + error=$? + test $verbose -eq 1 && echo -n $error" " >&2 + while [ $error -ne 0 ] && [ $ping -le 50 ]; do + let ping++ + mozilla -remote "ping()" 2> /dev/null + local error=$? + test $verbose -eq 1 && echo -n $error" " >&2 + if [ $ping -eq 25 ]; then + echo " + " + L "Mozilla was pinged $ping times without response, trying + $ping more times before giving up. Press Ctrl+C to quit." \ + "Mozilla wurde $ping Mal erfolglos gepingt, es werden weitere + $ping Versuche unternommen. Drücken Sie Strg+C, um abzubrechen." | $fmt >&2 + echo -n " + ... " >&2 + fi + done + if [ $error -eq 0 ]; then + echo $rc_done + test $verbose -eq 1 && \ + L "Mozilla was pinged "$ping" times until startup was complete." \ + "Mozilla wurde "$ping" Mal gepingt, bevor er vollständig gestartet \ + war." | $fmt >&2 + else + echo $rc_failed + test $verbose -eq 1 && \ + L " + Mozilla was pinged "$ping" times without response. + Please check your Mozilla installation." \ + " + Mozilla wurde "$ping" Mal erfolglos gepingt. + Bitte überprüfen Sie ihre Mozilla-Installation." | $fmt >&2 + fi else - echo "failed" + mozilla -remote "openURL($1,new-tab)" & + if [ $? -eq 0 ]; then + echo $rc_done + else + echo $rc_failed + fi fi } - function msg_missed { - if [ -n "$rc_missed" ]; then - echo -e $rc_missed + function XULisInstd { + local chk="`grep chrome/$1 $mozdir/chrome/installed-chrome.txt 2> /dev/null`" + if [ -n "$chk" ]; then + return 0 else - echo "not found" + return 1 fi } - function help { - echo - 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 " If left out or -, the default (/tmp) will be used." - echo " (Write access to the specified directory is required!)" - 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 " -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 " -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 + function XULuninst { + for u in $1; do if [ -n "$u" ]; then + KillMoz + echo -n " $u$stat" + if XULisInstd "$u"; then + rm -rf $mozdir/chrome/$u* #2> /dev/null + + # Removing chrome.rdf first because overlayinfo/ is NOT automagically + # recreated when chrome.rdf exists; otherwise an error removing + # chrome.rdf would have "killed" $Joe_User's XUL apps without a + # (plausible) explanation which could cause some ... trouble for this + # $|-|3|_|_$<|21|°' |-|4><0|2. + # See <1231960.iDbeOVK0A0@pointedears.de> pp. :-> + test $? -eq 0 && rm -f $mozdir/chrome/chrome.rdf #2> /dev/null + test $? -eq 0 && rm -rf $mozdir/chrome/overlayinfo #2> /dev/null + + test $? -eq 0 && grep -v chrome/$u $mozdir/chrome/installed-chrome.txt \ + 1> $mozdir/chrome/installed-chrome.txt.new + # echo + # diff -u $mozdir/chrome/installed-chrome.txt \ + # $mozdir/chrome/installed-chrome.txt.new + test $? -eq 0 && cp -p $mozdir/chrome/installed-chrome.txt \ + $mozdir/chrome/installed-chrome.txt.bak + test $? -eq 0 && mv $mozdir/chrome/installed-chrome.txt.new \ + $mozdir/chrome/installed-chrome.txt + if [ $? -eq 0 ]; then + echo $rc_done + else + echo $? + echo $rc_failed + fi + else + echo "${extd}not installed${norm}" + fi + fi; done } - function KillMoz { - if [ -n "`ps -A | grep mozilla-bin`" ]; then - echo -n "sending all Mozilla instances the TERM signal... " - killall mozilla-bin 2> /dev/null - if [ $? -ne 0 ]; then - msg_failed - echo "You should close all Mozilla windows before continuing." - echo "Press any key when ready." - read -n 1 -s - echo + function isMozRunning { + # check for supported `ps' options + # BSD style user-oriented + args="u " + ps $args 1>/dev/null 2>&1 + if [ $? -eq 0 ]; then + fallback=$args + else + # SysV/Unix98 (i.e. IRIX) style + fallback="-" + args="-f" # full output + ps $args 1>/dev/null 2>&1 + if [ $? -eq 0 ]; then + fallback=$args else - msg_done + args=$fallback fi + ps $args 1>/dev/null 2>&1 + test $? -ne 0 && args=$fallback fi + chk=`ps $args | grep mozilla-bin | grep -v grep` + test -z "$chk" && return 1 + return 0 } - 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." - help=0 - if [ -z "$1" ] || [ "$1" = "-?" ] || [ "$1" = "--help" ]; then - help=1; - help - fi - echo "Send suggestions and bug reports to " - echo - test $help -eq 1 && exit 255 + function XPInst { + for i in $1; do + # to be removed when RunMoz works instead of direct call + # KillMoz + local f=$i + echo -n " $f" + if [ ! -f "$f" ]; then + echo -n ".xpi$stat" + if [ -f "$f.xpi" ]; then + f=$f.xpi + else + echo "$rc_failed" + continue + fi + else + echo -n "$stat" + fi + if [ -f "$f" ]; then + # TO DO: Automagic uninstall requires $i = `basename $i` =~ s/-.*?\.xpi// + # if [ `XULisInstd $(basename $i)` -eq 0 ]; then + # echo -n " + # $i is already installed. Performing automagic uninstall first... " + # XULuninst "$i" + # fi + local d="`pwd`/" + test "`echo "$f" | cut -c 1 2>/dev/null`" = "/" && d="" + # if isMozRunning && mozilla -remote 'ping()' 2>/dev/null ; then + # mozilla -remote 'openURL(file://$d$f)' + # else + mozilla "file://$d$f" # & + # fi + if [ $? -eq 0 ]; then + echo "$rc_done" + else + echo "$rc_failed" + return 1 + fi + fi + done + } - verbose=0 - if [ "$1" = "-v" ] || [ "$1" = "--verbose" ]; then - verbose=1 - echo -e "\033[1mWorking in verbose mode.\033[m" - shift - fi + function XULsetup { + echo " + ${extd}XUL applications and cross-platform installation setup${norm}" - # - install Mozilla setup from ./mozilla*pc-linux*sea.t*gz - # $1 install Mozilla setup from $1 - # - - install Mozilla setup from ./mozilla*pc-linux*sea.t*gz to /tmp - # - $2 like above but use $2 as setup directory + if [ $uninst -eq 1 ]; then + echo " + Uninstalling XUL applications (${extd}is currently tested${norm})... + " + XULuninst "$uninstList" + fi - src="-" - target="-" - 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" != "-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 + if [ $inst -eq 1 ]; then + echo " + Installing XPIs. You need to quit Mozilla after each installation. + " + XPInst "$instList" fi - fi - if [ $verbose -eq 1 ]; then - echo src=\"$src\" - 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 + function MozRepairFiles { + local result=0 + for f in $1; do + test $verbose -eq 1 && echo -n " $f$stat" + find $HOME/.mozilla -name "$f" -print0 2>/dev/null | xargs -0r rm -R$sVerbose + if [ $? -eq 0 ]; then + test $verbose -eq 1 && echo "$rc_done" + else + test $verbose -eq 1 && echo "$rc_failed" + let result++ + fi + done + test $verbose -eq 1 -a $result -gt 0 && \ + L "Failed to remove $result file(s)." \ + "$result Datei(en) konnte(n) nicht entfernt werden." >&2 + return $result + } + + function MozRepair { + echo " + + ${extd}`L "Repair of an existing installation" \ + "Reparatur einer bestehenden Installation"`${norm} + " + KillMoz + test $verbose -eq 1 && sVerbose=v + echo -n `L "Repairing" "Wird repariert"`"... " + test $verbose -eq 1 && echo + MozRepairFiles XUL.mfasl # chrome.rdf localstore.rdf + sVerbose= + if [ $verbose -eq 0 ]; then + if [ $? -eq 0 ]; then + echo $rc_done + else + echo $rc_failed fi fi + } + + function EnableTrueType { + echo " + + ${extd}`L "TrueType font support" \ + "Unterstützung für TrueType-Schriftarten"`${norm} + " + KillMoz + + local prefdir=$mozdir/defaults/pref + fontdirs=("/usr/X11R6/lib/X11/fonts/truetype" "" "") + test -n "$1" -a "$1" != "-" && fontdirs[0]="$1" + test -n "$2" -a "$2" != "-" && fontdirs[1]="$2" + test -n "$3" && fontdirs[2]="$3" + + echo "`L Directories: Verzeichnisse:` + " + for i in ${fontdirs[*]}; do + test -n "$i" && echo " $i" + done + + cp -p $prefdir/unix.js $prefdir/unix.js.bak \ + && sed 's%\(pref("font.FreeType2.enable", \+\)false%\1true%' $prefdir/unix.js.bak \ + | sed 's%^\(//\)* *\(pref("font.directory.truetype.1", \+"\).*"%\2'${fontdirs[0]}'"%' \ + | sed 's%^\(//\)* *\(pref("font.directory.truetype.2", \+"\).*"%\2'${fontdirs[1]}'"%' \ + | sed 's%^\(//\)* *\(pref("font.directory.truetype.3", \+"\).*"%\2'${fontdirs[2]}'"%' \ + > $prefdir/unix.js + + test $verbose -eq 1 && less $prefdir/unix.js + + echo + if [ $? -eq 0 ]; then + echo $rc_done + else + echo $rc_failed + fi + } + + function UpdPerm { + # Make XUL apps available to all users + echo -n "`L "Updating access permissions" \ + "Zugriffsrechte werden aktualisiert"`... " + # ` + + chmod -R go+r $mozdir/chrome/* 2> /dev/null + test $? -eq 0 && chmod -R 755 $mozdir/chrome/mozgest/* 2> /dev/null + echo $rc_done + } + + # ********************************** MAIN ************************************** + + # Note that we use `"$@"' to let each command-line parameter expand to a + # separate word. The quotes around `$@' are essential! + # We need `tmp' as the `eval set --' would nuke the return value of getopt. + + # ${extd}${appname}${norm} + # [${extd}-?${norm}] [${extd}-v${norm}] \ + # [${extd}-L${norm} LOCALE] [${extd}-I${norm} INSTALLER] [${extd}-U${norm} \ + # [USER]] [${extd}-R${norm}] [${extd}-D${norm} RESOURCE] + # [( ${extd}-c${norm} | ${extd}-s${norm} | ${extd}-h${norm} ) [SOURCE] \ + # [PLUGIN_DIR] [...] [${extd}-0o${norm}]] + # [${extd}-f${norm} [PLUGIN_DIR] [INST_PATH] [TGZ_PATH]] + # [ ( ${extd}-i${norm} | ${extd}-u${norm} ) [APP_NAME] [...]] [${extd}-d${norm} MOZ_DIR] + # SOURCE [TARGET] + + # if `getopt -T >/dev/null 2>&1` ; [ $? = 4 ] ; then + # echo "Enhanced getopt(1)" + # tmp=`getopt -o hvL:I:U::RD:c:s:l:0of::a::i::u::d: \ + # --long help,verbose,locale,installer,user,repair,download,copy,\ + # symlink,link,null,overwrite,flash,apps,install,uninstall,directory \ + # -n "$appname" -s bash \ + # -- "$@"` + # echo "$tmp" + # exit 0 + # else + # echo "Old getopt(1)" + # tmp=`getopt hvL:I:U:RD:c:s:l:0iof:a:i:u:d: "$@"` + # fi + # + # getopt_exit_code=$? + # if [ $getopt_exit_code -eq 0 ]; then + ## getopt returns error code 0 for successful parsing, 1 if + ## getopt(3) returns errors, 2 if it does not understand its + ## own parameters, 3 if an internal error occurs like out-of- + ## memory, and 4 if it is called with -T. + # + # Note the quotes around `$tmp': they are essential! + # echo $tmp + # remove "--" + # for i in $tmp; do if [ "$i" != "--" ]; then tmp2="${tmp2} $i"; fi; done + # eval set -- "$tmp2" + # echo $* + #exit 0 + # else + # echo "getopt exited: $getopt_exit_code + # " >&2 + # exit $getopt_exit_code + # fi + + # L10n + lg="" + if [ -n "$LANG" ]; then lg=`echo $LANG | sed 's/_.*[.].*//' 2> /dev/null`; fi + if [ -z "$lg" ]; then lg=`echo $LC_CTYPE | sed 's/_.*//' 2> /dev/null`; fi + + # from /etc/rc.status + + if test -z "$LINES" -o -z "$COLUMNS" ; then + eval `stty size 2>/dev/null | (read L C; \ + echo LINES=${L:-24} COLUMNS=${C:-80})` fi - if [ $verbose -eq 1 ]; then - echo import=$import - echo import_source=\"$import_source\" - echo import_target=\"$import_target\" + test $LINES -eq 0 && LINES=24 + test $COLUMNS -eq 0 && COLUMNS=80 + + if test "$TERM" != "raw" && stty size >/dev/null 2>&1 ; then + esc=`echo -en "\033"` + extd="${esc}[1m" + warn="${esc}[1;31m" + done="${esc}[1;32m" + attn="${esc}[1m" + norm=`echo -en "${esc}[m\017"` + stat=`echo -en "\015${esc}[${COLUMNS}C${esc}[13D"` + else + esc="" + extd="" + warn="" + done="" + attn="" + norm="" + stat="... " 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 - # * (-F | --flash) $4 $5 like above but use $5 to install plugin + # check for fold + fold="fold -sw $COLUMNS" + chk=`which fold 2> /dev/null` + test $? -ne 0 && fold="cat" + chk=`echo x | $fold 1> /dev/null` + test -n "$chk" && fold="cat" - flash=0 - flash_plugin_dir="/usr/local/mozilla/plugins" - flash_inst_path="./flash-linux-installer" - if [ "$1" = "-F" ] || [ "$1" = "--flash" ]; then - flash=1 - shift - if [ -n "$1" ] && [ "$1" != "-A" ] && [ "$1" != "--apps" ]; then - if [ "$1" != "-" ]; then flash_plugin_dir=$1; fi - shift - if [ -n "$1" ] && [ "$1" != "-A" ] && [ "$1" != "--apps" ]; then - if [ "$1" != "-" ]; then flash_inst_path=$1; fi - shift + # check for fmt + fmt=cat + if [ $COLUMNS -ne 80 ]; then # output is preformatted for 80 cols + chk=`which fmt 2> /dev/null` + if [ $? -ne 0 ]; then + fmt=$fold + else + # check for columns + fmt="fmt -$COLUMNS" + chk=`echo x | $fmt 2> /dev/null` + test -z "$chk" && fmt="fmt" + # check for -c|--crown-margin + chk=`echo x | $fmt -c 2> /dev/null` + if [ -n "$chk" ]; then + fmt=$fmt" -c" + else + chk=`echo x | $fmt --crown-margin 2> /dev/null` + test -n "$chk" && fmt=$fmt" --crown-margin" fi fi fi - if [ $verbose -eq 1 ]; then - echo flash=$flash - echo flash_plugin_dir=\"$flash_plugin_dir\" - echo flash_inst_path=\"$flash_inst_path\" - fi - # * (-A | --apps) $4-* install applications $4 to $* + echo " + ${extd}Mozilla Setup Wizard for GNU/Linux $ver${norm} + Copyright (C) $copy Thomas Lahn <$mail> + Distributed under the terms of the GNU General Public License (GPL), + see COPYING file or http://www.fsf.org/copyleft/gpl.html for details." - apps="" - if [ "$1" = "-A" ] || [ "$1" = "--apps" ]; then + help=0 + test -z "$1" && help=1 + + # Flags and setup data + verbose=0 + download_default="http://ftp.mozilla.org/pub/mozilla/nightly/latest/mozilla-i686-pc-linux-gnu-sea.tar.gz" + download="" + repair=0 + single=0 + src="" + target="" + installer="mozilla-installer" + import=0 + importNull=0 + copy=0 + copyOpt[0]="" + copyOptLast=-1 + link=0 + linkOpt[0]="" + linkOptLast=-1 + hard=0 + hardOpt[0]="" + hardOptLast=-1 + overwrite=0 + flash=0 + flashOpt="" + inst=0 + instList="" + uninst=0 + uninstList="" + truetype=0 + truetype_dirs=() + last="" + + while [ -n "$1" ]; do + case "$1" in + -h | --help) + help=1;; + -v | --verbose) + last="" + verbose=1 + echo + echo "${extd}Working in verbose mode.${norm} + \$* = \"$*\" + ";; + -L | --locale) last="L";; + -D | --download) last="D" + download=$download_default;; + -R | --repair) last=""; repair=1;; + -I | --installer) last="I";; + -U | --single-user) last=""; single=1;; + -0 | --null) last=""; importNull=1;; + -O | -o | --overwrite) last=""; overwrite=1;; + -C | -c | --copy) last="c"; import=1; copy=1; let copyOptLast+=1;; + -S | -s | --symlinks) last="s"; import=1; link=1; let linkOptLast+=1;; + -l | --link) last="l"; import=1; hard=1; let hardOptLast+=1;; + -F | -f | --flash) last="f"; flash=1; flashPluginDir="" + flashInstPath="";; + -A | -a | --apps | -i | --install) + last="i"; inst=1;; + -u | --uninstall) last="u"; uninst=1;; + -T | --truetype) truetype=1; last="T";; + *) + if [ -n "$last" ]; then + case $last in + L) + lg=$1 + last="";; + D) + download="$1" + last="";; + I) + installer=$1 + last="";; + c) + if [ -z "${copyOpt[$copyOptLast]}" ]; then + copyOpt[$copyOptLast]=$1 + else + copyOpt[$copyOptLast]="${copyOpt[$copyOptLast]} $1" + last="" + fi;; + s) + if [ -z "${linkOpt[$linkOptLast]}" ]; then + linkOpt[$linkOptLast]=$1 + else + linkOpt[$linkOptLast]="${linkOpt[$linkOptLast]} $1" + last="" + fi;; + l) + if [ -z "${hardOpt[$hardOptLast]}" ]; then + hardOpt[$hardOptLast]=$1 + else + hardOpt[$hardOptLast]="${hardOpt[$hardOptLast]} $1" + last="" + fi;; + f) + if [ -z "$flashPluginDir" ]; then + flashPluginDir=$1 + else + test -z "$flashInstPath" && flashInstPath=$1 + last="" + fi;; + i) + test -n "$instList" && instList="$instList " + instList="$instList$1";; + u) + test -n "$uninstList" && uninstList="$uninstList " + uninstList="$uninstList$1";; + T) + for i in $1; do + truetype_dirs[${#truetype_dirs[*]}]="$i" + done + ;; + esac + else + if [ -z "$src" ]; then + src="$1" + else + test -z "$target" && target="$1" + fi + fi + ;; + esac shift - if [ -z "$1" ]; then - help - exit 255 - fi - if [ -n "$*" ]; then apps=$*; fi + done + + rc_done="${done}done${norm}" + rc_running="${stat}${done}`L 'running ' 'läuft '`${norm}" + rc_failed="${warn}`L 'failed ' 'versagt '`${norm}" + rc_missed="${warn}`L 'not found ' 'nicht gefunden'`${norm}" + rc_skipped="${attn}`L 'skipped ' 'übergangen '`${norm}" + rc_done_up="${esc}[1A${rc_done}" + rc_failed_up="${esc}[1A${rc_failed}" + + test -z "$src" && src="-" + test -z "$target" && target="-" + if [ $verbose -eq 1 ]; then + echo "\ + download_default=\"$download_default\" + download=\"$download\" + repair=$repair + single=$single + src=\"$src\" + target=\"$target\" + installer=\"$installer\"" fi + + test -z "$flashPluginDir" -o "$flashPluginDir" = "-" && + flashPluginDir="/usr/local/mozilla/plugins" + test -z "$flashInstPath" -o "$flashInstPath" = "-" && + flashInstPath="./flash-linux-installer" if [ $verbose -eq 1 ]; then - echo apps=\"$apps\" + echo -n "import=$import + copy=$copy + copyOpt=" + test -n "$copyOpt" && for i in `seq 0 $copyOptLast`; do echo -n + "[\"${copyOpt[$i]}\"] "; done + echo -n " + copyOptLast=$copyOptLast + link=$link + linkOpt=" + test -n "$linkOpt" && for i in `seq 0 $linkOptLast`; do echo -n + "[\"${linkOpt[$i]}\"] "; done + echo -n " + linkOptLast=$linkOptLast + hard=$hard + hardOpt=" + test -n "$hardOpt" && for i in `seq 0 $hardOptLast`; do echo -n + "[\"${hardOpt[$i]}\"] "; done + echo " + hardOptLast=$hardOptLast + overwrite=$overwrite + flash=$flash + flashPluginDir=\"$flashPluginDir\" + flashInstPath=\"$flashInstPath\" + inst=$inst + instList=\"$instList\" + uninst=$uninst + uninstList=\"$uninstList\" + " fi - echo -e "\n\033[1mBasic user-agent setup\033[m\n" + # check for required arguments + if [ $inst -eq 1 ] && [ -z "$instList" ]; then + echo "${appname}: Required argument missing for -A|--apps|-i|--install" >&2 + echo + help=1 + fi + + if [ $uninst -eq 1 ] && [ -z "$uninstList" ]; then + echo "${appname}: Required argument missing for -u|--uninstall" >&2 + echo + help=1 + fi + + test $help -eq 1 && help + echo "Send suggestions and bug reports to <$mail_feedback> + " + test $help -eq 1 && exit 1 + + echo " + ${extd}`L "Basic Setup" "Basis-Installation"`${norm}" + echo if [ "$src" = "0" ]; then - echo "Skipped." + echo `L "Skipped" "Übergangen"`. else - echo -n "checking for tar... " + echo -n "`L 'checking for tar... ' 'Überprüfe tar... '`" chk=`which tar 2> /dev/null` - if [ -n "$chk" ]; then + if [ $? -eq 0 ]; then echo "`tar --version | head -n 1 -` ($chk)" else - msg_missed - echo - echo "`basename $0`: Could not find \`tar' which is required to extract the archive." - exit 254 + echo "$rc_missed + " + echo "${appname}: Could not find \`tar' which is required to extract \ + the archive." >&2 + exit 2 fi - echo -n "checking for gzip... " + echo -n "`L 'checking for gzip... ' 'Überprüfe gzip... '`" chk=`which gzip 2> /dev/null` - if [ -n "$chk" ]; then + if [ $? -eq 0 ]; then echo "`gzip --version | head -n 1 -` ($chk)" else - msg_missed - echo - echo "`basename $0`: Could not find \`gzip' which is required to extract the archive." - exit 253 + echo "$rc_missed + " + echo "${appname}: Could not find \`gzip' which is required to extract \ + the archive." >&2 + exit 3 fi - echo -n "checking for source path... " - if [ "$src" = "-" ]; then - src=`dirname $0` - fi + test "$src" = "-" && src=`pwd` + + test -n "$download" && { + if [ -d "$src" ]; then + src2="-P $src" + else + src2="-O $src" + fi + test "$download" = "-" && download=$download_default + echo -n "`L "downloading archive from $download... " \ + "Archiv wird von $download heruntergeladen... "`" | $fold + if [ $verbose -eq 1 ]; then + echo + wget "$download" $src2 + else + wget_out=`wget "$download" $src2 2>&1` + fi + if [ $? -ne 0 ]; then + echo "$rc_failed + " + test $verbose -eq 0 && echo "$wget_out" + echo + exit 6 + else + echo $rc_done + fi + } + + echo -n "`L 'checking for source path... ' 'Überprüfe Quellpfad... '`" if [ -d "$src" ]; then - echo "directory: $src" | fold -s - echo -n "checking for archive... " + echo "`L directory Verzeichnis`: $src" | fold -s + echo -n "`L 'checking for archive... ' 'Überprüfe Archiv... '`" 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 - msg_missed - echo - exit 252 + echo "$rc_missed + " + exit 4 fi else - echo "file: $src" - echo -n "checking for archive... " + echo "`L file Datei`: $src" + echo -n "`L 'checking for archive... ' 'Überprüfe Archiv... '`" if [ -f "$src" ]; then - msg_done + echo $rc_done else - msg_missed - echo - exit 252 + echo "$rc_missed + " + exit 4 fi fi - echo -n "checking for target directory... " + echo -n "`L 'checking for target directory... ' \ + 'Überprüfe Zielverzeichnis... '`" if [ "$target" = "-" ]; then - target=/tmp + target="/tmp" fi if [ -d "$target" ]; then echo $target + echo -n "`L 'extracting files... ' \ + 'Archiv wird entpackt... '`" if [ $verbose -eq 1 ]; then - echo "extracting files..." + echo tar xvzf $src -C $target else - echo -n "extracting files... " tar_out=`tar xvzf $src -C $target 2>&1` fi if [ $? -ne 0 ]; then - msg_failed - echo + echo "$rc_failed + " if [ $verbose -eq 0 ]; then echo "$tar_out"; fi echo - exit 250 + exit 6 else - msg_done + echo $rc_done fi - echo -n "checking for mozilla-installer... " - if [ -x "$target/mozilla-installer/mozilla-installer" ]; then - msg_done + echo -n "`L "checking for $installer... " \ + "Überprüfe $installer... "`" + if [ -f "$target/$installer/$installer" ] \ + && [ -x "$target/$installer/$installer" ]; then + echo $rc_done KillMoz - echo "starting mozilla-installer..." - $target/mozilla-installer/mozilla-installer + echo + moz_ver=`grep pub/ $target/$installer/config.ini | uniq | \ + sed 's%.*/pub/\(.*\)/linux-xpi/%\1%'` + test -n "$moz_ver" && echo "`L "Installing $moz_ver" \ + "Installiert wird $moz_ver"`." + echo -n "$(L "Waiting for \`$installer' to finish + (close all Mozilla windows to continue!)... " \ + "Warte auf \`$installer' + (zum Fortsetzen alle Mozilla-Fenster schliessen!)... ")" + # ` + + # save current working directory before changing it (fixes XPI setup bug) + cwd=`pwd 2> /dev/null` + + cd $target/$installer/ + out="`./$installer 2>&1`" if [ $? -eq 0 ]; then - msg_done; echo + echo $rc_done; echo + test -n "$out" && echo " + $out + " + # check if `df' is supported + chk="`df "$target" 2>/dev/null`" + if [ $? -eq 0 ]; then + # check if -h option is supported + chk2="`df -h "$target" 2>/dev/null`" + if [ $? -eq 0 ]; then + chk="$chk2" + else + # check if --human-readable option is supported + chk2="`df --human-readable "$target" 2>/dev/null`" + test $? -eq 0 && chk="$chk2" + fi + test -n "$chk" && echo "$chk + " + fi answer="0" - while [ "$answer" != "y" ] && [ "$answer" != "n" ]; do - read -p "Clean up NOW ([y]es / [n]o / [i]nfo)? " -n 1 answer + while [ "$answer" != "`L y j`" ] && [ "$answer" != "n" ]; do + read -p "`L 'Clean up NOW ([y]es | [n]o | [i]nfo)?' \ + 'JETZT aufräumen ([j]a | [n]ein | [i]nfo)?'` " -n 1 answer echo - if [ "$answer" = "y" ]; then - echo - echo -n "cleaning up... " - rm -r $target/mozilla-installer &> /dev/null - if [ $? -eq 0 ]; then - msg_done - else - msg_failed - fi - elif [ "$answer" = "n" ]; then - echo - echo -e "OK. If not needed anymore, you should \`rm -r $target/mozilla-installer'\nto save diskspace." - elif [ "$answer" = "i" ]; then - echo - echo "\"Yes\" means that the directory and files" - echo "extracted from the archive will be removed." - echo - fi + case "$answer" in + `L y j`) + echo + echo -n "`L 'cleaning up' 'Aufräumen'`... " + + # up one directory before removal (secure method) + cd .. + + out="`rm -r $target/$installer 2>&1`" + if [ $? -eq 0 ]; then + echo $rc_done + else + echo $rc_failed + test -n "$out" && echo " + $out + " + fi + break;; + n) + echo " + -------------------------------------------------------------------- + `L 'OK. If not needed anymore, you should' 'OK. Wenn nicht länger benötigt, \ + sollten Sie'` + + rm -r $target/$installer + + `L 'to free disk space.' 'ausführen, um Speicherplatz freizugeben.'` + --------------------------------------------------------------------" + break;; + i) + echo " + -------------------------------------------------------------------- + `L "\\"Yes\\" means that the setup directory extracted from the archive will + be removed to free disk space. + + \\"No\\" keeps the setup files and allows you to reinstall Mozilla with" \ + "\\"Ja\\" bedeutet, dass das aus dem Archiv entpackte Setup-Verzeichnis + entfernt wird, um Speicherplatz freizugeben. + + \\"Nein\\" belässt die Setup-Dateien an ihrer Position, was es Ihnen + gestattet, Mozilla mit"` + + $target/$installer/$installer + + `L "if something goes wrong." "neu zu installieren, falls es Probleme gibt."` + -------------------------------------------------------------------- + " | $fold + ;; + esac done - else - msg_failed - echo - exit 248 - fi - else - echo "not found or executable bit not set" - echo - exit 249 - fi - else - msg_missed - echo - echo "`basename $0`: $target: Unable to find target directory." - echo - exit 251 - 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 + # back to previous directory + test -n "$cwd" && cd "$cwd" else - msg_done + echo $rc_failed + test -n "$out" && echo " + $out + " + exit 8 fi else - msg_missed + echo "${warn}not found or executable bit not set${norm} + " + exit 7 fi else - msg_missed - fi - echo - fi + echo "$rc_missed - if [ $flash -eq 1 ]; then - 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" + ${appname}: ${target}: Unable to find target directory. + " + exit 5 fi fi - if [ "$apps" != "" ]; then - 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 - msg_done - continue - KillMoz - else - msg_failed - fi - fi - done - fi + test $import -eq 1 && PluginImport + test $flash -eq 1 && FlashSetup - echo -e "\n\n\033[1mSetup complete.\033[m\n" + # for 0.3.5: customizable by `-d' option + mozdir=/usr/local/mozilla + + test $uninst -eq 1 -o $inst -eq 1 && XULsetup + test $truetype -eq 1 && EnableTrueType ${truetype_dirs[@]} + test $repair -eq 1 && MozRepair + + echo " + + ${extd}`L "Finalizing setup" "Installation wird abgeschlossen"`${norm} + " + UpdPerm + + echo " + + ${extd}`L "Setup finished" "Installation beendet"`.${norm} + "