#!/bin/bash # # installnewfirefox.sh # Script to automatically download and install the newest firefox version for linux, on an Ubuntu system. # Requires an internet connection to work (obviously). # # Author: nanotube . # # Version: installnewfirefox.sh 1.9 22-Aug-2006 nanotube@users.sf.net # # Modified: 24-Oct-2006 by aysiu, updated for Edgy, allows for a previous /opt installation and gets rid of key signature verification ####### ## Make sure that we exit if any commands do not complete successfully. set -o errexit trap 'echo "Previous command did not complete successfully. Exiting."' ERR ## Set version-specific variables if grep -q "5.10" /etc/issue ; then PLUGINPATH=/usr/lib/mozilla-firefox/plugins elif grep -q "6.06" /etc/issue ; then PLUGINPATH=/usr/lib/firefox/plugins elif grep -q "6.10" /etc/issue ; then PLUGINPATH=/usr/lib/firefox/plugins else echo "This script only works on Breezy or Dapper or Edgy." exit 1 fi ## Get the newest firefox release version from mozilla website VERSION=`wget -q -O - http://www.mozilla.com |grep "product=" -m 1 |sed -e 's/.*
  • .*firefox-//' -e 's/&.*//'` echo -e -n "The most recent release of firefox is detected to be $VERSION. Please make sure this is correct before proceeding. (You can confirm by going to http://www.mozilla.com/) Is it correct [y/n]? " while true do read ans case $ans in Y|y) break ;; [Yy][Ee][Ss]) break ;; N|n) echo "If this does not agree with the latest version as listed on mozilla.com, please contact nanotube@users.sf.net and let me know."; exit ;; [Nn][Oo]) echo "If this does not agree with the latest version as listed on mozilla.com, please contact nanotube@users.sf.net and let me know."; exit ;; *) echo -n "Invalid command. Please answer yes or no [y/n] " ;; esac done ## Get available localizations LOCALIZATIONS=( `wget -q -O - http://ftp.mozilla.org/pub/mozilla.org/firefox/releases/$VERSION/linux-i686/ | grep 'a href="' | grep -v "xpi" | grep -v "Name" | sed -e 's/.*@@'` ) LIMIT=${#LOCALIZATIONS[*]} ## Get user choice of localization echo "Please choose the localization (language) for firefox. Enter the number of your choice from the list below." for ((i=0; i < LIMIT ; i++)) do echo "$i: ${LOCALIZATIONS[$i]}" done CHOICE=$(($LIMIT + 1)) echo -n "Enter your choice of localization: " while [ "$CHOICE" -gt "$(($LIMIT-1))" -o "$CHOICE" -lt "0" ] do read CHOICE if echo -n "$CHOICE" | grep -q "[^0-9]"; then echo -n "Your input contains non-numeric characters. Please try again: " CHOICE=$(($LIMIT + 1)) continue elif [ -z "$CHOICE" ]; then echo -n "Please enter the number of your choice from the list: " CHOICE=$(($LIMIT + 1)) continue elif [ "$CHOICE" -gt "$(($LIMIT-1))" -o "$CHOICE" -lt "0" ]; then echo -n "Your input is not in the range of available localizations. Please try again: " fi done echo -n "You have chosen localization \"${LOCALIZATIONS[$CHOICE]}\". Is that correct [y/n]? " while true do read ans case $ans in Y|y) break ;; [Yy][Ee][Ss]) break ;; N|n) echo "In that case, start over by running this script again."; exit ;; [Nn][Oo]) echo "In that case, start over by running this script again."; exit ;; *) echo -n "Invalid command. Please answer yes or no [y/n] " ;; esac done ## Proceed to download and install firefox. echo -e "\nUpdating repositories list\n" sudo aptitude update echo -e "\nMaking sure libstdc++5 and the old Firefox are installed\n" sudo aptitude install firefox libstdc++5 if [ -d ~/.mozilla ]; then echo -e "\nBacking up old Firefox preferences\n" cp -R ~/.mozilla ~/.mozilla_backup_`date -Iseconds` else echo -e "\nOld firefox preferences not found. Nothing to back up. Proceeding with installation.\n" fi echo -e "\nChanging to home directory\n" cd echo -e "\nDownloading Firefox from the Mozilla site\n" wget -c http://ftp.mozilla.org/pub/mozilla.org/firefox/releases/$VERSION/linux-i686/${LOCALIZATIONS[$CHOICE]}/firefox-$VERSION.tar.gz # echo -e "\nDownloading Firefox signature from the Mozilla site\n" # wget -c # http://ftp.mozilla.org/pub/mozilla.org/firefox/releases/$VERSION/linux-i686/${LOCALIZATIONS[$CHOICE]}/firefox-$VERSION.tar.gz.asc # echo -e "\nImporting Mozilla Software Releases public key\n" # echo -e "Note that if you have never used gpg before on this system, and this is your first time running this script, there may be a delay of about a minute during the generation of a gpg keypair. This is normal and expected behavior.\n" # gpg --keyserver subkeys.pgp.net --recv 1AF32821 # echo -e "\nVerifying signature...\nNote: do not worry about \"untrusted key\" warnings. That is normal behavior for newly imported keys.\n" # gpg --verify firefox-$VERSION.tar.gz.asc firefox-$VERSION.tar.gz if [ -d /opt/firefox ]; then echo -e "\nDetected an older Mozilla Firefox installation. Removing it.\n" sudo rm -r /opt/firefox echo -e "\nUnzipping the .tar.gz file\n" sudo tar -C /opt -xzf firefox-$VERSION.tar.gz echo -e "\nRemoving the unzipped .tar.gz\n" rm -f firefox-$VERSION.tar.gz firefox-$VERSION.tar.gz.asc echo -e "\nLinking plugins\n" cd /opt/firefox/plugins/ sudo ln -s -f $PLUGINPATH/* . else echo -e "\nUnzipping the .tar.gz file\n" sudo tar -C /opt -xzf firefox-$VERSION.tar.gz echo -e "\nRemoving the unzipped .tar.gz\n" rm -f firefox-$VERSION.tar.gz firefox-$VERSION.tar.gz.asc echo -e "\nLinking plugins\n" cd /opt/firefox/plugins/ sudo ln -s -f $PLUGINPATH/* . echo -e "\nLinking launcher to new Firefox\n" sudo dpkg-divert --divert /usr/bin/firefox.ubuntu --rename /usr/bin/firefox sudo ln -s /opt/firefox/firefox /usr/bin/firefox sudo dpkg-divert --divert /usr/bin/mozilla-firefox.ubuntu --rename /usr/bin/mozilla-firefox sudo ln -s /opt/firefox/firefox /usr/bin/mozilla-firefox fi echo -e "\nThe new Firefox version $VERSION has been installed successfully." exit