#!/bin/sh
# A bash script for installing Linux Mint LXDE PPC in Debian Lenny GNU/Linux
# You should be logged in as root or be in a root session (./debian-testing-installer.sh)
#------------------------------------------------------------
clear
echo "Welcome to MintPPC 9 GNU/Linux installer."
echo ""
echo "This shell script has been designed to run after a minimal"
echo "\"CLI\" netinstall installation of Debian Lenny. The script"
echo "will attempt to configure the required repositories and" 
echo "install the necessary packages needed to transform a"
echo "Standard System install into a usable Linux MintPPC system."
echo ""
echo -n "Run installer now? (Y|n) > "
read a
if [ "$a" = "y" ] || [ "$a" = "Y" ] || \
[ "$a" = "" ]; then
if [ -f /etc/apt/sources.list ]; then
        cp -f /etc/apt/sources.list /etc/apt/sources.list~prebuildscript


sleep 2s
    #Update Repositories
    #---------------
    clear
    echo "Upgrading new repositories before install..."
    echo ""
    apt-get update
    echo ""
    echo "All packages updated..."
    echo ""
    sleep 2s
    #Perform Upgrade
    #---------------
    clear
    echo "Upgrading existing packages before install..."
    echo ""
    apt-get upgrade -y --force-yes
    echo ""
    echo "All packages upgraded..."
    echo ""
    sleep 2s
    
    #Install huge packages
    #------------------------------------
    clear
    echo "Installing huge packages"
    echo ""
    sleep 2s
    apt-get install -y desktop-base lxde cups totem
    echo ""
    sleep 2s

#Set MOTD
    #--------
    if [ -f /etc/motd.tail ]; then
        cp -f /etc/motd.tail /etc/motd.tail~prebuildscript
    fi
    echo "" > /etc/motd.tail
    echo "" >> /etc/motd.tail
    echo "The programs included with this build of MintPPC GNU/Linux are free software;" >> /etc/motd.tail
    echo "the exact distribution terms for each program are described in the" >> /etc/motd.tail
    echo "individual files in /usr/share/doc/*/copyright." >> /etc/motd.tail
    echo "" >> /etc/motd.tail
    echo "This build of MintPPC GNU/Linux comes with ABSOLUTELY NO WARRANTY," >> /etc/motd.tail
    echo "to the extent permitted by applicable law." >> /etc/motd.tail
    echo "" >> /etc/motd.tail
    echo "More information about MintPPC GNU/Linux can be found at:" >> /etc/motd.tail
    echo "http://mac.linux.be/" >> /etc/motd.tail
    echo ""
    echo "For info you can also email jjhdiederen at zonnet dot nl" >> /etc/motd.tail
    echo ""
    echo "Enjoy Linux MintPPC !" >> /etc/motd.tail
    echo "" >> /etc/motd.tail

#Install Debian packages
    #----------------------------
    clear
    echo "Installing the rest of the Debian packages"
    echo ""
    sleep 2s
    apt-get install -y alacarte alsa-base alsa-utils anacron autoconf automake1.7 autotools-dev binfmt-support binutils bluetooth bluez-audio bluez-utils
    sleep 2s
    apt-get install -y build-essential capplets-data cdbs cdrdao checkinstall cheese cpufrequtils debhelper deskbar-applet
    sleep 2s
    apt-get install -y djvulibre-desktop docbook-xml dpkg-dev dvd+rw-tools ekiga eog epiphany-browser epiphany-browser-data
    sleep 2s
    apt-get install -y epiphany-extensions epiphany-gecko evince evolution exaile feh finger firestarter foo2zjs freepats gconf-editor
    sleep 2s
    apt-get install -y gedit gedit-common genisoimage gettext gftp gftp-common gftp-gtk gftp-text giblib1 gimp gkrellm gparted gnome-alsamixer gnome-nettool gnome-system-tools gnome-wise-icon-theme gnuchess
    sleep 2s
    apt-get install -y gstreamer0.10-plugins-bad gsynaptics gthumb gthumb-data gtk-theme-switch gtk2-engines-murrine gtk2-engines-ubuntulooks
    sleep 2s
    apt-get install -y libgtkhtml3.14-19 libgtkhtml-editor-common gucharmap guile-1.8-libs hardinfo html2text iceweasel
    sleep 2s
    apt-get install -y imagemagick initscripts inkscape intltool intltool-debian kerneloops libnotify-bin liferea linux-libc-dev linux-sound-base
    sleep 2s
    apt-get install -y make menu-xdg metacity metacity-common mouseemu murrine-themes
    sleep 2s
    apt-get install -y nautilus nautilus-data nfs-kernel-server obex-data-server openprinting-ppds
    sleep 2s
    apt-get install -y pidgin pidgin-data pkg-config po-debconf ppp ppp-dev printconf python-cddb python-crypto python-cups python-eggtrayicon
    sleep 2s
    apt-get install -y python-foomatic python-gamin python-gmenu python-gnupginterface
    sleep 2s
    apt-get install -y python-gpod python-imaging python-ipy python-mutagen python-notify python-ogg python-paramiko python-pexpect python-ogg python-pysqlite2 python-pyvorbis
    sleep 2s
    apt-get install -y python-software-properties python-vte python-webkit rarian-compat rdesktop recode samba sane seahorse sg3-utils smbfs software-properties-gtk sound-juicer streamripper
    sleep 2s
    apt-get install -y system-config-printer system-tools-backends tcl8.4 transmission tsclient twm
    sleep 2s
    apt-get install -y unattended-upgrades update-manager-core update-notifier update-notifier-common vinagre vino
    sleep 2s
    apt-get install -y vorbis-tools w3c-dtd-xhtml wodim wpasupplicant x11proto-composite-dev x11proto-core-dev x11proto-damage-dev
    sleep 2s
    apt-get install -y x11proto-fixes-dev x11proto-input-dev x11proto-kb-dev x11proto-randr-dev x11proto-render-dev x11proto-xext-dev
    sleep 2s
    apt-get install -y x11proto-xinerama-dev xbitmaps xchat xchat-common xorg xsltproc xterm xtrans-dev yelp zlib1g-dev ntp
    sleep 2s
    apt-get install -y wicd fortune-mod vino ppp python-webkit gnome-wise-icon-theme python-vte python-vte blueman gnome-disk-utility
    sleep 2s
    apt-get install -y pyneighborhood system-config-printer python-paramiko python-pexpect hardinfo xfce4-taskmanager pyneighborhood xfburn asunder cheese  gnome-mplayer
    sleep 2s
    apt-get install -y vlc abiword gnumeric osmo epdfview pidgin transmission simple-scan galculator gnome-power-manager filezilla iceweasel mouseemu  catfish
    apt-get remove -y rhythmbox

#Clean up downloaded packages
    #----------------------------
    clear
    echo "Clean up. A number of packages were downloaded during"
    echo "the set-up routine. These packages are no longer needed,"
    echo "please choose whether or not you would like to remove them."
    echo ""
    echo -n "Remove downloaded packages? (Y|n) > "
    read a
    if [ "$a" = "y" ] || [ "$a" = "Y" ] || \
    [ "$a" = "" ]; then
        echo ""
        echo "Performing \"apt-get clean\"..."
        sleep 1s
        apt-get clean
	echo "Performing \"apt-get autoremove\"..."
        sleep 1s
        apt-get autoremove
 else
        echo ""
        echo "Skipping package cleanup..."
        sleep 1s
    fi

#Download and install the Mint programs
    #---------------------------
    clear
    echo "Would you like install the MintPPC specific programs?"
    echo "If not just enter to skip \"n\""
    echo ""
    echo -n "install the MintPPC files? (Y|n) > "
    read a
    if [ "$a" = "y" ] || [ "$a" = "Y" ] || \
    [ "$a" = "" ]; then
        echo ""
        echo "installing MintPPC specific programs"
        echo ""
        sleep 2s
        wget http://mac.linux.be/files/Isadora/isadora_packages.tar.gz
	tar -zxvf isadora_packages.tar.gz
	cd isadora
	dpkg -i chestnut-dialer_0.3.3-3mint3_all.deb mint-common_1.0.5_all.deb mintsystem_7.6.9_all.deb chestnut-dialer-gtk2_0.3.3-3mint3_all.deb  mintdesktop_3.2.1_all.deb mint-translations_2010.09.01_all.deb cowsay_3.03+dfsg1-2_all.deb mint-info-lxde_9.0.1_all.deb mintupdate_4.0.8_all.deb fortune-mod_1.99.1-4_powerpc.deb mintinput_1.1_all.deb mintupload_3.7.8_all.deb fortunes-husse_1.0.1_all.deb mint-wallpapers-extra_1.0.1_all.deb gtk2-engines-aurora_1.5.1-1_powerpc.deb mintwelcome_1.3.3_all.deb mint-artwork-common_1.1.3_all.deb mintnanny_1.3.8_all.deb vino-xfce_1.2-0mint1_all.deb mint-artwork-lxde_9.0.5_all.deb mint-search-addon_2.0_all.deb mintbackup_2.0.6_all.deb mint-stylish-addon_1.0.1_all.deb


	sleep 5s
	#Cleaning up
	cd ..
	rm -Rf isadora
	rm isadora_packages.tar.gz
	
     
    fi

# Install the fortunes in bash#
wget http://mac.linux.be/files/Isadora/fortunes-installer.tar.gz
tar -C /etc -zxvf fortunes-installer.tar.gz
rm -rf /etc/skel/.bashrc
rm -rf /root/.bashrc
rm fortunes-installer.tar.gz
clear
echo "Fortunes should be in place now"
sleep 4s

   fi 


# Install the menu items in /usr/share/applications
# First remove all the old crap out
clear
echo "We will now perform the mintification of Debian, starting with menu items"
rm -Rf /usr/share/applications
wget http://mac.linux.be/files/Isadora/applications.tar.gz
tar -C /usr/share/ -xzvf applications.tar.gz
rm applications.tar.gz
echo "Menu items are in place"
sleep 2s
    
# Remove personal stuff in home
rm .bashrc
rm -Rf .config/


# Install lxde-default-settings    
clear
echo "We will now install the LXDE default settings and the GDM themes"
wget http://mac.linux.be/files/Isadora/mint-lxde-default-settings.tar.gz
tar -C / -xzvf mint-lxde-default-settings.tar.gz
rm mint-lxde-default-settings.tar.gz
sleep 2s

    
# Install the GDM-themes
wget http://mac.linux.be/files/Isadora/gdm-themes.tar.gz
tar -C /usr/share/gdm -xzvf gdm-themes.tar.gz
rm gdm-themes.tar.gz
wget http://mac.linux.be/files/Isadora/gdm.conf.tar.gz
tar -C /etc/gdm -xzvf gdm.conf.tar.gz
rm gdm.conf.tar.gz
echo "GDM themes were put in place"
sleep 2s


# Add pmu_battery to /etc/modules
wget http://mac.linux.be/files/Isadora/modules.tar.gz
tar -C /etc -xzvf modules.tar.gz
rm modules.tar.gz
sleep 2s



   
    #Prompt for reboot
    #-----------------
    clear
    echo "Installation complete! Thank you for using this install script for your MintPPC GNU/Linux build."
    echo "You will now need to reboot your system."
    echo "You might need to adapt your /etc/X11/xorg.conf file."
    echo "Please consult http://mac.linux.be/ -> Apple PowerPC wiki -> Xorg.conf files and the MintPPC forum for that"
    echo ""
    echo -n "Reboot now? (Y|n) > "
    read a
    if [ "$a" = "y" ] || [ "$a" = "Y" ] || \
    [ "$a" = "" ]; then
        echo "Goodbye, hoping all went well :)"
        echo "Rebooting..."
        sleep 4s
        reboot
        exit
    else
        echo "Issue the following command as root to reboot:"
        echo ""
        echo "reboot"
        echo ""
        echo "Goodbye! :)"
    fi
fi
exit
