54 lines
1.9 KiB
Bash
54 lines
1.9 KiB
Bash
# -*- coding: utf-8 mode: sh -*- vim:sw=4:sts=4:et:ai:si:sta:fenc=utf-8
|
|
##@cooked nocomments
|
|
module: base.init base_ "Fonctions de base: initialiser l'environnement"
|
|
|
|
if [ -z "$NULIB_NO_INIT_ENV" ]; then
|
|
# Emplacement du script courant
|
|
if [ "$0" == "-bash" ]; then
|
|
MYNAME=
|
|
MYDIR=
|
|
MYSELF=
|
|
elif [ ! -f "$0" -a -f "${0#-}" ]; then
|
|
MYNAME="$(basename -- "${0#-}")"
|
|
MYDIR="$(dirname -- "${0#-}")"
|
|
MYDIR="$(cd "$MYDIR"; pwd)"
|
|
MYSELF="$MYDIR/$MYNAME"
|
|
else
|
|
MYNAME="$(basename -- "$0")"
|
|
MYDIR="$(dirname -- "$0")"
|
|
MYDIR="$(cd "$MYDIR"; pwd)"
|
|
MYSELF="$MYDIR/$MYNAME"
|
|
fi
|
|
[ -n "$NULIBDIR" ] || NULIBDIR="$MYDIR"
|
|
|
|
# Repertoire temporaire
|
|
[ -z "$TMPDIR" -a -d "$HOME/tmp" ] && TMPDIR="$HOME/tmp"
|
|
[ -z "$TMPDIR" ] && TMPDIR="${TMP:-${TEMP:-/tmp}}"
|
|
export TMPDIR
|
|
|
|
# User
|
|
[ -z "$USER" -a -n "$LOGNAME" ] && export USER="$LOGNAME"
|
|
|
|
# Le fichier nulibrc doit être chargé systématiquement
|
|
[ -f /etc/debian_chroot ] && NULIB_CHROOT=1
|
|
[ -f /etc/nulibrc ] && . /etc/nulibrc
|
|
[ -f ~/.nulibrc ] && . ~/.nulibrc
|
|
|
|
# Type de système sur lequel tourne le script
|
|
UNAME_SYSTEM=`uname -s`
|
|
[ "${UNAME_SYSTEM#CYGWIN}" != "$UNAME_SYSTEM" ] && UNAME_SYSTEM=Cygwin
|
|
[ "${UNAME_SYSTEM#MINGW32}" != "$UNAME_SYSTEM" ] && UNAME_SYSTEM=Mingw
|
|
UNAME_MACHINE=`uname -m`
|
|
if [ -n "$NULIB_CHROOT" ]; then
|
|
# Dans un chroot, il est possible de forcer les valeurs
|
|
[ -n "$NULIB_UNAME_SYSTEM" ] && eval "UNAME_SYSTEM=$NULIB_UNAME_SYSTEM"
|
|
[ -n "$NULIB_UNAME_MACHINE" ] && eval "UNAME_MACHINE=$NULIB_UNAME_MACHINE"
|
|
fi
|
|
|
|
# Nom d'hôte respectivement avec et sans domaine
|
|
# contrairement à $HOSTNAME, cette valeur peut être spécifiée, comme par ruinst
|
|
[ -n "$MYHOST" ] || MYHOST="$HOSTNAME"
|
|
[ -n "$MYHOSTNAME" ] || MYHOSTNAME="${HOSTNAME%%.*}"
|
|
export MYHOST MYHOSTNAME
|
|
fi
|