#!/bin/bash
export TEXTDOMAIN="zero-lliurex-flavours"
# LLiurex-info-version
FICHERO='/tmp/version.txt'
SALIDA='/tmp/salida.txt'
MSG_INFO=$(gettext "Operating System:")
MSG_BASADO=$(gettext "Based on:")
MSG_KERNEL=$(gettext "Kernel:")
MSG_TITLE=$(gettext "ABOUT")
MSG_USER=$(gettext "User")
cat /dev/null > $FICHERO
cat /dev/null > $SALIDA
lsb_release -a > $FICHERO
uname -a >> $FICHERO
#DESCRIPTION=$(grep Description $FICHERO | cut -c14-)
DESCRIPTION="LliureX 15.05"
if [ -f /etc/lsb-release.real ]; then
eval $(cat /etc/lsb-release.real)
DISTRIBUTION=$DISTRIB_ID
RELEASE=$DISTRIB_RELEASE
CODENAME=$DISTRIB_CODENAME
else
DISTRIBUTION=$(grep Distributor $FICHERO | cut -c17-)
RELEASE=$(grep Release $FICHERO | cut -c10-)
CODENAME=$(grep Codename $FICHERO | cut -c11-)
fi
LINUX=$(grep Linux $FICHERO| cut -d" " -f3)
WHOAMI=$(whoami)
#CADENA="$MSG_INFO\n$DESCRIPTION\n$MSG_BASADO\n$DISTRIBUTION $RELEASE ($CODENAME)\n$MSG_KERNEL\n$LINUX\n$MSG_USER\n$WHOAMI"
#Si el usuario (aparecía root siempre al lanzarse desde el zero center)
CADENA="$MSG_INFO\n$DESCRIPTION\n$MSG_BASADO\n$DISTRIBUTION $RELEASE ($CODENAME)\n$MSG_KERNEL\n$LINUX"
zenity --info --text="$CADENA" --title="$MSG_TITLE"
# End of Lliurex-info-version
MSG_WINDOW=$(gettext "Flavour Utility")
MSG_DISTRIBUTION=$(gettext "Your Lliurex flavour. Choose new flavour to incorporate or cancel button.")
MSG_CHECK=$(gettext "Check")
MSG_DESCRIPTION=$(gettext "Description")
MSG_ADVERTISE=$(gettext "Now, You will see your actual distribution.\nIf you want to change it, check.\n(It will install a metapackage)")
MSG_NOVERSION=$(gettext "No version detected: Check one at least.")
MSG_INCOMPATIBILITY1=$(gettext "Incompatibility between Server and Client detected.")
MSG_INCOMPATIBILITY2=$(gettext "Incompatibility between Biblio and Client detected.")
# Sabores de Lliurex
FLAVORSERVER="Lliurex Server"
FLAVORCLIENT="Lliurex Client"
FLAVORDESKTOP="Lliurex Desktop"
FLAVORMUSIC="Lliurex Music"
FLAVORINFANTIL="Lliurex Infantil"
FLAVORLITE="Lliurex Lite"
FLAVORPIME="Lliurex Pime"
FLAVORGVA="Lliurex Gva"
#Variable sin inicializar en /usr/share/lliurex-up/common-upgrade-vars.sh
#IS_PIME=0
ALL_CEROS="1111111111"
source /usr/share/lliurex-up/common-upgrade-vars.sh
_researchCddVersion
_discoverCddVersion
#Booleanos de LLiurex
IS_SERVER_BOOL="FALSE"
IS_CLIENT_BOOL="FALSE"
IS_DESKTOP_BOOL="FALSE"
IS_MUSIC_BOOL="FALSE"
IS_INFANTIL_BOOL="FALSE"
IS_LITE_BOOL="FALSE"
IS_PIME_BOOL="FALSE"
IS_GVA_BOOL="FALSE"
IFS="+"
#Inicializando la lista doble (check -- descripción)
TODOS=$IS_SERVER$IS_CLIENT$IS_DESKTOP$IS_MUSIC$IS_INFANTIL$IS_LITE$IS_PIME$IS_GVA
if [ $TODOS = $ALL_CEROS ] ; then
FLAVORS=("FALSE""+"$FLAVORSERVER"+""FALSE""+"$FLAVORCLIENT"+""FALSE""+"$FLAVORDESKTOP\
"+""FALSE""+"$FLAVORMUSIC"+""FALSE""+"$FLAVORINFANTIL"+""FALSE""+"$FLAVORLITE\
"+""FALSE""+"$FLAVORPIME"+""FALSE""+"$FLAVORGVA)
zenity --error --text="$MSG_NOVERSION"
else
if [ $IS_SERVER -eq 0 ] ; then IS_SERVER_BOOL="TRUE" ; fi
if [ $IS_CLIENT -eq 0 ] ; then IS_CLIENT_BOOL="TRUE" ; fi
if [ $IS_DESKTOP -eq 0 ] ; then IS_DESKTOP_BOOL="TRUE" ; fi
if [ $IS_MUSIC -eq 0 ] ; then IS_MUSIC_BOOL="TRUE" ; fi
if [ $IS_INFANTIL -eq 0 ] ; then IS_INFANTIL_BOOL="TRUE" ; fi
if [ $IS_LITE -eq 0 ] ; then IS_LITE_BOOL="TRUE" ; fi
if [ $IS_PIME -eq 0 ] ; then IS_PIME_BOOL="TRUE" ; fi
if [ $IS_GVA -eq 0 ] ; then IS_GVA_BOOL="TRUE" ; fi
FLAVORS=($IS_SERVER_BOOL"+"$FLAVORSERVER"+"$IS_CLIENT_BOOL"+"$FLAVORCLIENT"+"$IS_DESKTOP_BOOL"+"$FLAVORDESKTOP"+"$IS_INFANTIL_BOOL"+"$FLAVORINFANTIL)
zenity --info --text="$MSG_ADVERTISE"
fi
for elemento in $FLAVORS; do
LIST=(${LIST[@]} "$elemento")
done
RESULTADO=$(zenity --title="$MSG_WINDOW" --width=600 --height=400 --text="$MSG_DISTRIBUTION" --list --column="$MSG_CHECK" --column="$MSG_DESCRIPTION" --checklist ${LIST[*]})
IFS="|"
#Comprobar la incompatibilidad SERVER-CLIENT
RESULT_SERVER=0
RESULT_CLIENT=0
for result in $RESULTADO ; do
if [ $FLAVORSERVER = $result ] ; then RESULT_SERVER=1 ; fi
if [ $FLAVORCLIENT = $result ] ; then RESULT_CLIENT=1 ; fi
done
if [ $RESULT_SERVER$RESULT_CLIENT = "11" ] ; then
zenity --error --text="$MSG_INCOMPATIBILITY1"
exit 0
fi
if [ $IS_SERVER$RESULT_CLIENT = "01" ] ; then
zenity --error --text="$MSG_INCOMPATIBILITY1"
exit 0
fi
if [ $RESULT_SERVER$IS_CLIENT = "10" ] ; then
zenity --error --text="$MSG_INCOMPATIBILITY1"
exit 0
fi
#Vaciar el fichero metapaquetes
:>/tmp/metapaquetes
#Arrastrar el metapaquete adecuado
echo $RESULTADO
if [[ -z ${RESULTADO} ]] ; then exit 0
fi
for result in $RESULTADO ; do
if [ $FLAVORCLIENT = $result ] ; then echo "lliurex-cdd-edu-class-gclient install" >> /tmp/metapaquetes ; fi
if [ $FLAVORDESKTOP = $result ] ; then
if [ $RESULT_SERVER -eq 1 ] ; then
echo "lliurex-cdd-edu-class-gserver install" >> /tmp/metapaquetes
else
echo "lliurex-cdd-edu-gdesktop install" >> /tmp/metapaquetes
fi
fi
if [ $FLAVORINFANTIL = $result ] ; then
echo "lliurex-cdd-edu-infantil-gdesktop install" >> /tmp/metapaquetes
fi
done
apt-get update | zenity --progress --pulsate --width=400 --height=80 --title "SimpleUpdate" --text "Updating repositories..." --auto-close
synaptic --hide-main-window --non-interactive --set-selections-file /tmp/metapaquetes -o APT::Get::Assume-Yes=true -o APT::Get::force-yes=true -o APT::Get::AllowUnauthenticated=true
exit 0