#!/bin/sh # ------- # File: lliurex-default-language # Description: LliureX manager for LANGUAGE environment variable # Author: Luis Garcia Gisbert # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License along # with this program; if not, write to the Free Software Foundation, Inc., # 51 Franklin St, Fifth Floor, Boston MA 02110-1301 USA # -------- set -e PATH="/usr/sbin:/usr/bin:/sbin:/bin" PROFILE_FILE="/etc/skel/.profile" TEMPLATE_FILE="/usr/share/lliurex-base-files/templates/profile" usage(){ echo "Usage: $(basename "$0") show-default LANG" >&2 } generate_language(){ # $1 : LANG LANG0="${1%.*}" LANG00="${1%_*}" [ "$LANG00" != "qcv" ] || LANG00="$LANG00:es_ES:es" L="$LANG0:$LANG00:en" # remove duplicates L=$(echo "$L" |tr ":" "\n" |awk '!x[$0]++' |tr "\n" ":") L=${L%:} echo "$L" } ACTION="$1" case "$1" in current) generate_language "$LANG" ;; system) # search system's default LANG LANGUAGE="es_ES:es:en" for f in /etc/environment /etc/default/locale ; do [ ! -r "$f" ] || . $f done generate_language "$LANG" ;; test-current) PRO TMP_FILE="$(tempfile -m 644)" sed -e "s%_@_LANGUAGE_@_%$LANGUAGE%g" "$TEMPLATE_FILE" > "$TMP_FILE" mv -f "$TMP_FILE" "$PROFILE_FILE" ;; remove) # remove diversion if required if [ -r "${PROFILE_FILE}.orig" ][ "$(dpkg-divert --truename "$PROFILE_FILE")" != "$PROFILE_FILE" ] ; then rm -f "$PROFILE_FILE" dpkg-divert --package lliurex-base-files --rename --quiet --remove "$PROFILE_FILE" || true fi ;; *) usage ;; esac exit 0