#!/bin/bash LANGUAGE_VALENCIAN="ca_ES@valencia:ca:qcv:es_ES:es:en" LANGUAGE_CASTILIAN="es_ES:es:en" LANGUAGE_ENGLISH="en_US:en" ENVIRONMENT_FILE="/etc/environment" DEFAULT_LOCALE_FILE="/etc/default/locale" TOKEN_DIR="/etc/lliurex-tokens/" TOKEN_LANGUAGE="/etc/lliurex-tokens/lliurex-language-fixer" TEMPLATE_VALENCIAN="/usr/share/language-pack-gnome-qcv-base/default.locale.valencia" # First test the TOKEN_DIR exists [ -d ${TOKEN_DIR} ] || mkdir -p ${TOKEN_DIR} # Testing if Andorra is present rc=0 cat $DEFAULT_LOCALE_FILE | grep -q "ca_AD" || rc=1 if [ ${rc} -eq 0 ]; then logger -t "lliurex-language-fixer" "Locale set to ca_ES.UTF-8@valencia" cp ${TEMPLATE_VALENCIAN} ${DEFAULT_LOCALE_FILE} logger -t "lliurex-language-fixer" "Setting the language and creating the token" date > ${TOKEN_LANGUAGE} fi # Testing if your are installed with Beta rc=0 cat $DEFAULT_LOCALE_FILE | grep -q "LANG=\"ca_ES.UTF-8$" || rc=1 if [ ${rc} -eq 0 ]; then logger -t "lliurex-language-fixer" "Locale is set but not correctly (on Beta Systems)" cp ${TEMPLATE_VALENCIAN} ${DEFAULT_LOCALE_FILE} date > ${TOKEN_LANGUAGE} fi # Testing if valencian is present #logger -t "lliurex-language-fixer" "Testing if valencian is present" #rc=0 #cat $DEFAULT_LOCALE_FILE | grep -q "LANG=\"ca_ES.UTF-8\"" || rc=1 #if [ ${rc} -eq 0 ]; then # logger -t "lliurex-language-fixer" "Locale is set but not correctly" # if [ ! -e ${TOKEN_LANGUAGE} ] ; then # logger -t "lliurex-language-fixer" "Setting the language and creating the token" # cp ${TEMPLATE_VALENCIAN} ${DEFAULT_LOCALE_FILE} # date > ${TOKEN_LANGUAGE} # else # logger -t "lliurex-language-fixer" "Token exists...nothing to do" # fi #else # logger -t "lliurex-language-fixer" "All seems to be ok" #fi # Tests on each boot rc=0 cat $ENVIRONMENT_FILE| grep -q ^LANGUAGE || rc=1 if [ $rc -eq 1 ]; then echo "Info: Not language setted" logger -t "lliurex-language-fixer" "Not language set..." current_locale="$(cat $DEFAULT_LOCALE_FILE| head -1 |cut -d "=" -f2)" echo "$current_locale" if [ "$current_locale" = "\"ca_ES.UTF-8@valencia\"" ]; then echo "LANGUAGE=$LANGUAGE_VALENCIAN" >> $ENVIRONMENT_FILE logger -t "lliurex-language-fixer" "LANGUAGE=$LANGUAGE_VALENCIAN >> $ENVIRONMENT_FILE" elif [ "$current_locale" = "\"es_ES.UTF-8\"" ]; then echo "LANGUAGE=$LANGUAGE_CASTILIAN" >> $ENVIRONMENT_FILE logger -t "lliurex-language-fixer" "LANGUAGE=$LANGUAGE_CASTILIAN >> $ENVIRONMENT_FILE" else echo "LANGUAGE=$LANGUAGE_VALENCIAN" >> $ENVIRONMENT_FILE logger -t "lliurex-language-fixer" "NOT FOUND..default: LANGUAGE=$LANGUAGE_VALENCIAN >> $ENVIRONMENT_FILE" fi fi rc=0 cat $ENVIRONMENT_FILE| grep -q ^LANGUAGE=\"ca_ES:ca\" || rc=1 if [ $rc -eq 0 ]; then current_locale="$(cat $DEFAULT_LOCALE_FILE| head -1 |cut -d "=" -f2)" echo "$current_locale" if [ "$current_locale" = "\"ca_ES.UTF-8@valencia\"" ]; then echo "LANGUAGE=$LANGUAGE_VALENCIAN" >> $ENVIRONMENT_FILE logger -t "lliurex-language-fixer" "LANGUAGE=$LANGUAGE_VALENCIAN >> $ENVIRONMENT_FILE" fi fi exit 0