#!/bin/sh

##################--------C o l o r  -------------##########################
# <colors>
	coloroff="\033[1;0m"	# standart color
	green="\033[1;32m"	# green
	white="\033[1;37m"	# white
	blue="\033[1;36m"	# blue
	red="\033[1;31m"	# red
	lilas="\033[1;35m"	# lilac
# </colors>


############################################################################

clear
echo "Homepage of this project:"
echo -e "http://gnormalize.sourceforge.net\n"
echo -e "This script will install ${blue}gnormalize${coloroff}, \
${green}CDDB_get${coloroff}, ${green}MP3::Info${coloroff}, ${green}Audio-CD${coloroff}, \
${green}mppenc${coloroff} and ${green}mppdec${coloroff} in your system:"

ID=$(id)

case $ID in *\(root\)*)
     IDROOT=1
     ;;
esac

if [ "$IDROOT" != 1 ] ; 
then echo -e "\nYou must have permission access (superuser privilege) to install this programs.
Please, become root.\n"
     exit; 
fi


####################--------------Install------------########################

echo -e "\nInstall Audio-CD to play Audio CDs( you must have installed: libcdaudio,\
libcdaudio-devel, perl-devel )? Type (y/n): \c"

read resposta

if [ "$resposta" = "y" -o "$resposta" = "" ]
then       	 
	 echo -e "\n${lilas}Install Audio-CD:${coloroff}"
	 tar zxvf Audio-CD-0.04-changed.tar.gz
	 cd Audio-CD-0.04-changed
	 perl Makefile.PL
	 make && make install
	 if [ "$?" = "0" ]
	    then echo -e "\n${green}Sucess, Audio-CD installed.${coloroff}\n"
	    else echo -e "\n${red}Could not install Audio-CD.${coloroff}\n"
	 fi
	 cd ..
	 rm -rf Audio-CD-0.04-changed
	 	 	 
else     echo -e "\nNot install Audio-CD!\n"

fi

echo -e "\nInstall CDDB_get? Type (y/n): \c"
read resposta
if [ "$resposta" = "y" -o "$resposta" = "" ]
then       	 
	 echo -e "\n${lilas}Install CDDB_get:${coloroff}"
	 tar zxvf CDDB_get-2.27.tar.gz
	 cd CDDB_get-2.27
	 perl Makefile.PL
	 make && make install
	 if [ "$?" = "0" ]
	    then echo -e "\n${green}Sucess, CDDB_get installed.${coloroff}\n"
	    else echo -e "\n${red}Could not install CDDB_get.${coloroff}\n"
	 fi
	 cd ..
	 rm -rf CDDB_get-2.27	  
	 	 	 
else     echo -e "\nNot install CDDB_get!\n"

fi

echo -e "\nInstall MP3::Info? Type (y/n): \c"
read resposta
if [ "$resposta" = "y" -o "$resposta" = "" ]
then       	 
	 echo -e "\n${lilas}Install MP3::Info:${coloroff}"
	 tar zxvf MP3-Info-1.20.tar.gz
	 cd MP3-Info-1.20
	 perl Makefile.PL
	 make && make install
	 if [ "$?" = "0" ]
	    then echo -e "\n${green}Sucess, MP3::Info installed.${coloroff}\n"
	    else echo -e "\n${red}Could not install MP3::Info.${coloroff}\n"
	 fi
	 cd ..
	 rm -rf MP3-Info-1.20
	 	 	 
else     echo -e "\nNot install CDDB_get!\n"

fi

echo -e "\nInstall ${blue}gnormalize${coloroff}, \
${green}mppenc${coloroff} and ${green}mppdec${coloroff}? Type (y/n): \c"
read resposta
if [ "$resposta" = "y" -o "$resposta" = "" ]
then       
	 echo -e "\n${lilas}Install MPC encoder and decoder:${coloroff}"
	 cp -vf mpc/mppdec /usr/bin; chmod 755 /usr/bin/mppdec
	 cp -vf mpc/mppenc /usr/bin; chmod 755 /usr/bin/mppenc
	 
	 #echo -e "\n${lilas}Remove cdcd config file \"home/.cdcdrc\" to avoid some error:${coloroff}"
	 
	 echo -e "\n${lilas}Install gnormalize:${coloroff}"
	 
	 make install
	 
	 if [ "$?" = "0" ]
	    then echo -e "\n${green}Sucess, install finished.${coloroff}\n"
	    else echo -e "\n${red}Could not install gnormalize.${coloroff}\n"
	 fi
	 
else     echo -e "\nNot install!\n"

fi
