#!/bin/sh

# Check to ensure script is running as root.
if [ `whoami` != root ]; then
echo "This script requires root privileges."
echo "Please run using 'sudo sh install.sh'"
echo "This script will now abort."
exit
fi


# Check for initial updates to the command line install.
echo "*		Updating your repositories"
apt-get -y update 
echo "*		Updating your packages"
apt-get -y dist-upgrade 

# Enable adding PPAs to source list.
echo "*		Installing software to modify your repositories"
apt-get -y -m  install python-software-properties

# Add Custom 3rd Party Personal Package Archives to list.
# add-apt-repository ppa:kevin-mehall/pithos-daily
# add-apt-repository ppa:banshee-team/banshee-daily
add-apt-repository ppa:elementaryart/elementarydesktop
add-apt-repository ppa:elementaryart/elementary-dev
add-apt-repository ppa:sgringwe/beatbox
# add-apt-repository ppa:moonlight-team/pinta
add-apt-repository ppa:vala-team/ppa
add-apt-repository ppa:postler-dev/ppa
add-apt-repository ppa:midori/ppa
# add-apt-repository ppa:gm-notify-maintainers/ppa

# Check for new updates to the command line install.
echo "*		Updating your repositories"
apt-get -y update 
echo "*		Updating your packages"
apt-get -y upgrade 

# Install the GNOME system.
echo "*		Installing the core system"
apt-get -y -m install xorg gdm elementary-desktop x11-xserver-utils jockey-gtk xscreensaver-gl-extra network-manager-gnome synaptic notify-osd brasero gdebi evince gedit file-roller cheese empathy ubuntu-mono light-themes dmz-cursor-theme ssh gcalctool gconf-editor transmission nautilus p7zip update-manager system-config-printer-gnome alacarte gconf-editor unrar pinta libxss1 gnome-terminal gnome-media gnome-power-manager eog pulseaudio ttf-droid abiword gnumeric gnome-system-monitor ubuntu-artwork plymouth-theme-ubuntu-logo appmenu-gtk libqtgui4 indicator-applet indicator-applet-appmenu indicator-appmenu compiz compizconfig-settings-manager nautilus-gksu indicator-application libglew1.5 gtk2-engines-pixbuf aptdaemon python-aptdaemon-gtk geany inkscape cups gcc xdg-user-dirs xdg-user-dirs-gtk gtk2-engines-aurora gnome-bluetooth bluetooth compizconfig-settings-manager update-notifier sessioninstaller pithos totem nautilus-wallpaper nautilus-open-terminal gnome-activity-journal beatbox indicator-session indicator-applet-complete valac cdrdao apturl telepathy-idle contractor dexter postler pantheon unity midori hpijs lame flac faad vorbis-tools ffmpeg libcurl3 # deb-thumbnailer gnome-system-tools gnome-utils gnome-screensaver gnome-core



# Configuration switches.
gconftool-2 -s --type bool  /apps/nautilus/desktop/volumes_visible  false
gconftool-2 -s /apps/metacity/general/button_layout -t String minimize,maximize,close:
gconftool-2 -s --type bool  /apps/gksu/sudo-mode  true
gconftool-2 -s --type bool  /apps/gdm/simple-greeter/disable_user_list true
gconftool-2 -s --type int /system/indicator/me/display 2
gconftool-2 -s /system/gstreamer/0.10/default/videosink -t String ximagesink
# gsettings set org.ayatana.indicator.datetime show-date true

# Install Cantarell Font.
mkdir /usr/share/fonts/truetype/ttf-cantarell/
wget http://git.gnome.org/browse/cantarell-fonts/plain/ttf/Cantarell-Bold.ttf
mv Cantarell-Bold.ttf /usr/share/fonts/truetype/ttf-cantarell/Cantarell-Bold.ttf
wget http://git.gnome.org/browse/cantarell-fonts/plain/ttf/Cantarell-Regular.ttf
mv Cantarell-Regular.ttf /usr/share/fonts/truetype/ttf-cantarell/Cantarell-Regular.ttf

# Install Android Tools.
wget http://in.hrhnick.com/linux-install/adb
chmod +x adb
mv adb /bin/adb
wget http://in.hrhnick.com/linux-install/sbf_flash
chmod +x sbf_flash
mv sbf_flash /bin/sbf_flash

# Install Restricted Extras.
while true
do
echo -n "Do you need Restricted Extras including non-free Flash, Codec, and DVD support? [Y/n]? "
read EXTRAS
case $EXTRAS in
y|Y|YES|yes|Yes) break ;;
n|N|no|NO|No) break ;;
*) 
esac
done
case "$EXTRAS" in
y|Y|YES|yes|Yes)
apt-get -y -m install ubuntu-restricted-extras libdvdread4 # w32codecs
sh /usr/share/doc/libdvdread4/install-css.sh
;;
*)
break
;;
esac

# Install Wireless Driver support.
while true
do
echo -n "Do you need Broadcom Wireless support [Y/n]? "
read WIRELESS
case $WIRELESS in
y|Y|YES|yes|Yes) break ;;
n|N|no|NO|No) break ;;
*) 
esac
done
case "$WIRELESS" in
y|Y|YES|yes|Yes)
apt-get -y -m install bcmwl-kernel-source
;;
*)
break
;;
esac

# Install Nvidia Driver support.
while true
do
echo -n "Do you need Nvidia Proprietary Graphics support [Y/n]? "
read GRAPHICS
case $GRAPHICS in
y|Y|YES|yes|Yes) break ;;
n|N|no|NO|No) break ;;
*) 
esac
done
case "$GRAPHICS" in
y|Y|YES|yes|Yes)
apt-get -y -m install nvidia-current
;;
*)
break
;;
esac


# Set variable $ARCH to processor type.
ARCH=`uname -m`

# Install software depending on $ARCH

# Install 32-bit software.
if  [ $ARCH = "i686" ];  then

# Install Google Chrome.
wget http://dl.google.com/linux/direct/google-chrome-unstable_current_i386.deb
dpkg -i google-chrome-unstable_current_i386.deb
rm google-chrome-unstable_current_i386.deb

# Install Dropbox
wget https://www.dropbox.com/download?dl=packages/nautilus-dropbox_0.6.7_i386.deb
dpkg -i nautilus-dropbox_0.6.7_i386.deb
dropbox start -i
rm nautilus-dropbox_0.6.7_i386.deb

# Install Google Talk Plugin.
wget http://dl.google.com/linux/direct/google-talkplugin_current_i386.deb
dpkg -i  google-talkplugin_current_i386.deb
rm google-talkplugin_current_i386.deb

break

# Install 64-bit software.
elif [ $ARCH = "x86_64" ];  then

# Install Google Chrome.
wget http://dl.google.com/linux/direct/google-chrome-unstable_current_AMD64.deb
dpkg -i google-chrome-unstable_current_AMD64.deb
rm google-chrome-unstable_current_AMD64.deb

# Install Dropbox
wget https://www.dropbox.com/download?dl=packages/nautilus-dropbox_0.6.7_amd64.deb
dpkg -i nautilus-dropbox_0.6.7_amd64.deb
dropbox start -i
rm nautilus-dropbox_0.6.7_amd64.deb

# Install Google Talk Plugin.
wget http://dl.google.com/linux/direct/google-talkplugin_current_AMD64.deb
dpkg -i  google-talkplugin_current_AMD64.deb
rm google-talkplugin_current_AMD64.deb

break

fi

echo "*		Cleaning up unused packages"
apt-get -y purge ubuntuone-client* python-ubuntuone-storage* gwibber
apt-get -y autoremove


# Prompt to reboot.
while true
do
echo -n "Setup recommends rebooting into the GUI at this time, Continue [Y/n]? "
read REBOOT
case $REBOOT in
y|Y|YES|yes|Yes) break ;;
n|N|no|NO|No) break ;;
*) 
esac
done
case "$REBOOT" in
y|Y|YES|yes|Yes)
reboot
;;
*)
break
;;
esac

# Exit if user did not opt to reboot.
exit

