fixed some issue on error treatment, some typo
This commit is contained in:
22
init.sh
22
init.sh
@@ -108,6 +108,12 @@ get_mod_name()
|
|||||||
# ==== Main Program ====
|
# ==== Main Program ====
|
||||||
# ======================
|
# ======================
|
||||||
|
|
||||||
|
# Initializing global variables
|
||||||
|
export CHECK_ONLY=false
|
||||||
|
export JUMP=false
|
||||||
|
export KEEPGOING=false
|
||||||
|
export RESUME=false
|
||||||
|
|
||||||
# Processing command line options
|
# Processing command line options
|
||||||
want_module=false
|
want_module=false
|
||||||
for opt in $@; do
|
for opt in $@; do
|
||||||
@@ -123,9 +129,10 @@ for opt in $@; do
|
|||||||
;;
|
;;
|
||||||
"-m"|"--module")
|
"-m"|"--module")
|
||||||
want_module=true
|
want_module=true
|
||||||
|
prnt W "Une liste de modules manuelle sera utilisé. $want_module"
|
||||||
;;
|
;;
|
||||||
"-c"|"--check-only")
|
"-c"|"--check-only")
|
||||||
export CHECKONLY=true
|
export CHECK_ONLY=true
|
||||||
;;
|
;;
|
||||||
"-j"|"--jump")
|
"-j"|"--jump")
|
||||||
export JUMP=true
|
export JUMP=true
|
||||||
@@ -176,7 +183,8 @@ prnt I "Création du répertoire d'accueil du fichier log..."
|
|||||||
# Log toutes les sortie dans le fichier de log
|
# Log toutes les sortie dans le fichier de log
|
||||||
exec 3>&1 4>&2
|
exec 3>&1 4>&2
|
||||||
trap 'exec 2>&4 1>&3' 0 1 2 3
|
trap 'exec 2>&4 1>&3' 0 1 2 3
|
||||||
exec 1>$LOGFILE 2>&1
|
exec > >(tee -a $LOGFILE)
|
||||||
|
exec 2> >(tee -a $LOGFILE >&2)
|
||||||
|
|
||||||
# Récupère la configuration
|
# Récupère la configuration
|
||||||
prnt I "Chargement de la configuration..."
|
prnt I "Chargement de la configuration..."
|
||||||
@@ -199,26 +207,26 @@ if [[ $want_module == true ]]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Check unconsistant parameters
|
# Check unconsistant parameters
|
||||||
[[ $CHECK_ONLY == true ]] && [[ $JUMP == true ]] && (
|
if [[ $CHECK_ONLY == true ]]; then
|
||||||
|
[[ $JUMP == true ]] && (
|
||||||
prnt E "Les options --check-only et --jump s'excluent mutuellement !"
|
prnt E "Les options --check-only et --jump s'excluent mutuellement !"
|
||||||
die 1 --force
|
die 1 --force
|
||||||
)
|
)
|
||||||
[[ $KEEPGOING == true ]] && [[ $CHECKONLY == true ]] && (
|
[[ $KEEPGOING == true ]] && (
|
||||||
prnt E "Les options --keep-going et --check-only sont incompatible !"
|
prnt E "Les options --keep-going et --check-only sont incompatible !"
|
||||||
die 1 --force
|
die 1 --force
|
||||||
)
|
)
|
||||||
|
fi
|
||||||
if [[ $RESUME == true ]]; then
|
if [[ $RESUME == true ]]; then
|
||||||
[[ $CHECK_ONLY == true ]] && (
|
[[ $CHECK_ONLY == true ]] && (
|
||||||
prnt E "La reprise n'a pas de sens avec --check-only."
|
prnt E "La reprise n'a pas de sens avec --check-only."
|
||||||
die 1 --force
|
die 1 --force
|
||||||
)
|
)
|
||||||
[[ $MANUAL_MODULE_LIST ]] && (
|
[[ $MANUAL_MODULE_LIST ]] && (
|
||||||
prnt E "Le mode reprise ne fonctionne pas avec une liste de \
|
prnt E "Le mode reprise ne fonctionne pas avec une liste de modules passé manuellement."
|
||||||
modules passé manuellement."
|
|
||||||
die 1 --force
|
die 1 --force
|
||||||
)
|
)
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
prnt I "That's all folks !"
|
prnt I "That's all folks !"
|
||||||
echo "Après vérification des logs, vous devriez redémarrer la machine..."
|
echo "Après vérification des logs, vous devriez redémarrer la machine..."
|
||||||
|
|||||||
@@ -4,14 +4,19 @@
|
|||||||
function die()
|
function die()
|
||||||
{
|
{
|
||||||
local errorcode=$1
|
local errorcode=$1
|
||||||
[[ $2 == "--force" ]] && unset KEEPGOING
|
|
||||||
|
|
||||||
if [[ $KEEPGOING ]]; then
|
# Don't trigger the ERR signal as we already managed the error
|
||||||
|
trap - ERR
|
||||||
|
|
||||||
|
if [[ "$KEEPGOING" != "true" || "$2" == "--force" ]]; then
|
||||||
prnt E "Sortie prématuré avec erreur (code #$errorcode)."
|
prnt E "Sortie prématuré avec erreur (code #$errorcode)."
|
||||||
exit $errorcode
|
exit $errorcode
|
||||||
else
|
else
|
||||||
prnt W "On continue malgrés l'erreur #$errorcode."
|
prnt W "On continue malgrés l'erreur #$errorcode."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Put the trigger back (only executed with --keepgoing)
|
||||||
|
trap "error ${LINENO}" ERR
|
||||||
}
|
}
|
||||||
export -f die
|
export -f die
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user