#!/bin/sh

# This script will install the Kompozer precompiled package for Ubuntu Feisty
# This package will take the place of Nvu
# This script will also make an entry in your menu.  
# This script must be run as root with 755 permission
# Source of procedure https://help.ubuntu.com/community/Kompozer
#
# Authored by Bob Nelson  admin@stchman.com
#
# Script updated for latest version 0.7.10


script_name="kompozer.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
# This will be the place to download the archive temporarily
cd ~

# Download the Kompozer tar.gz file from www.stchman.com
wget http://www.stchman.com/tools/kompozer/kompozer-0.7.10-gcc4.0.3-i486.tar.gz

# Decompress the archive to a the /opt/ folder, the archive will create a kompozer folder under the /opt folder
sudo tar -C /opt -zxvf ~/kompozer-0.7.10-gcc4.0.3-i486.tar.gz

# make a symbolic link to the /usr/bin/ folder
sudo ln -s /opt/kompozer/kompozer /usr/bin/kompozer

# make menu entry in Appliation-->Development
# script will do this by creating a kompozer.desktop text file
# the > creates the file while >> appends to the file
sudo echo "[Desktop Entry]" > /usr/share/applications/kompozer.desktop
sudo echo "Name=Kompozer" >> /usr/share/applications/kompozer.desktop 
sudo echo "Name[ja]=Kompozer" >> /usr/share/applications/kompozer.desktop
sudo echo "Name[de]=Kompozer" >> /usr/share/applications/kompozer.desktop
sudo echo "Comment=Create and Edit Web Pages" >> /usr/share/applications/kompozer.desktop
sudo echo "Categories=GNOME;Application;Development;" >> /usr/share/applications/kompozer.desktop
sudo echo "Encoding=UTF-8" >> /usr/share/applications/kompozer.desktop
sudo echo "Exec=kompozer" >> /usr/share/applications/kompozer.desktop
sudo echo "Icon=/opt/kompozer/icons/mozicon50.xpm" >> /usr/share/applications/kompozer.desktop
sudo echo "Terminal=false" >> /usr/share/applications/kompozer.desktop
sudo echo "Type=Application" >> /usr/share/applications/kompozer.desktop

# Remove the precompiled archive as it is no longer needed
rm -r -f ~/kompozer-0.7.10-gcc4.0.3-i486.tar.gz

