#!/bin/sh # ------- # File: lliure-profile # Description: LliureX /etc/skel/.profile utility # 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" case "$1" in update) # divert if required if [ -r "$TEMPLATE_FILE" ] && [ "$(dpkg-divert --truename "$PROFILE_FILE")" = "$PROFILE_FILE" ] ; then dpkg-divert --package lliurex-base-files --rename --quiet --add --divert ${PROFILE_FILE}.orig ${PROFILE_FILE} || true fi # set default language and override with system default (if any) LANGUAGE="es_ES:es:en" for f in /etc/environment /etc/default/locale ; do [ ! -r "$f" ] || . $f done 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 ;; *) echo "Usage: $(basename "$0") {update|remove}" >&2 ;; esac exit 0