SEARCH :

Custom Search

Thursday, April 19, 2007

XGL Installation Script

Do you find a bad result when you install XGL on your distro? Do you tired or confuse about XGL installation? When i'm searching about XGL on uncle google, i find something interested for me. It's an script to install XGL automaticly..=P May be some people will call us scriptkiddie if we use that script, but it's okey for me.. scriptkidie is a process.. Every great hacker never be like that from he or she started learn about komputer. They are learning step by step include from scriptkiddie.^^
The script are listing below.. to use it,just copy and paste it into your text editor and then save as installXGL.sh
to run it you can write
#chmod +x installXGL.sh
#./installXGL.sh
it's otomaticly will install XGL on your distro...

#!/bin/sh

# 20/01/07 - version 1
# 06/02/07 - version 2 Mis à jour pour pouvoir faire des updates
# 08/03/07 - version 3 Possibilité de désinstaller
#
# 23/02/07 - English version. Original is at
# http://nicofo.tuxfamily.org/scripts/xgl/installXGL
#
# nicofo - http://nicofo.tuxfamily.org
#
# installation et configuration automatique de xgl et compiz pour GNOME, KDE et XFCE

testRoot()
{
if [ $(id -u) -ne 0 ]; then
echo -e "The installation and configuration of XGL must be run as \033[1mroot\033[0m."
exit 1
fi
}

#RPM à installer :
RPM="
compiz-1.0.0-5.i386.rpm
fedora-xgl-settings-0.0.1-2.noarch.rpm
gset-compiz-0.3.3-1.i386.rpm
libsvg-0.1.4-1.i386.rpm
libsvg-cairo-0.1.6-1.i386.rpm
xgl-hardware-list-1.0.0-2.noarch.rpm
xorg-x11-server-Xgl-1.1.99.1-3.i386.rpm"

if [ $# -ge 1 ]; then
if [ $1 = "-r" ] || [ $1 = "--remove" ]; then
testRoot

#Déconfigurer XGL :
echo "1) Remove configuration files... "
wget http://nicofo.tuxfamily.org/scripts/xgl/configureXgl -O configureXgl
sh configureXgl -r

#Supprimer les RPM installés :
echo -e "\n2) Uninstall XGL..."
RPM_R=$(echo "$RPM"|sed "s/.rpm//")
rpm -e $RPM_R
rpm -e fedora-xgl-repository
if [ -z "$(rpm -e glitz-glx glitz --test)" ]; then
rpm -e glitz-glx glitz
fi

#Supprimer Beryl :
if [ -f /usr/bin/beryl ]; then
echo
read -p "3) Do you want to remove Beryl also [y/N] ?" res
if [ "$res" == "y" ] || [ "$res" == "Y" ] ;then
yum remove beryl\*
fi
fi

echo -e "\nUninstallation finished."
else
echo "Usage :"
echo " installXGL install and configure XGL and compiz,"
echo " installXGL -r|--remove uninstall XGL and compiz."
fi
exit 0
fi

testRoot

texte=(
"Installation of the XGL repository"
"Removal of the current version of compiz"
"Installation of XGL and compiz"
"Configuration of XGL for compiz and beryl"
)

N=${#texte[*]} #nombre total d'étapes = nombre d'éléments dans $texte (ou : ${#texte[@]})
n=0 #étape actuelle (à partir de 0)

#$etat = status de l'étape précédente
#0=OK ; autre=KO ; -1=STOP ; -2=so (sans objet)
etat=0
erreur=""

avant="\033[2m"
actuel="\033[1;5;33;42m"
apres="\033[1;34m"
normal="\033[m"
ok="\033[1;32m[ OK ]\033[0m"
ko="\033[1;31m[ KO ]\033[0m"
so="\033[1;36m[Alrdy done]\033[0m"

stop()
{
echo
echo -e "\033[31m$erreur\033[0m"
read -p "Installation cannot continue. Do you want to continue anyway [y/N] ? " res
if [ ! "$res" == "y" ] && [ ! "$res" == "Y" ] ;then
exit $n
fi
echo
etat=0
erreur=""
}

menu()
{
#status : 0=OK ; autre=KO ; -1=STOP ; -2=so (sans objet)
if [ $n -gt 0 ]; then
status[$((n-1))]=$etat
fi

if [ $etat -eq -1 ]; then
stop
fi

clear

for i in $(seq 0 $(($N-1))); do
if [ $i -lt $n ]; then
echo -en $avant
elif [ $i -eq $n ]; then
echo -en $actuel
else
echo -en $apres
fi

echo -n "$(($i+1))) ${texte[$i]}"

if [ $i -lt $n ]; then
echo -en "\033[500C\033[15D$normal" #fin ligne
if [ ${status[$i]} -eq 0 ]; then
echo -e "$ok"
elif [ ${status[$i]} -eq -2 ]; then
echo -e "$so"
else
echo -e "$ko"
fi
else
echo -e "$normal"
fi
done
n=$(($n+1))
echo ; echo

erreur=""
etat=0
}

#Installation du dépôt 'fedora-xgl' (pour les mises à jour p. ex.)
menu
if [ "$(rpm -q fedora-xgl-repository)" = "fedora-xgl-repository-1.0-3" ]; then
etat=-2
else
rpm -Uhv http://fedoraxgl.tuxfamily.org/repository/fedora-xgl-repository-1.0-3.noarch.rpm
etat=$?
sed -i "s#\$releasever#5#g" /etc/yum.repos.d/fedora-xgl.repo
fi


#Désinstallation de la version actuelle de compiz
menu
tmp=$(rpm -q compiz)
if [ $? -ne 0 ] || [ "$tmp" = "compiz-1.0.0-5" ] ; then
etat=-2
else
rpm -e compiz
if [ $? -ne 0 ]; then
etat=-1;
erreur="Cannot remove the current version of compiz."
fi
fi


#Installation de XGL et compiz
menu
if [ "$(rpm -q compiz)" = "compiz-1.0.0-5" ] \
&& [ "$(rpm -q xorg-x11-server-Xgl)" = "xorg-x11-server-Xgl-1.1.99.1-3" ]; then
etat=-2
else #installation :

yum -y install glitz-glx
if [ $? -ne 0 ]; then
erreur="Error while installing the dependencies (glitz-glx) of XGL."
stop
fi

site="http://fedoraxgl.tuxfamily.org/repository/5/i386"
for file in $RPM; do
wget $site/$file
if [ ! -f ${file} ]; then
erreur="Error while downloading '$site/$file'."
stop
break
fi
done

rpm -Uhv $RPM
if [ $? -ne 0 ] ; then
etat=-1
erreur="Error at the installation of the RPM of XGL and compiz."
else
rm -f $RPM
fi

fi


#Configuration de XGL pour compiz et beryl
menu
wget http://nicofo.tuxfamily.org/scripts/xgl/xgl_demarrage_GDM.tar.gz
if [ ! -f xgl_demarrage_GDM.tar.gz ]; then
erreur="Error while downloading 'http://nicofo.tuxfamily.org/scripts/xgl/xgl_demarrage_GDM.tar.gz'."
etat=-1
else
tar -xzf xgl_demarrage_GDM.tar.gz

#traduction en anglais de 'chooseCompositeWM'
FR=(
"texte=(.*)"
"Gestionnaire de fenêtres avec XGL"
"Quel gestionnaire de fenêtres voulez-vous avec XGL ?"
"--column=\"Gestionnaire de fenêtres\""
"Beryl n'est pas installé.*yum :"
"Voulez-vous appliquer la.*session."
"La modification aura lieu au prochain démarrage de votre session."
)

EN=(
"texte=(\"Compiz\" \"Beryl (with beryl-manager)\" \"Beryl (without beryl-manager)\" \"(No composite window manager)\")"
"Composite window manager with XGL"
"Which composite window manager do you want with XGL ?"
"--column=\"Window manager\""
"Beryl is not installed ! \\\nYou can install it using yum:"
"Do you want to apply the modification now ?\\\n\\\nOtherwise, the modification will take place with the next starting of your session."
"The modification will take place with the next starting of your session."
)

i=0
for fr in "${FR[@]}"; do
# echo "$fr -> ${EN[$i]}"
sed -i "s/$fr/${EN[$i]}/" chooseCompositeWM
i=$(($i+1))
done

./configureXgl
if [ $? -ne 0 ]; then etat=-1; fi
rm -f xgl_demarrage_GDM.tar.gz $(tar -tf xgl_demarrage_GDM.tar.gz)
fi


#Fin
menu
if [ ! -f /usr/bin/beryl ]; then
echo -e "\033[1;34m -------INFO-------------------------------------------------------------"
echo -e " \033[1mCompiz\033[0;34m has been installed. But you can also install \033[1mBeryl\033[0;34m with yum :\n\t\033[1;47;30myum install beryl\033[0m"
echo -e "\033[1;34m ------------------------------------------------------------------------\033[0m\n"
fi

echo -e "Installation finished. You can now launch a new GNOME, KDE or XFCE session and\nchoose \033[1mXGL\033[0m."
echo -e "At any time you can choose to use \033[1mCompiz\033[0m or \033[1mBeryl\033[0m through the Gnome/KDE menu -> Preferences/Settings -> \"XGL Window Manager\"."
#end of script (copy until here)

long enaugh?he3.. now enjoy your XGL....

No comments: