--- 2003-03-14-15/mozilla-linux-setup Fri Mar 14 15:19:42 2003 +++ latest/mozilla-linux-setup Fri Mar 28 23:44:59 2003 @@ -1,5 +1,5 @@ #!/bin/bash - ver="0.3.5a.2003031415" + ver="0.3.5a.2003032823" copy="2002, 2003" mail="PointedEars@gmx.de" mail_feedback="bug-mozilla@PointedEars.de" @@ -85,9 +85,17 @@ mail_feedback="bug-mozilla@PointedEars.d # * Basic user agent setup: Accept installer binary and skip extraction # * Optimize portability: Does this require `bash' or would `sh' suffice? # (to be tested on IRIX 6.5) - # * `-D', `--download': Use the gzipped tarball downloaded by external script - # thx to Michael Heisig , see the - # subthread + # * `-D', `--download': + # Define the resource from where to download the gzipped tarball first + # (use wget). The file is downloaded to the location specified by SOURCE. + # * `-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 + # * `-C', `--clean-up': + # Removes the previously extracted mozilla installer directory # * Cosmetics: # - More modular code (incomplete) # - Use parameter expansion whereever possible, like ${foo:-bar} and @@ -95,6 +103,18 @@ mail_feedback="bug-mozilla@PointedEars.d # # ---------------------------------------------------------------------------- + # 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 + + function L { + case $lg in + de) echo "${2:-$1}";; + *) echo "$1";; + esac + } + # from /etc/rc.status if test -z "$LINES" -o -z "$COLUMNS" ; then @@ -108,10 +128,10 @@ if test "$TERM" != "raw" && stty size >/ esc=`echo -en "\033"` extd="${esc}[1m" warn="${esc}[1;31m" - done="${esc}[1;32m" + done="${esc}[1m" attn="${esc}[1m" norm=`echo -en "${esc}[m\017"` - stat=`echo -en "\015${esc}[${COLUMNS}C${esc}[10D"` + stat=`echo -en "\015${esc}[${COLUMNS}C${esc}[14D "` else esc="" extd="" @@ -119,17 +139,9 @@ else done="" attn="" norm="" - stat="" + stat="... " fi - rc_done="${extd}done${norm}" - rc_running="${stat}${done}running${norm}" - rc_failed="${warn}failed${norm}" - rc_missed="${warn}not found${norm}" - rc_skipped="${attn}skipped${norm}" - rc_done_up="${esc}[1A${rc_done}" - rc_failed_up="${esc}[1A${rc_failed}" - # check for fold fold="fold -sw $COLUMNS" chk=`which fold 2> /dev/null` @@ -159,41 +171,17 @@ rc_failed_up="${esc}[1A${rc_failed}" fi 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 - - function L { - case $lg in - de) echo "${2:-$1}";; - *) echo "$1";; - esac - } - - function msg_done { - echo $rc_done - } - - function msg_failed { - echo $rc_failed - } - - function msg_missed { - echo $rc_missed - } - function help { echo -n " ${extd}`basename $0`${norm} [${extd}-?${norm}] [${extd}-v${norm}] \ [${extd}-L${norm} LOCALE] [${extd}-I${norm} INSTALLER] [${extd}-U${norm} \ - [USER]] [${extd}-R${norm}] SOURCE [TARGET] + [USER]] [${extd}-R${norm}] [${extd}-D${norm} RESOURCE] [( ${extd}-c${norm} | ${extd}-s${norm} | ${extd}-h${norm} ) [SOURCE] \ [PLUGIN_DIR] [...] [${extd}-0io${norm}]] - [${extd}-f${norm} [PLUGIN_DIR] [INST_PATH] [TGZ_PATH]] [ ( ${extd}-i${norm} \ - | ${extd}-u${norm} ) [APP_NAME] [...]] - [${extd}-d${norm} [MOZ_DIR]] + [${extd}-f${norm} [PLUGIN_DIR] [INST_PATH] [TGZ_PATH]] + [ ( ${extd}-i${norm} | ${extd}-u${norm} ) [APP_NAME] [...]] [${extd}-d${norm} [MOZ_DIR]] + SOURCE [TARGET] ${extd}-?${norm}, ${extd}--help${norm} " L "Show this help and exit." \ @@ -236,7 +224,7 @@ ${extd}`L "BASIC USER-AGENT SETUP" \ ${extd}`basename $0`${norm} [...] [${extd}-I${norm} INSTALLER] [${extd}-U${norm} [USER]] \ - [${extd}-R${norm}] SOURCE [TARGET] [...] + [${extd}-R${norm}] [${extd}-D${norm} RESOURCE] SOURCE [TARGET] [...] ${extd}-I${norm}, ${extd}--installer${norm} " L "Use the installer program specified by INSTALLER." \ @@ -321,6 +309,15 @@ L "Terminate all Mozilla processes and r SIGTERM(15) nicht funktioniert, wird SIGKILL(9) gesendet und Benutzer werden nicht gespeicherte Daten verlieren!" | $fmt + echo -n " ${extd}-D${norm}, ${extd}--download${norm} " + L "Download \`mozilla-installer' archive from" \ + "Archiv mit \`mozilla-installer' vor dem Entpacken" | $fold + L "\ + RESOURCE to SOURCE before extracting it. + ${extd}For future use.${norm}" \ + "\ + von RESOURCE nach SOURCE herunterladen. + ${extd}Für zukünftige Verwendung.${norm}" | $fmt echo -n " SOURCE " L "\`mozilla-installer' archive path. Required." \ "Pfad für Archiv mit \`mozilla-installer'. Erforderlich." | $fold @@ -360,9 +357,9 @@ ADD-ONS"`${norm} ${extd}`basename $0`${norm} [...] [( ${extd}-c${norm} | ${extd}-s${norm} | \ ${extd}-h${norm} ) [SOURCE] [PLUGIN_DIR] [...] [${extd}-0io${norm}]] - [${extd}-f${norm} [PLUGIN_DIR] [INST_PATH] [TGZ_PATH]] [ ( ${extd}-i${norm} \ - | ${extd}-u${norm} ) [APP_NAME] [...]] - [${extd}-d${norm} [MOZ_DIR]] + [${extd}-f${norm} [PLUGIN_DIR] [INST_PATH] [TGZ_PATH]] + [ ( ${extd}-i${norm} | ${extd}-u${norm} ) [APP_NAME] [...]] \ + [${extd}-d${norm} [MOZ_DIR]] ${extd}-c${norm}, ${extd}--copy${norm} " L "Copy plugin files from another installation of Mozilla or" \ @@ -463,7 +460,7 @@ L "\ "\ Type \`flash-linux-installer' for further information." \ | $fmt - echo " PLUGIN_DIR Mozilla plugin directory after installation. Leave this out + echo " PLUGIN_DIR Mozilla plugin directory after installation. Leave this out or use \`-' for the default (/usr/local/mozilla/plugins). If -c, -s or -h was used before with specifying PLUGIN_DIR (including \`-'), that value is used instead @@ -553,26 +550,26 @@ Copying plugins..." fi done if [ $? -ne 0 ]; then - msg_failed - echo + echo "$rc_failed + " else - msg_done + echo $rc_done fi elif [ -f "$importSource" ]; then echo "file: $importSource" echo " copying $importSource..." cp -irpv $importSource $importTarget if [ $? -ne 0 ]; then - msg_failed - echo + echo "$rc_failed + " else - msg_done + echo $rc_done fi else - msg_missed + echo $rc_missed fi else - msg_missed + echo $rc_missed fi done fi @@ -605,26 +602,26 @@ Symlinking plugins..." fi done if [ $? -ne 0 ]; then - msg_failed - echo + echo "$rc_failed + " else - msg_done + echo $rc_done fi elif [ -f "$importSource" ]; then echo "file: $importSource" echo " creating symbolic link for $importSource..." cp -irpsv $importSource $importTarget if [ $? -ne 0 ]; then - msg_failed - echo + echo "$rc_failed + " else - msg_done + echo $rc_done fi else - msg_missed + echo $rc_missed fi else - msg_missed + echo $rc_missed fi done fi @@ -657,26 +654,26 @@ Hardlinking plugins..." fi done if [ $? -ne 0 ]; then - msg_failed - echo + echo "$rc_failed + " else - msg_done + echo $rc_done fi elif [ -f "$importSource" ]; then echo "file: $importSource" echo " creating hard link for $importSource..." cp -ilrpv $importSource $importTarget if [ $? -ne 0 ]; then - msg_failed - echo + echo "$rc_failed + " else - msg_done + echo $rc_done fi else - msg_missed + echo $rc_missed fi else - msg_missed + echo $rc_missed fi done fi @@ -695,13 +692,13 @@ ${extd}Macromedia Flash plugin setup${no echo "$flashInstPath" else flash=0 - msg_missed + echo $rc_missed fi elif [ -x "$flashInstPath" ]; then echo "$flashInstPath" else flash=0 - msg_missed + echo $rc_missed fi if [ $flash -ne 0 ]; then $flashInstPath $flashPluginDir @@ -728,7 +725,7 @@ function KillMoz { killall $1 mozilla-bin 2> /dev/null result=$? if [ $result -ne 0 ]; then - msg_failed + echo $rc_failed else ping=1 mozilla -remote "ping()" 2> /dev/null @@ -751,13 +748,13 @@ $ping Versuche unternommen. Drücken Sie fi done if [ $error -ne 0 ]; then - msg_done + 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 - msg_failed + echo $rc_failed test $verbose -eq 1 && \ L " Mozilla was pinged "$ping" times without response. @@ -799,13 +796,13 @@ $ping Versuche unternommen. Drücken Sie fi done if [ $error -eq 0 ]; then - msg_done + 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 - msg_failed + echo $rc_failed test $verbose -eq 1 && \ L " Mozilla was pinged "$ping" times without response. @@ -816,7 +813,11 @@ Bitte überprüfen Sie ihre Mozilla-Instal fi else mozilla -remote "openURL($1,new-tab)" & - if [ $? -eq 0 ]; then msg_done; else msg_failed; fi + if [ $? -eq 0 ]; then + echo $rc_done + else + echo $rc_failed + fi fi } @@ -832,7 +833,7 @@ function XULisInstd { function XULuninst { for u in $1; do if [ -n "$u" ]; then KillMoz - echo -n " $u... " + echo -n " $u$stat" if XULisInstd "$u"; then rm -rf $mozdir/chrome/$u* #2> /dev/null @@ -855,10 +856,10 @@ function XULuninst { test $? -eq 0 && mv $mozdir/chrome/installed-chrome.txt.new \ $mozdir/chrome/installed-chrome.txt if [ $? -eq 0 ]; then - msg_done + echo $rc_done else echo $? - msg_failed + echo $rc_failed fi else echo "${extd}not installed${norm}" @@ -866,21 +867,47 @@ function XULuninst { fi; done } + 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 + 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 + } + function XPInst { for i in $1; do # to be removed when RunMoz works instead of direct call - KillMoz + # KillMoz local f=$i - echo -n " $f... " + echo -n " $f" if [ ! -f "$f" ]; then - msg_missed - echo -n " trying $f.xpi... " + echo -n ".xpi$stat" if [ -f "$f.xpi" ]; then f=$f.xpi else - msg_failed + echo "$rc_failed" continue fi + else + echo -n "$stat" fi if [ -f "$f" ]; then # TO DO: Automagic uninstall requires $i = `basename $i` =~ s/-.*?\.xpi// @@ -889,11 +916,15 @@ function XPInst { # $i is already installed. Performing automagic uninstall first... " # XULuninst "$i" # fi - mozilla "file://"`pwd`"/$f" + # if isMozRunning && mozilla -remote 'ping()' 2>/dev/null ; then + # mozilla -remote 'openURL(file://'`pwd`'/$f)' + # else + mozilla "file://"`pwd`"/$f" # & + # fi if [ $? -eq 0 ]; then - msg_done + echo "$rc_done" else - msg_failed + echo "$rc_failed" return 1 fi fi @@ -922,12 +953,12 @@ Installing XPIs. You need to quit Mozill function MozRepairFiles { local result=0 for f in $1; do - test $verbose -eq 1 && echo -n " $f... " + 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 && msg_done + test $verbose -eq 1 && echo "$rc_done" else - test $verbose -eq 1 && msg_failed + test $verbose -eq 1 && echo "$rc_failed" let result++; fi done @@ -951,9 +982,9 @@ ${extd}`L "Repair of an existing install sVerbose= if [ $verbose -eq 0 ]; then if [ $? -eq 0 ]; then - msg_done + echo $rc_done else - msg_failed + echo $rc_failed fi fi } @@ -964,7 +995,7 @@ function UpdPerm { "Zugriffsrechte werden aktualisiert"`... " chmod -R go+r $mozdir/chrome/* 2> /dev/null test $? -eq 0 && chmod -R 755 $mozdir/chrome/mozgest/* 2> /dev/null - msg_done + echo $rc_done } echo " @@ -1083,6 +1114,14 @@ while [ -n "$1" ]; do shift 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 @@ -1151,59 +1190,59 @@ echo if [ "$src" = "0" ]; then echo `L "Skipped" "Übergangen"`. else - echo -n "checking for tar... " + echo -n "`L 'checking for tar... ' 'überprüfe auf tar... '`" chk=`which tar 2> /dev/null` if [ $? -eq 0 ]; then echo "`tar --version | head -n 1 -` ($chk)" else - msg_missed - echo + echo "$rc_missed + " echo "`basename $0`: 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 auf gzip... '`" chk=`which gzip 2> /dev/null` if [ $? -eq 0 ]; then echo "`gzip --version | head -n 1 -` ($chk)" else - msg_missed - echo + echo "$rc_missed + " echo "`basename $0`: Could not find \`gzip' which is required to extract \ the archive." >&2 exit 3 fi - echo -n "checking for source path... " + echo -n "`L 'checking for source path... ' 'überprüfe Quellpfad... '`" if [ "$src" = "-" ]; then src=`dirname $0` fi 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 + echo "$rc_missed + " exit 4 fi else echo "file: $src" - echo -n "checking for archive... " + echo -n "`L 'checking for archive... ' 'überprüfe Archiv... '`" if [ -f "$src" ]; then - msg_done + echo $rc_done else - msg_missed - echo + echo "$rc_missed + " exit 4 fi fi - echo -n "checking for target directory... " + echo -n "checking for target directory... " if [ "$target" = "-" ]; then target="/tmp" fi @@ -1214,22 +1253,22 @@ the archive." >&2 echo "extracting files..." tar xvzf $src -C $target else - echo -n "extracting files... " + 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 6 else - msg_done + echo $rc_done fi echo -n "checking for $installer... " if [ -f "$target/$installer/$installer" ] \ && [ -x "$target/$installer/$installer" ]; then - msg_done + echo $rc_done KillMoz echo -n " Waiting for \`$installer' to finish @@ -1241,7 +1280,7 @@ Waiting for \`$installer' to finish cd $target/$installer/ out="`./$installer 2>&1`" if [ $? -eq 0 ]; then - msg_done; echo + echo $rc_done; echo test -n "$out" && echo " $out " @@ -1274,9 +1313,9 @@ $out out="`rm -r $target/$installer 2>&1`" if [ $? -eq 0 ]; then - msg_done + echo $rc_done else - msg_failed + echo $rc_failed test -n "$out" && echo " $out " @@ -1312,7 +1351,7 @@ if something goes wrong. # back to previous directory test -n "$cwd" && cd "$cwd" else - msg_failed + echo $rc_failed test -n "$out" && echo " $out " @@ -1324,8 +1363,8 @@ $out exit 7 fi else - msg_missed - echo " + echo "$rc_missed + `basename $0`: $target: Unable to find target directory. " exit 5