#!/bin/bash
# 2013-01-19 07:33:38+00:00 category5.tv
##  This is a script adpated by Jonathan Garbee from an older version of Perfectbuntu
##  ( http://perfectbuntu.category5.tv ) written by Robbie Ferguson.  
####
# Do NOT ask for software to be added into the main script.  What is provided is
# only to be used as a framework for your customization.
## 

# Script start
echo
echo Custom Install Script
echo Version 0.3
echo
echo
echo "Starting the script"
sleep 2s
# If you are needing to do something that requires your username as you run the script,
# use MAIN_USER to insert that name, since if things are done as super-user it then
# is root vs your actual username.  The next snippit of code gets your user, and sets
# it to MAIN_USER for use even as root.
echo "Getting and storing the current username."
MAIN_USER="$USER"
echo
sleep 3s
echo "Checking for super-user access"
#sleep 5
sudo echo "Access Granted."
echo
echo "Time for install"
echo
sleep 2s

# Ask if they want to install their stuff
echo -en
read -p "Do you want to update your system? (Y/N)"
echo -en
if [ "$REPLY" = "y" -o "$REPLY" = "Y" ] ; then
UPDATE="1"
fi
echo
echo
echo -en
read -p "Do you want to install apps that you have set from the default repositories? (Y/N)"
echo -en
if [ "$REPLY" = "y" -o "$REPLY" = "Y" ] ; then
CUSTOM="1"
fi
echo
echo
echo -en
read -p "Do you want to install Virtualbox from their repository? (Y/N)"
echo -en
if [ "$REPLY" = "y" -o "$REPLY" = "Y" ] ; then
VIRTUALBOX="1"
fi 


# Now that selections are made, lets add any needed repositories.

echo
touch /tmp/custom_install_sources


# This is an example of a Repository that requires it manually be added.
## This is not meant to be run twice.  Otherwise it will keep adding extra lines in /etc/apt/sources.list.
## If you re-run, either comment this area out or delete the line(s) added from /etc/apt/sources.list.

if [ "$VIRTUALBOX" = "1" ]; then
echo -e "\n \n ##Oracle Virtualbox Repository \n deb http://download.virtualbox.org/virtualbox/debian oneiric contrib" >> /tmp/custom_install_sources
wget -q http://download.virtualbox.org/virtualbox/debian/oracle_vbox.asc -O- | sudo apt-key add -
fi
fi

cat /tmp/custom_install_sources | sudo tee -a /etc/apt/sources.list

sudo apt-get update


# Time to install the packages

# Update the system
if [ "$UPDATE" = "1" ]; then
echo "Updating your base system."
sudo apt-get update && sudo apt-get -y dist-upgrade
echo Done.
fi

# Install the users custom software packages from the main repository
# This is the command to edit for your software packages.  Simply remove
# everything after "install" in the sudo apt-get line (as if you are actually
# installing by hand).  This line will auto-install all the software specified
# without asking.
###  I prefer not to add things from other repositories in this area since they
###  could require extra stuff, like Virtualbox.  You *can* though and have no
###  problems.
if [ "$CUSTOM" = "1" ]; then
echo "Installing your stuff"
sleep 3s
sudo apt-get --force-yes -y -f -m install ubuntu-restricted-extras filezilla putty gufw preload gimp gimp-data-extras gimp-plugin-registry shutter
echo Done.
fi

# Install Virtualbox from Oracles Repository
if [ "$VIRTUALBOX" = "1" ]; then
echo "Virtualbox eh?..."
sleep 3s
sudo apt-get --force-yes -y -f -m install build-essential virtualbox-4.1
sudo usermod -G vboxusers -a $MAIN_USER
echo "You will need to logout before you can fully use Virtualbox."
sleep 4s
fi

#  Cleaning the packages out of the cache.
echo "Cleaning some packages out of the cache."
sudo apt-get clean

# Script end.
echo Done.
echo
echo "All done.  Wasn't that painless?"
sleep 5s


syntax highlighted by Code2HTML, v. 0.9.1