#!/bin/bash

# This is a brief script on how to install important packages ubunutu for
############# ChesTech ############
# Stuff this script does:
### installs java and flash so that applications with firefox work
### adds appropriate lines to sources.list and installs scratch
### installs vim and emacs for text editing
### adds Firefox and OpenOfficeWriter icons to desktop
### installs a theme to make ubunutu look like Windows XP
### updates current packages so that we're up-to-date (might take a while)

# to run this file, right click and select "Properties" from the drop-down
# menu. Then click on the "Permissions" tab and check the "Allow executing file
# as program" box. This will allow you to run the script. (eek!) Now open up a
# terminal and navigate to the Downloads folder and run ./ubuntu-install.sh

# move ChesTechInstaller to home directory
cd ..
mv ChesTechInstaller ~/

# move to home directory
cd ~/ChesTechInstaller

# add Scratch to sources.list so we can install it with apt-get (below)
# note that we only add it if it's not already there. Thus we grep for it
# and if return status ($?) is zero, it's already in the file
grep -q scratch /etc/apt/sources.list
if [ $? == 0 ]; then
	echo "Scratch already in /etc/apt/sources.list"
else
	echo "Adding Scratch to /etc/apt/sources.list"
	echo -e "\n#Scratch 1.4 PPA" | sudo tee -a /etc/apt/sources.list
	echo "deb http://ppa.launchpad.net/scratch/ppa/ubuntu karmic main" | sudo tee -a /etc/apt/sources.list
	echo "deb-src http://ppa.launchpad.net/scratch/ppa/ubuntu karmic main" | sudo tee -a /etc/apt/sources.list

	# make sure that apt-get update doesn't freak out about the GPG key
	sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 4EA7974E
fi

# install java, flash, vim, emacs, and scratch
sudo apt-get -y update 
sudo apt-get -y install sun-java6-jre sun-java6-plugin sun-java6-fonts flashplugin-nonfree vim emacs scratch

# add .desktop files -- icons for the desktop
cp Desktop-Files/*.desktop ~/Desktop/

# install XP theme
# here's the website http://ubuntu.online02.com/node/14
mkdir -p XpTheme && mv XpGnome.tar.gz XpTheme && cd XpTheme
tar -xvvzf XpGnome.tar.gz
./InstallXpGnome.sh
# this is the download location, if you're curious
# wget http://ubuntu.online02.com/files/XpGnome.tar.gz

# upgrade all packages
sudo apt-get -y upgrade
