bugfix, esthetic cleanup, better comments, version bump

This commit is contained in:
Geoffray Levasseur-Brandin
2024-06-21 16:19:44 +02:00
parent 9e49e3e4d7
commit bef205ae84
18 changed files with 634 additions and 571 deletions

View File

@@ -44,35 +44,34 @@ fi
# ------------------------------------------------------------------------------
# path* : private functions for PATH variable management
# ------------------------------------------------------------------------------
pathremove ()
pathremove()
{
local ifs=':'
local newpath
local dir
local pathvar=${2:-PATH}
for dir in ${!pathvar} ; do
if [ "$dir" != "$1" ] ; then
for dir in ${!pathvar}; do
if [ "$dir" != "$1" ]; then
newpath=${newpath:+$newpath:}$dir
fi
done
export $pathvar="$newpath"
}
pathprepend ()
pathprepend()
{
pathremove $1 $2
local pathvar=${2:-PATH}
export $pathvar="$1${!pathvar:+:${!pathvar}}"
}
pathappend ()
pathappend()
{
pathremove $1 $2
local pathvar=${2:-PATH}
export $pathvar="${!pathvar:+${!pathvar}:}$1"
}
# ------------------------------------------------------------------------------
# ------------------------------------------------------------------------------
# ********************************** MAIN PROGRAM ******************************
@@ -89,7 +88,7 @@ if [[ ! -e $MYPATH/profile.sh ]]; then
echo "[ Warning ] Path detection failed, trying to use pwd..."
MYPATH=$(pwd)
if [[ ! -e $MYPATH/profile.sh ]]; then
echo "[ Error ] Impossible to determine installation path, pretty much nothing will work."
echo "[ Error ] Impossible to determine installation path, pretty much nothing will work."
fi
fi
@@ -99,7 +98,7 @@ fi
export PROFVERSION=$(cat $MYPATH/version)
# Build PATH environment variable
if [[ $EUID -eq 0 ]] ; then
if [[ $EUID -eq 0 ]]; then
pathappend /sbin:/usr/sbin
fi
[[ -d /share/services/gestparc ]] && pathappend /share/services/gestparc
@@ -139,7 +138,7 @@ export DEFAULT_CITY="Toulouse"
[[ -f ~/.profile.conf ]] && . ~/.profile.conf
# Load module scripts
for script in $MYPATH/profile.d/*.sh ; do
for script in $MYPATH/profile.d/*.sh; do
if [[ -r $script ]]; then
. $script
fi