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 ====
|
||||
# ======================
|
||||
|
||||
# Initializing global variables
|
||||
export CHECK_ONLY=false
|
||||
export JUMP=false
|
||||
export KEEPGOING=false
|
||||
export RESUME=false
|
||||
|
||||
# Processing command line options
|
||||
want_module=false
|
||||
for opt in $@; do
|
||||
@@ -123,9 +129,10 @@ for opt in $@; do
|
||||
;;
|
||||
"-m"|"--module")
|
||||
want_module=true
|
||||
prnt W "Une liste de modules manuelle sera utilisé. $want_module"
|
||||
;;
|
||||
"-c"|"--check-only")
|
||||
export CHECKONLY=true
|
||||
export CHECK_ONLY=true
|
||||
;;
|
||||
"-j"|"--jump")
|
||||
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
|
||||
exec 3>&1 4>&2
|
||||
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
|
||||
prnt I "Chargement de la configuration..."
|
||||
@@ -199,26 +207,26 @@ if [[ $want_module == true ]]; then
|
||||
fi
|
||||
|
||||
# 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 !"
|
||||
die 1 --force
|
||||
)
|
||||
[[ $KEEPGOING == true ]] && [[ $CHECKONLY == true ]] && (
|
||||
[[ $KEEPGOING == true ]] && (
|
||||
prnt E "Les options --keep-going et --check-only sont incompatible !"
|
||||
die 1 --force
|
||||
)
|
||||
fi
|
||||
if [[ $RESUME == true ]]; then
|
||||
[[ $CHECK_ONLY == true ]] && (
|
||||
prnt E "La reprise n'a pas de sens avec --check-only."
|
||||
die 1 --force
|
||||
)
|
||||
[[ $MANUAL_MODULE_LIST ]] && (
|
||||
prnt E "Le mode reprise ne fonctionne pas avec une liste de \
|
||||
modules passé manuellement."
|
||||
prnt E "Le mode reprise ne fonctionne pas avec une liste de modules passé manuellement."
|
||||
die 1 --force
|
||||
)
|
||||
fi
|
||||
|
||||
|
||||
prnt I "That's all folks !"
|
||||
echo "Après vérification des logs, vous devriez redémarrer la machine..."
|
||||
|
||||
@@ -4,14 +4,19 @@
|
||||
function die()
|
||||
{
|
||||
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)."
|
||||
exit $errorcode
|
||||
else
|
||||
prnt W "On continue malgrés l'erreur #$errorcode."
|
||||
fi
|
||||
|
||||
# Put the trigger back (only executed with --keepgoing)
|
||||
trap "error ${LINENO}" ERR
|
||||
}
|
||||
export -f die
|
||||
|
||||
|
||||
Reference in New Issue
Block a user