#!/bin/bash
# 
# This script installs Swiftfox

# Download Swiftfox
echo " "
echo "The installer can only be used successfully by the root user.  Please make sure you are either using the sudo or su commands to gain root privileges before installing."
echo " "
cd /usr/lib
wget http://getswiftfox.com/builds/current/swiftfox-prescott.tar.bz2;

# Install Swiftfox
echo " "
echo "Installing Swiftfox..."

# If there is an existing swiftfox install here let's move it out of the way
mv swiftfox swiftfox.old

# Extract the build
tar -jxf swiftfox-prescott.tar.bz2

# Search for plugins
echo " "
echo "Searching for existing plugins, errors can be safely ignored..."
cp swiftfox.old/plugins/* swiftfox/plugins
cp /usr/lib/firefox/plugins/* swiftfox/plugins
cp /usr/lib/mozilla/plugins/* swiftfox/plugins
cp /usr/lib/mozilla-firefox/plugins/* swiftfox/plugins
cp /usr/lib/browser-plugins/* swiftfox/plugins
cp /usr/lib/xulrunner-addons/plugins/* swiftfox/plugins

# Make sure root owns the Swiftfox directory
chown -hR root:root swiftfox

# Add link in /usr/bin
ln -s /usr/lib/swiftfox/swiftfox /usr/bin/swiftfox

# Add Swiftfox to menu
cd /usr/share/applications
wget http://getswiftfox.com/builds/installer/Swiftfox.desktop

# Remove the downloaded tarball
rm /usr/lib/swiftfox-prescott.tar.bz2

echo " "
echo "Swiftfox has been installed. Happy Surfing!"
echo " "
exit

