few improvements, consistency fixes

This commit is contained in:
levasseur
2021-10-06 17:55:04 +02:00
parent a1372a5d50
commit ee3a8d91ba
2 changed files with 20 additions and 12 deletions

15
init.sh
View File

@@ -44,9 +44,6 @@ export MYPATH=$(dirname $(realpath -s $0))
# Get hostname
export HOSTNAME=$(hostname)
# System architecture
export SYS_ARCH=$(uname -m)
# Load libraries
for lib in $MYPATH/lib/*.sh; do
. $lib
@@ -69,13 +66,13 @@ function_exists prnt || (
exit 3
)
# Set system dependent vars
get_os_version $(read_os_release)
# ======================
# ==== Main Program ====
# ======================
# Set system dependent vars
set_sys_vars $(uname -m) $(get_os_version)
# Initializing global variables
export CHECK_ONLY=false
export JUMP=false
@@ -109,7 +106,11 @@ exec > >(tee -a $LOGFILE)
exec 2> >(tee -a $LOGFILE >&2)
prnt I "Démarrage d'init version $VERSION."
prnt I "Le fichier de log est $LOGFILE."
prnt I "Lancé sur $SYS_DIST version $SYS_VER ($SYS_CODE) architecture $SYS_ARCH"
if [[ -n $SYS_CODE ]]; then
prnt I "Lancé sur $SYS_DIST version $SYS_VER ($SYS_CODE) architecture $SYS_ARCH"
else
prnt I "Lancé sur $SYS_DIST version $SYS_VER architecture $SYS_ARCH"
fi
# -- Cannot be a function ends here

View File

@@ -79,6 +79,8 @@ show_version()
local mod=
for mod in $MYPATH/modules/*.sh; do
# Ran in a subshell to not pollute environment
(
. $mod
local modname=$(get_mod_name $mod)
local version=VER_$modname
@@ -86,6 +88,7 @@ show_version()
echo -e "\t$BWhite$modname${DEFAULTCOL}: $BGreen${!version}$DEFAULTCOL"
unset modname version
)
done
unset mod
@@ -100,6 +103,10 @@ export -f show_version
# Get module name from module file
get_mod_name()
{
if [[ $# -ne 1 ]] then
prnt E "get_mod_name(): Bad number of parameters."
die 11 --force
fi
echo $(basename $1 | cut -f 1 -d '.')
}
export -f get_mod_name