#!/bin/bash
#
# +-------------------------------------------------------------------------+
# | Copyright (C) 2007 Ezequiel M. Cardinali                                |
# |                                                                         |
# | Este programa es Software Libre; Puedes distribuirlo y/o                |
# | modificarlo bajo los términos de la GNU General Public License          |
# | como está publicada por la Free Software Foundation; cualquier          |
# | versión 2 de la Licencia, o (opcionalmente) cualquier versión           |
# | posterior. http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt         |
# |                                                                         |
# | Este programa es distribuido con la esperanza de que sea útil,          |
# | pero SIN NINGUNA GARANTÍA. Vea la GNU General Public License            |
# | para más detalles.                                                      |
# +-------------------------------------------------------------------------+
# | Este código ha sido diseñado, escrito y mantenido por Ezequiel M.       |
# | Cardinali. Cualquier pregunta, comentario o consejo sobre este código   |
# | debe dirigirse a:                                                       |
# | - ezq@lugmaju.com.ar                                                    |
# +-------------------------------------------------------------------------+
#
# ---------------------------------------------------------------------------
# AVISO: ESTE SCRIPT DEBE EJECUTARSE CON PRIVILEGIOS DE ROOT
# ---------------------------------------------------------------------------
# Declaración de las funciones que instalan los programas

function repos () {
   rpm --import /etc/pki/rpm-gpg/*
   rpm -hiv http://rpm.livna.org/livna-release-8.rpm
   rpm --import http://rpm.livna.org/RPM-LIVNA-GPG-KEY
}

function yumex () {
   yum -y install yumex
}

function nvidia () {
   yum -y install kmod-nvidia
}

function ati () {
   yum -y install kmod-fglrx
   service fglrx restart
}

function fonts () {
   yum -y install freetype-freeworld
   rpm -Uvh http://avi.alkalay.net/software/webcore-fonts/webcore-fonts-3.0-1.noarch.rpm
   http://avi.alkalay.net/software/webcore-fonts/webcore-fonts-vista-3.0-1.noarch.rpm
   rpm -Uvh http://www.my-guides.net/downloads/msttcorefonts-2.0-1.noarch.rpm
}

function flash-plugin () {
   rpm -Uvh http://linuxdownload.adobe.com/adobe-release/adobe-release-i386-1.0-1.noarch.rpm
   yum -y install flash-plugin
}

function gnash-plugin () {
   yum -y install gnash gnash-plugin
   ln -s /usr/lib/mozilla/plugins/libgnashplugin.so /usr/lib/firefox-2.0.0.*/pluginslibgnashplugin.so
}

function mplayer-plugin () {
   yum -y install mplayerplug-in
}

function java-plugin () {
   yum -y install java-*-icedtea-plugin
}

function rhythmbox-mp3 () {
   yum -y install gstreamer rhythmbox
   yum -y install gstreamer-plugins-good gstreamer-plugins-bad gstreamer-plugins-ugly
}

function amarok () {
   yum -y install amarok amarok-extras-nonfree
}

function audacious () {
   yum -y install audacious audacious-plugins-nonfree-*
}

function xmms () {
   yum -y install xmms xmms-libs xmms-mp3
}

function dvd-video () {
   yum -y install libdvdcss libdvdread libdvdplay libdvdnav lsdvd libdvbpsi
   cd /tmp
   wget http://www1.mplayerhq.hu/MPlayer/releases/codecs/all-20071007.tar.bz2
   tar -jxf 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
   rm -rf all-20071007
   cd -
}

function mplayer-gui () {
   yum -y install mplayer-gui
}

function totem () {
   yum -y remove totem
   yum -y install totem-xine totem-xine-plparser xine-lib-extras xine-lib-extras-nonfree
   yum -y install gstreamer-ffmpeg ffmpeg ffmpeg-libs
}

function xine () {
   yum -y install xine xine-lib-extras xine-lib-extras-nonfree
   yum -y install gstreamer-ffmpeg ffmpeg ffmpeg-libs
}

function vlc () {
   yum -y install vlc
}

function kaffeine () {
   yum -y install kaffeine xine-lib-extras xine-lib-extras-nonfree
}

function xchat () {
   yum -y install xchat
}

function pidgin () {
   yum -y install pidgin
}

function amsn () {
   yum -y install amsn
}

function k3b () {
   yum -y install k3b
}

function k9copy () {
   yum -y install k9copy libdvdcss libdvdread libdvdplay libdvdnav lsdvd libdvbpsi 
}

function devede () {
   yum -y install devede
}

function acroread () {
   rpm -Uvh http://ardownload.adobe.com/pub/adobe/reader/unix/8.x/8.1.1/esp/AdobeReader_esp-8.1.1-1.i486.rpm
}

function unrar () {
   yum -y install unrar
}

function chm-reader () {
   yum -y install gnochm
}

function ntfs () {
   yum -y install ntfs-3g fuse fuse-libs
}

function compiz-fusion () {
   yum -y install compiz compiz-gnome compiz-bcop compiz-fusion compiz-fusion \
   compiz-fusion-extras compiz-fusion-extras-gnome compiz compizconfig-python \
   libcompizconfig libcompizconfig-devel gnome-compiz-manager
}

function kde () {
   yum -y groupinstall "KDE (K Desktop Environment)"
   yum -y install gtk-qt-engine
}

function pulseaudio () {
   yum -y install pulseaudio gstreamer-plugins-pulse pulseaudio-core-libs \
   pulseaudio-esound-compat pulseaudio-libs pulseaudio-libs-glib2 \
   pulseaudio-libs-zeroconf pulseaudio-module-gconf pulseaudio-module-x11 \
   pulseaudio-module-zeroconf pulseaudio-utils
   echo "load-module module-zeroconf-publish" >> /etc/pulse/default.pa
}
# Final de las funciones
# --------------------------------------------------------------------------

# --------------------------------------------------------------------------
# Ahora empieza lo bueno :,)
# --------------------------------------------------------------------------
# Armo el menú principal
LISTA=$(zenity --list \
   --title="Wolf - Fedora 8 - i386" \
   --text="Selecciona que quieres instalar" \
   --checklist \
   --width="700" \
   --height="550" \
   --separator=" " \
   --column="" --column="#" --column="Programa" --column="Descripción" \
   FALSE 1 "Yumex" "Instalar frontend gráfico para yum" \
   FALSE 2 "Nvidia" "Instalar drivers propietarios para nvidia" \
   FALSE 3 "ATI" "Inatalar drivers propietarios para ATI" \
   FALSE 4 "Fonts" "Instalar fuentes tty" \
   FALSE 5 "Flash Plugin" "Instalar plugin de flash para Firefox" \
   FALSE 6 "GNASH Plugin" "Instalar plugin de flash libre para Firefox" \
   FALSE 7 "Mplayer Plugin" "Instalar plugin de Mplayer para Firefox" \
   FALSE 8 "Java Plugin" "Inatalar plugin de OpenSDK para Firefox" \
   FALSE 9 "Rhythmbox MP3" "Instalar soporte para mp3 para Rhythmbox" \
   FALSE 10 "Amarok" "Instalar Amarok con soporte para mp3, wma, etc." \
   FALSE 11 "Audacious" "Instalar Audacious con soporte para mp3, wma, etc." \
   FALSE 12 "XMMS" "Instalar XMMS con soporte para mp3" \
   FALSE 13 "DVD & Video" "Instalar soporte para DVDs y otros formatos de video" \
   FALSE 14 "Mplayer" "Instalar Mplayer para Gnome" \
   FALSE 15 "Totem-xine" "Instalar Totem-xina con soporte para formatos de video populares" \
   FALSE 16 "Xine" "Instalar Xine" \
   FALSE 17 "VLC" "Instalar VLC, uno de los mejores reproductores de video" \
   FALSE 18 "Kaffeine" "Instalar reproductor de peliculas para KDE" \
   FALSE 19 "XChat" "Instalar XChat" \
   FALSE 20 "Pidgin" "Instalar cliente de mensajería instantánea multiprotocolo" \
   FALSE 21 "AMSN" "Instalar clon de MSN" \
   FALSE 22 "K3B" "Instalar K3B, el mejor quemador de CDs" \
   FALSE 23 "K9copy" "Instalar K9copy, copiador de DVDs" \
   FALSE 24 "DeVeDe" "Instalar DeVeDe, creador de DVDs" \
   FALSE 25 "Acrobat Reader" "Instalar Adobe Acrobat Reader" \
   FALSE 26 "Unrar" "Instalar soporte para archivos rar" \
   FALSE 27 "GNOCHM" "Instalar lector de archivos chm" \
   FALSE 28 "NTFS" "Instalar soporte para escritura en ntfs" \
   FALSE 29 "Compiz-Fusion" "Instalar Compiz-Fusion, el escritorio 3D" \
   FALSE 30 "KDE" "Instalar KDE" \
   FALSE 31 "Pulse Audio" "Instalar servidor PulseAudio")
# Fin del menú principal
# --------------------------------------------------------------------------
# Reviso si el repositorio de livna está instalado
if [ -z /etc/yum.repos.d/livna.repo  ]
then
   repos
fi
# Fin revisión de repositorios
# --------------------------------------------------------------------------
LOGFILE=/tmp/wolf.log

echo "-------------------------------------------" > $LOGFILE
echo `date` >> $LOGFILE
echo "-------------------------------------------" >> $LOGFILE

for ITEM in $LISTA
do
   case $ITEM in
      "1" ) yumex | tee >(zenity --text="Instalando Yumex..." \
            --progress --auto-close --auto-kill) >> $LOGFILE ;;
      "2" ) nvidia | tee >(zenity --text="Instalando Nvidia Driver..." \
            --progress --auto-close --auto-kill) >> $LOGFILE ;;
      "3" ) ati | tee >(zenity --text="Instalando ATI  Driver..." \
            --progress --auto-close --auto-kill) >> $LOGFILE ;;
      "4" ) fonts | tee >(zenity --text="Instalando Fuentes..." \
            --progress --auto-close --auto-kill) >> $LOGFILE ;;
      "5" ) flash-plugin | tee >(zenity --text="Instalando Flash Plugin..." \
            --progress --auto-close --auto-kill) >> $LOGFILE ;;
      "6" ) gnash-plugin | tee >(zenity --text="Instalando Gnash Plugin..." \
            --progress --auto-close --auto-kill) >> $LOGFILE ;;
      "7" ) mplayer-plugin | tee >(zenity --text="Instalando Mplayer Plugin..." \
            --progress --auto-close --auto-kill) >> $LOGFILE ;;
      "8" ) java-plugin | tee >(zenity --text="Instalando Java Plugin..." \
            --progress --auto-close --auto-kill) >> $LOGFILE ;;
      "9" ) rhythmbox-mp3 | tee >(zenity --text="Instalando Rhythmbox Mp3..." \
            --progress --auto-close --auto-kill) >> $LOGFILE ;;
      "10" ) amarok | tee >(zenity --text="Instalando Amarok..." \
            --progress --auto-close --auto-kill) >> $LOGFILE ;;
      "11" ) audacious | tee >(zenity --text="Instalando Audacious..." \
            --progress --auto-close --auto-kill) >> $LOGFILE ;;
      "12" ) xmms | tee >(zenity --text="Instalando XMMS..." \
            --progress --auto-close --auto-kill) >> $LOGFILE ;;
      "13" ) dvd-video | tee >(zenity --text="Instalando Soporte DVD..." \
            --progress --auto-close --auto-kill) >> $LOGFILE ;;
      "14" ) mplayer-gui | tee >(zenity --text="Instalando Mplayer..." \
            --progress --auto-close --auto-kill) >> $LOGFILE ;;
      "15" ) totem | tee >(zenity --text="Instalando Totem-Xine..." \
            --progress --auto-close --auto-kill) >> $LOGFILE ;;
      "16" ) xine | tee >(zenity --text="Instalando Xine..." \
            --progress --auto-close --auto-kill) >> $LOGFILE ;;
      "17" ) vlc | tee >(zenity --text="Instalando VLC..." \
            --progress --auto-close --auto-kill) >> $LOGFILE ;;
      "18" ) kaffeine | tee >(zenity --text="Instalando Kaffeine..." \
            --progress --auto-close --auto-kill) >> $LOGFILE ;;
      "19" ) xchat | tee >(zenity --text="Instalando XChat..." \
            --progress --auto-close --auto-kill) >> $LOGFILE ;;
      "20" ) pidgin | tee >(zenity --text="Instalando Pidgin..." \
            --progress --auto-close --auto-kill) >> $LOGFILE ;;
      "21" ) amsn | tee >(zenity --text="Instalando AMSN..." \
            --progress --auto-close --auto-kill) >> $LOGFILE ;;
      "22" ) k3b | tee >(zenity --text="Instalando K3B..." \
            --progress --auto-close --auto-kill) >> $LOGFILE ;;
      "23" ) k9copy | tee >(zenity --text="Instalando K9copy..." \
            --progress --auto-close --auto-kill) >> $LOGFILE ;;
      "24" ) devede | tee >(zenity --text="Instalando DeVeDe..." \
            --progress --auto-close --auto-kill) >> $LOGFILE ;;
      "25" ) acroread | tee >(zenity --text="Instalando Acrobat Reader..." \
            --progress --auto-close --auto-kill) >> $LOGFILE ;;
      "26" ) unrar | tee >(zenity --text="Instalando Soporte RAR..." \
            --progress --auto-close --auto-kill) >> $LOGFILE ;;
      "27" ) chm-reader | tee >(zenity --text="Instalando GnoCHM..." \
            --progress --auto-close --auto-kill) >> $LOGFILE ;;
      "28" ) ntfs | tee >(zenity --text="Instalando Soporte NTFS..." \
            --progress --auto-close --auto-kill) >> $LOGFILE ;;
      "29" ) compiz-fusion | tee >(zenity --text="Instalando Compiz-Fusion..." \
            --progress --auto-close --auto-kill) >> $LOGFILE ;;
      "30" ) kde | tee >(zenity --text="Instalando KDE..." \
            --progress --auto-close --auto-kill) >> $LOGFILE ;;
      "31" ) pulseaudio | tee >(zenity --text="Instalando servidor PulseAudio..." \
            --progress --auto-close --auto-kill) >> $LOGFILE ;;
   esac
done

