few improvements, consistency fixes
This commit is contained in:
15
init.sh
15
init.sh
@@ -44,9 +44,6 @@ export MYPATH=$(dirname $(realpath -s $0))
|
|||||||
# Get hostname
|
# Get hostname
|
||||||
export HOSTNAME=$(hostname)
|
export HOSTNAME=$(hostname)
|
||||||
|
|
||||||
# System architecture
|
|
||||||
export SYS_ARCH=$(uname -m)
|
|
||||||
|
|
||||||
# Load libraries
|
# Load libraries
|
||||||
for lib in $MYPATH/lib/*.sh; do
|
for lib in $MYPATH/lib/*.sh; do
|
||||||
. $lib
|
. $lib
|
||||||
@@ -69,13 +66,13 @@ function_exists prnt || (
|
|||||||
exit 3
|
exit 3
|
||||||
)
|
)
|
||||||
|
|
||||||
# Set system dependent vars
|
|
||||||
get_os_version $(read_os_release)
|
|
||||||
|
|
||||||
# ======================
|
# ======================
|
||||||
# ==== Main Program ====
|
# ==== Main Program ====
|
||||||
# ======================
|
# ======================
|
||||||
|
|
||||||
|
# Set system dependent vars
|
||||||
|
set_sys_vars $(uname -m) $(get_os_version)
|
||||||
|
|
||||||
# Initializing global variables
|
# Initializing global variables
|
||||||
export CHECK_ONLY=false
|
export CHECK_ONLY=false
|
||||||
export JUMP=false
|
export JUMP=false
|
||||||
@@ -109,7 +106,11 @@ exec > >(tee -a $LOGFILE)
|
|||||||
exec 2> >(tee -a $LOGFILE >&2)
|
exec 2> >(tee -a $LOGFILE >&2)
|
||||||
prnt I "Démarrage d'init version $VERSION."
|
prnt I "Démarrage d'init version $VERSION."
|
||||||
prnt I "Le fichier de log est $LOGFILE."
|
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
|
# -- Cannot be a function ends here
|
||||||
|
|
||||||
|
|||||||
@@ -79,6 +79,8 @@ show_version()
|
|||||||
|
|
||||||
local mod=
|
local mod=
|
||||||
for mod in $MYPATH/modules/*.sh; do
|
for mod in $MYPATH/modules/*.sh; do
|
||||||
|
# Ran in a subshell to not pollute environment
|
||||||
|
(
|
||||||
. $mod
|
. $mod
|
||||||
local modname=$(get_mod_name $mod)
|
local modname=$(get_mod_name $mod)
|
||||||
local version=VER_$modname
|
local version=VER_$modname
|
||||||
@@ -86,6 +88,7 @@ show_version()
|
|||||||
echo -e "\t$BWhite$modname${DEFAULTCOL}: $BGreen${!version}$DEFAULTCOL"
|
echo -e "\t$BWhite$modname${DEFAULTCOL}: $BGreen${!version}$DEFAULTCOL"
|
||||||
|
|
||||||
unset modname version
|
unset modname version
|
||||||
|
)
|
||||||
done
|
done
|
||||||
unset mod
|
unset mod
|
||||||
|
|
||||||
@@ -100,6 +103,10 @@ export -f show_version
|
|||||||
# Get module name from module file
|
# Get module name from module file
|
||||||
get_mod_name()
|
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 '.')
|
echo $(basename $1 | cut -f 1 -d '.')
|
||||||
}
|
}
|
||||||
export -f get_mod_name
|
export -f get_mod_name
|
||||||
|
|||||||
Reference in New Issue
Block a user