#! /bin/bash

#lastupdated 29/10/07 10am changed dvd playback added gstreamer-plugins-all
#lastupdated 29/10/07 8pm updated madwifi 9.3.2 to 9.3.3 added modprobe livna repo temp
#lastupdated 30/10/07 4.45pm changed personal and corrected menu display nvidia
#lastupdated 01/11/07 added root check swapped menus allow for more
#lastupdated 03/11/07 reverted madwifi back to 9.3.2 other become unstable with new kernel .43
#lastupdated 06/11/07 updated mplayer codecs to latest ver 20071007
#lastupdated 08/11/07 added more webcam drivers # xine changed plparser no change needed 
#lastupdated 16/11/07 added enable flash plugins for 64bit firefox
#lastupdated 18/11/07 added autostart networkmanager when installing wireless drivers
#lastupdated 18/11/07 added compiz-fusion gnome testing only 
#lastupdated 19/11/07 added set up sudo with or without password
#lastupdated 24/11/07 changed personal
#lastupdated 05/12/07 remove and changed personal, removed java , added fglrx,
#lastupdated 13/12/07 dependencies changed had to add ffmpeg manually removed compizf everthing is in repos now need to run compizf
#lastupdated 18/12/07 put back sun java 6u3 changed personal added google desktop/picasa config touchpad/gysynaptics
#lastupdated 20/12/07 changed personal added weblider + gnome-color-chooser hotbabe
#lastupdated 23/12/07 updated frostwire to latest version
#lastupdated 24/12/07 added --nogpgcheck to gnome-color-chooser woops sorry all
#lastupdated 24/12/07 added --nogpgcheck to gnome-color-chooser woops sorry all
#lastupdated 26/12/07 added lightscribe changed personal
#lastupdated
#lastupdated
#lastupdated
#lastupdated
#lastupdated
#lastupdated
#lastupdated
#lastupdated
#lastupdated
#lastupdated
#lastupdated
#lastupdated
#lastupdated
#lastupdated
#lastupdated
if [ $(whoami) = "root" ]
then
    thunderbirds are go
else 
  clear
  echo "                                                     "
  echo "$(logname) You must login this terminal as root su -."
  echo "                                                     "
  exit 1
fi

typeset -r YUM="`which yum`"
typeset -r RPM="`which rpm`"
typeset -r PERL="`which perl`"

DUMP_PATH="/temp"

WELCOME="1"

TOPL="-geometry 96x25+0+0"
TOPR="-geometry 96x25-0+0"

CHOICES="1 2 3 4 5 6 7 8 9"
	
function menu {
  clear
  echo -en "\033[0;40;32m"
  clear
  echo Hello $(logname) 
  echo "#################################DANGERMOUSE#################################"
  echo "###                     What would you like to do ?                       ###"
  echo "###    1) Adobe Flash Plugin and Adobe repository                         ###"
  echo "###    2) Drivers  all sorts (wireless,display,webcams,touchpad,etc plus  ###"
  echo "###    lightscribe.                                                       ###"
  echo "###    3) Sudo set up with or without password                            ###"
  echo "###    4) Sun java    6u3                                                 ###"
  echo "###    5) Google desktop or Picaso                                        ###"
  echo "###    6) Limewire or Frostwire or RealPlayerGold10                       ###"
  echo "###    7) Personal                                                        ###"
  echo "###    8) Dvd playback + extra codecs / plugins                           ###"
  echo "###    9) Exits This Script                                               ###"
  echo "##################################DANGERMOUSE################################"
}

function dvd {
$RPM -Uvh http://rpm.livna.org/livna-release-8.rpm
$RPM -e --nodeps totem-plparser.x86_64  totem-plparser.i386 totem totem-mozplugin
$YUM -y install yum-protectbase
$PERL -i -pe "s/(\[.*\])/\1\nprotect=yes/" /etc/yum.repos.d/{fedora*,livna*}
$YUM -y install totem-xine totem-xine-plparser totem-xine-mozplugin mozplugger mplayerplug-in xmms xmms-mp3 xmms-faad2 gstreamer-plugins-ugly gstreamer-plugins-bad libmad libid3tag libdvdcss libdvdnav xine-lib-extras-nonfree xine-lib-extras libquicktime vlc ffmpeg
wget www1.mplayerhq.hu/MPlayer/releases/codecs/all-20071007.tar.bz2
tar -jxvf all-20071007.tar.bz2
mkdir -p /usr/local/lib/codecs
cp all-20071007/* /usr/local/lib/codecs
ln -sf /usr/local/lib/codecs /usr/lib/codecs && ln -sf /usr/local/lib/codecs /usr/local/lib/win32 && ln -sf /usr/local/lib/codecs /usr/lib/win32
cd $DUMP_PATH
}

function setsudo {
while true; do
  clear
  echo "###################################################################"
  echo "###   Set up current user(logname) with sudo (as sudoer)        ###"
  echo "###                                                             ###"
  echo "###   1) With password                                          ###"
  echo "###   2) No password                                            ###"
  echo "###   3) Back to main menu                                      ###"
  echo "###################################################################"
  read yn
  case $yn in
    1 ) sudopswd ; break ;;
    2 ) sudonpswd ; break ;;
    3 ) menu ; break ;;
    * ) echo "unknown response. Try again" ;;
  esac
done 
}



function sudonpswd {
echo "$(logname) ALL=(ALL) ALL" >> /etc/sudoer
chmod +w /etc/sudoers
echo "$(logname) ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers
chmod -w /etc/sudoers
sleep 5
cd $DUMP_PATH
}

function google {
while true; do
  clear
  echo "###################################################################"
  echo "###   Set up current user(logname) with sudo (as sudoer)        ###"
  echo "###                                                             ###"
  echo "###   1) Google Desktop                                         ###"
  echo "###   2) Google Picaso                                          ###"
  echo "###   3) Back to main menu                                      ###"
  echo "###################################################################"
  read yn
  case $yn in
    1 ) googled ; break ;;
    2 ) googlep ; break ;;
    3 ) menu ; break ;;
    * ) echo "unknown response. Try again" ;;
  esac
done 
}

function googled {
cat <<EOF > /etc/yum.repos.d/google.repo
[google]
name=Google - i386
baseurl=http://dl.google.com/linux/rpm/stable/i386
enabled=1
gpgkey=https://dl-ssl.google.com/linux/linux_signing_key.pub
EOF
wget https://dl-ssl.google.com/linux/linux_signing_key.pub
$RPM --import linux_signing_key.pub  
$YUM -y install google-desktop-linux.i586
cd $DUMP_PATH
}

function googlep {
cat <<EOF > /etc/yum.repos.d/google.repo
[google]
name=Google - i386
baseurl=http://dl.google.com/linux/rpm/stable/i386
enabled=1
gpgkey=https://dl-ssl.google.com/linux/linux_signing_key.pub
EOF
wget https://dl-ssl.google.com/linux/linux_signing_key.pub
$RPM --import linux_signing_key.pub  
$YUM -y install picasa.i386
cd $DUMP_PATH
}

function sudopswd {
echo "$(logname) ALL=(ALL) ALL" >> /etc/sudoer
chmod +w /etc/sudoers
echo "$(logname) ALL=(ALL) PASSWD:ALL" >> /etc/sudoers
chmod -w /etc/sudoers
sleep 5
cd $DUMP_PATH
}


function abode {
$RPM -Uvh http://linuxdownload.adobe.com/adobe-release/adobe-release-i386-1.0-1.noarch.rpm
$YUM -y install flash-plugin.i386
mkdir -p /usr/lib/mozilla/plugins
$YUM -y install nspluginwrapper.{i386,x86_64} pulseaudio-libs.i386
mozilla-plugin-config -i -g -v
cd $DUMP_PATH
}

function java {
clear
$YUM -y install compat-libstdc++-33 compat-libstdc++-296
wget http://javadl.sun.com/webapps/download/AutoDL?BundleId=12790
sh jre-6u3*.bin
ln -sf "$(rpm -ql jre|grep plugin|grep ns7/|grep \\.so$)" /usr/lib/mozilla/plugins/libjavaplugin_oji.so & /usr/sbin/alternatives --install /usr/bin/java java $(rpm -ql jre | grep bin/java$) 2
xterm $TOPL  -bg "#000000" -fg "#99CCFF" -title "CHOOSE YOUR DEFAULT VERSION" -e /usr/sbin/alternatives --config java
cd $DUMP_PATH
}


function madwifi {
rm -rf /lib/modules/$(uname -r)/kernel/drivers/net/wireless/ath5k; depmod
xterm $TOPL  -bg "#000000" -fg "#99CCFF" -title "DOWNLOADING AND INSTALLING MADWIFI" -e "$YUM -y install gcc kernel-devel-$(uname -r) && wget http://www.freewebs.com/dnmouse/madwifi-0.9.3.2.tar.gz && tar -xvf /temp/madwifi-0.9.3.2.tar.gz && cd /temp/madwifi-0.9.3.2 && make && make install && modprobe ath_pci"
/sbin/chkconfig NetworkManager on
/sbin/chkconfig network off
cd $DUMP_PATH
}

function wireless {
while true; do
  clear
  echo "###################################################################"
  echo "###           Select which wireless driver to install           ###"
  echo "###                                                             ###"
  echo "###   1) Broadcom 43xx      SEE NOTE AT BOTTOM                  ###"
  echo "###   2) Madwifi/Atheros    SEE NOTE AT BOTTOM                  ###"
  echo "###   3) Back to main menu                                      ###"
  echo "###                                                             ###"
  echo "###                  NOTE                                       ###"
  echo "###  Networkmanger will be enabled by default on boot           ###"
  echo "###  Please restart after driver installation                   ###"
  echo "###  Atheros/Madwifi should already work, the above driver will ###"
  echo "###  install a stable version from madwifi and ban the pre in-  ###"
  echo "### -installed driver                                           ###"
  echo "###################################################################"
  read yn
  case $yn in
    1 ) broadcom ; break ;;
    2 ) madwifi ; break ;;
    3 ) menu ; break ;;
    * ) echo "unknown response. Try again" ;;
  esac
done 
}

function nvidiafx {
$RPM -Uvh http://rpm.livna.org/livna-release-8.rpm
$YUM -y install yum-protectbase
$PERL -i -pe "s/(\[.*\])/\1\nprotect=yes/" /etc/yum.repos.d/{fedora*,livna*}
$YUM -y install kmod-nvidia xorg-x11-drv-nvidia-libs-32bit
cd $DUMP_PATH
}

function nvidiamx {
$RPM -Uvh http://rpm.livna.org/livna-release-8.rpm
$YUM -y install yum-protectbase
$PERL -i -pe "s/(\[.*\])/\1\nprotect=yes/" /etc/yum.repos.d/{fedora*,livna*}
$YUM -y install kmod-nvidia-96xx xorg-x11-drv-nvidia-96xx-libs-32bit
cd $DUMP_PATH
}

function personal {
while true; do
  clear
  echo -e '\E[31;40m'
  echo "####################################################################"
  echo "###     This is for personal use, use at your own risk !!!!!     ###"
  echo "###                                                              ###"
  echo "###   1) Repo's Livna,abode,freshrpms,protectbase                ###"
  echo "###   2) Install most programs i use                             ###"
  echo "###   3) gnome-color-chooser                                     ###"
  echo "###   4) Weblider wallpaper changer                              ###"
  echo "###   5) Hotbabe cpu display  (type [hot-babe] in a terminal     ###"
  echo "###   6) Exit to main menu                                       ###"
  echo "###                                                              ###"
  echo "####################################################################"
  read yn
  case $yn in
    1 ) repos ; break ;;
    2 ) most  ; break ;;
    3 ) color ; break ;;
    4 ) weblider ; break ;;
    5 ) hotbabe ; break ;;
    6 ) menu ; break ;;
    * ) echo "unknown response. Try again" ;;
  esac
done 
}

function hotbabe {
wget http://dnmouse.webs.com/rpms/hot-babe-0.2.2-2.i386.rpm
$RPM -Uvh hot-babe-0.2.2-2.i386.rpm
cd $DUMP_PATH
}


function weblider {
$YUM -y install python-imaging
wget http://dnmouse.webs.com/files/Webilder-0.6.2.tar.gz
tar -xvf Webilder-0.6.2.tar.gz
cd Webilder-0.6.2
python setup.py install
cd $DUMP_PATH
}

function color {
wget http://dnmouse.webs.com/rpms/gnome-color-chooser-0.2.2-1.fc8.i386.rpm
$YUM -y localinstall /temp/gnome-color-chooser-0.2.2-1.fc8.i386.rpm --nogpgcheck
cd $DUMP_PATH
}

function repos {
$RPM -Uvh http://rpm.livna.org/livna-release-8.rpm
$RPM -Uvh http://linuxdownload.adobe.com/adobe-release/adobe-release-i386-1.0-1.noarch.rpm
$RPM -Uvh http://ftp.freshrpms.net/pub/freshrpms/fedora/linux/8/freshrpms-release/freshrpms-release-1.1-1.fc.noarch.rpm
$YUM -y install yum-protectbase
$PERL -i -pe "s/(\[.*\])/\1\nprotect=yes/" /etc/yum.repos.d/{fedora*,livna*}
cd $DUMP_PATH
}

function most {
$RPM -Uvh http://rpm.livna.org/livna-release-8.rpm
$RPM -Uvh http://linuxdownload.adobe.com/adobe-release/adobe-release-i386-1.0-1.noarch.rpm
$RPM -Uvh http://ftp.freshrpms.net/pub/freshrpms/fedora/linux/8/freshrpms-release/freshrpms-release-1.1-1.fc.noarch.rpm
$YUM -y install yum-protectbase
$PERL -i -pe "s/(\[.*\])/\1\nprotect=yes/" /etc/yum.repos.d/{fedora*,livna*}
$RPM -e --nodeps totem-plparser.x86_64  totem-plparser.i386 totem totem-mozplugin
$YUM -y install totem-xine totem-xine-plparser totem-xine-mozplugin mozplugger mplayerplug-in xmms xmms-mp3 xmms-faad2 gstreamer-plugins-ugly gstreamer-plugins-bad libmad libid3tag libdvdcss xine-lib-extras-nonfree libquicktime vlc xine-lib-extras libdvdnav
wget www1.mplayerhq.hu/MPlayer/releases/codecs/all-20071007.tar.bz2
tar -jxvf all-20071007.tar.bz2
mkdir -p /usr/local/lib/codecs
cp all-20071007/* /usr/local/lib/codecs
ln -sf /usr/local/lib/codecs /usr/lib/codecs && ln -sf /usr/local/lib/codecs /usr/local/lib/win32 && ln -sf /usr/local/lib/codecs /usr/lib/win32
mkdir -p /usr/lib/mozilla/plugins
$YUM -y install compat-libstdc++-33 compat-libstdc++-296
$YUM -y install streamtuner streamripper k3b-extras-nonfree  dvdstyler mencoder devede gdesklets istanbul gnome-applet-netspeed dvdauthor ktorrent amule glunarclock nautilus-search-tool nautilus-open-terminal nautilus-image-converter unixODBC-devel gstreamer-plugins-good gstreamer-plugins-ugly gstreamer-plugins-bad unrar lame soundconverter vnc macchanger gdesklets vlc gdeskcal git system-config-boot gwget dvdrip alltray pam_keyring tor privoxy gtweakui gnome-screensaver-frogs rss-glx-xsceensaver rss-glx gnome-speech gparted gsynaptics gconf-editor
/sbin/chkconfig tor on
/sbin/chkconfig privoxy on
/sbin/chkconfig NetworkManager on
sed -i.bak '/Option	    "Emulate3Buttons" "yes"/a\
Option "SHMConfig" "on"' /etc/X11/xorg.conf
/sbin/chkconfig network off
/sbin/chkconfig isdn off
/sbin/chkconfig yum-updatesd off
$YUM -y install gcc kernel-devel-$(uname -r) camstream
wget http://www.freewebs.com/dnmouse/gspcav1-20070110.tar.gz
wget http://www.freewebs.com/dnmouse/trunk.tar.gz
wget http://www.freewebs.com/dnmouse/sn9c1xx-1.48.tar.gz
tar -xvf sn9c1xx-1.48.tar.gz
tar -xvf trunk.tar.gz
tar -xvf gspcav1-20070110.tar.gz
cd gspcav1-20070110
make && make install
cd $DUMP_PATH
cd trunk
make && make install
cd $DUMP_PATH
cd sn9c1xx-1.48
make && make install
cd $DUMP_PATH
wget http://www.real.com/realcom/R?href=http%3A%2F%2Fforms%2Ereal%2Ecom%2Freal%2Fplayer%2Fdownload%2Ehtml%3Ff%3Dunix%2FRealPlayer10GOLD%2Erpm
$RPM -Uvh RealPlayer10GOLD.rpm
$YUM -y install flash-plugin.i386
mkdir -p /usr/lib/mozilla/plugins
$YUM -y install nspluginwrapper.{i386,x86_64} pulseaudio-libs.i386
mozilla-plugin-config -i -g -v
cd $DUMP_PATH
}


function cam {
clear
$YUM -y install gcc kernel-devel-$(uname -r) camstream
wget http://www.freewebs.com/dnmouse/gspcav1-20070110.tar.gz
wget http://www.freewebs.com/dnmouse/trunk.tar.gz
wget http://www.freewebs.com/dnmouse/sn9c1xx-1.48.tar.gz
tar -xvf sn9c1xx-1.48.tar.gz
tar -xvf trunk.tar.gz
tar -xvf gspcav1-20070110.tar.gz
cd gspcav1-20070110
make && make install
cd $DUMP_PATH
cd trunk
make && make install
cd $DUMP_PATH
cd sn9c1xx-1.48
make && make install
cd $DUMP_PATH
}

function mixed {
while true; do
  clear
  echo "###################################################################"
  echo "###                Select which one to install                  ###"
  echo "###   1) Limewire                                               ###"
  echo "###   2) Frostwire                                              ###"
  echo "###   3) RealPlayerGold10                                       ###"         
  echo "###   4) back to main menu                                      ###"
  echo "###################################################################"
  read yn
  case $yn in
    1 ) limewire ; break ;;
    2 ) frostwire ; break ;;
    3 ) realplayer ; break ;;
    4 ) menu ; break ;;
    * ) echo "unknown response. Try again" ;;
  esac
done 
}

function realplayer {
clear
$YUM -y install compat-libstdc++-33 compat-libstdc++-296 nspluginwrapper
wget http://www.real.com/realcom/R?href=http%3A%2F%2Fforms%2Ereal%2Ecom%2Freal%2Fplayer%2Fdownload%2Ehtml%3Ff%3Dunix%2FRealPlayer10GOLD%2Erpm
$RPM -Uvh RealPlayer10GOLD.rpm
mkdir -p /usr/lib/mozilla/plugins
$YUM -y install nspluginwrapper.{i386,x86_64} pulseaudio-libs.i386
ln -sf /usr/lib64/mozilla/plugins/* /usr/lib64/firefox-*/plugins/
mozilla-plugin-config -i -g -v
cd $DUMP_PATH
}

function limewire {
clear
$YUM -y install libXp compat-libstdc++-33 compat-libstdc++-296
wget http://www.limewire.com/LimeWireSoftLinux
$RPM -Uvh --nodeps LimeWireLinux.rpm
cd $DUMP_PATH
}

function frostwire {
clear
$YUM -y install libXp compat-libstdc++-33 compat-libstdc++-296
wget http://www.frostwire.com/download/?os=redhat
$RPM -Uvh --nodeps frostwire*.rpm
cd $DUMP_PATH
}


function touchpad {
$YUM -y install gsynaptics
sed -i.bak '/Option	    "Emulate3Buttons" "yes"/a\
Option "SHMConfig" "on"' /etc/X11/xorg.conf
cd $DUMP_PATH
}


function fglrx {
$RPM -Uhv http://rpm.livna.org/livna-release-8.rpm
$YUM install kmod-fglrx xorg-x11-drv-fglrx xorg-x11-drv-fglrx-libs-32bit
cd $DUMP_PATH
}

function nvidia {
while true; do
  clear
  echo "###################################################################"
  echo "###           Select which driver to install                    ###"
  echo "###                                                             ###"
  echo "###   1) Nvidia FX          (recomend restart afterwards)       ###"
  echo "###   2) Nvidia MX          (recomend restart afterwards)       ###"
  echo "###   3) Ati using kmod-fglrx  (recomend restart afterwards)    ###"
  echo "###    check first if you card is supported at Ati website      ###"
  echo "###   4) Back to main menu                                      ###"
  echo "###################################################################"
  read yn
  case $yn in
    1 ) nvidiafx ; break ;;
    2 ) nvidiamx ; break ;;
    3 ) fglrx ; break ;;
    4 ) menu ; break ;;
    * ) echo "unknown response. Try again" ;;
  esac
done 
}

function drivers {
while true; do
  clear
  echo "###################################################################"
  echo "###           Select which driver to install                    ###"
  echo "###                                                             ###"
  echo "###   1) Nvidia or Ati graphics drivers                         ###"
  echo "###   2) Wireless drivers                                       ###"
  echo "###   3) Webcam drivers                                         ###"
  echo "###   4) Touchpad configure gsynaptics (restart required)       ###"
  echo "###   5) Lightscribe  (to run type    4L-gui     in a terminal  ###"
  echo "###   6) Back to main menu                                      ###"
  echo "###################################################################"
  read yn
  case $yn in
    1 ) nvidia ; break ;;
    2 ) wireless ; break ;;
    3 ) cam ; break ;;
    4 ) touchpad ; break ;;
    5 ) lightscribe ; break ;;
    6 ) menu ; break ;;
    * ) echo "unknown response. Try again" ;;
  esac
done 
}

function lightscribe {
wget http://dnmouse.webs.com/rpms/lightscribe.tar.gz
tar -xvf lightscribe.tar.gz
$YUM -y localinstall /temp/lightscribe*.rpm 4L*.rpm --nogpgcheck
cd $DUMP_PATH
}

function broadcom {
xterm $TOPL  -bg "#000000" -fg "#99CCFF" -title "INSTALLING BROADCOM 43xx DRIVER" -e "$YUM -y install b43-fwcutter --nogpgcheck && wget http://www.freewebs.com/dnmouse/broadcom-wl-4.80.53.0.tar.bz2 && tar xvf /temp/broadcom-wl-4.80.53.0.tar.bz2 && cd /temp/broadcom* && cd /temp/broadcom*/kmod && /usr/bin/b43-fwcutter -w /lib/firmware wl_apsta.o"
/sbin/chkconfig NetworkManager on
/sbin/chkconfig network off
cd $DUMP_PATH
}

function message {
if [ $WELCOME = 1 ]
	then
echo  Hello $(logname) 
echo "W E L C O M E   T O   M Y  S C R I P T"
echo    "T H I S  I S  F O R  F 8  O N L Y"
echo             "By Dangermouse"
echo        "www.dnmouse.webs.com"
sleep 5
	else
		echo "no welcome msg for you" 
fi
}
	
        clear
        message
	mkdir $DUMP_PATH
	cd $DUMP_PATH
	menu	
select choix in $CHOICES; do					
	if [ "$choix" = "1" ]; then
	abode
	menu			
	elif [ "$choix" = "2" ]; then
	drivers
	menu					
	elif [ "$choix" = "3" ]; then
	setsudo
        menu
        elif [ "$choix" = "4" ]; then
	java
        menu
        elif [ "$choix" = "5" ]; then
	google
        menu
        elif [ "$choix" = "6" ]; then
	mixed
        menu
        elif [ "$choix" = "7" ]; then
 	personal
        menu
        elif [ "$choix" = "8" ]; then
	dvd
	menu	
	elif [ "$choix" = "9" ]; then
        echo -e "\033[0m"
        clear
	echo Script terminated good bye $(logname) 
        exit 		
	else
	clear
	menu
        echo "################################################################"
        echo "###               Try again wrong number                     ###"
	fi
done
#END
