#!/bin/sh

# This script will install Firefox 3.0.5 on your Ubuntu Linux system
# This script must be run as root with 755 permission
#
# Authored by Bob Nelson  admin@stchman.com
#

script_name="firefox_install.sh"

# Script must run as root 
if [ $USER != "root" ]; then
	echo "You need to run this script as root."
	echo "Use 'sudo ./$script_name' then enter your password when prompted."
	exit 1
fi

# remove the old firefox
sudo apt-get -y autoremove firefox

# Change to the users home folder
cd ~

#Get the Firefox 3.0.5 .tar.bz2 file from www.stchman.com
wget http://www.stchman.com/tools/firefox/firefox-3.0.5.tar.bz2

# Unpack the .tar.bz2 archive to the /opt folder, this will create a /opt/firefox folder
sudo tar -jxvf ~/firefox-3*.tar.bz2 -C /opt

# Create a symbolic link in the /usr/bin folder
sudo ln -s /opt/firefox/firefox /usr/bin/firefox

# Create a menu item
# There will be a menu entry in Applications--->Internet
sudo echo "[Desktop Entry]" > /usr/share/applications/firefox.desktop
sudo echo "Encoding=UTF-8" >> /usr/share/applications/firefox.desktop
sudo echo "Name=Firefox"  >> /usr/share/applications/firefox.desktop
sudo echo "Comment=Firefox Web Browser"  >> /usr/share/applications/firefox.desktop
sudo echo "Exec=/opt/firefox/firefox"  >> /usr/share/applications/firefox.desktop
sudo echo "Icon=/opt/firefox/icons/mozicon16.xpm"  >> /usr/share/applications/firefox.desktop
sudo echo "StartupNotify=true"  >> /usr/share/applications/firefox.desktop
sudo echo "Terminal=false"  >> /usr/share/applications/firefox.desktop
sudo echo "Type=Application"  >> /usr/share/applications/firefox.desktop
sudo echo "Categories=Applications;Network;"  >> /usr/share/applications/firefox.desktop

# Remove .tar.bz2 as it is no longer needed
sudo rm -f ~/firefox-3*.tar.bz2


