#!/bin/sh

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

script_name="filezilla_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

# Change to the users home folder
cd ~

#Get the FileZilla 3.0.11 .tar.gz file from www.stchman.com
wget http://www.stchman.com/tools/filezilla/FileZilla_3.0.11_i586-linux-gnu.tar.bz2 

# Unpack the .tar.bz2 archive to the /opt folder, this will create a /opt/FileZilla3 folder
sudo tar -xvjpf ~/FileZilla_3.0.11_i586-linux-gnu.tar.bz2 -C /opt

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

# Create a menu item
# There will be a menu entry in Applications--->Internet
sudo echo "[Desktop Entry]" > /usr/share/applications/filezilla.desktop
sudo echo "Encoding=UTF-8" >> /usr/share/applications/filezilla.desktop
sudo echo "Name=FileZilla"  >> /usr/share/applications/filezilla.desktop
sudo echo "Comment=FileZilla FTP Client"  >> /usr/share/applications/filezilla.desktop
sudo echo "Exec=filezilla"  >> /usr/share/applications/filezilla.desktop
sudo echo "Icon=/opt/FileZilla3/share/pixmaps/filezilla.png"  >> /usr/share/applications/filezilla.desktop
sudo echo "StartupNotify=true"  >> /usr/share/applications/filezilla.desktop
sudo echo "Terminal=false"  >> /usr/share/applications/filezilla.desktop
sudo echo "Type=Application"  >> /usr/share/applications/filezilla.desktop
sudo echo "Categories=Applications;Network;"  >> /usr/share/applications/filezilla.desktop

# Remove .tar.gz as it is no longer needed
rm -f ~/FileZilla_3.0.11_i586-linux-gnu.tar.bz2 

# Hope you find this useful

