From 2de98f91e856e26bf94301aa66c92cf6413091c0 Mon Sep 17 00:00:00 2001 From: levasseur Date: Mon, 20 Sep 2021 16:42:52 +0200 Subject: [PATCH] added shell option --- init.sh | 23 +++++++++++++++++++---- lib/support.sh | 3 +++ lib/zzz_main_fct.sh | 3 +++ 3 files changed, 25 insertions(+), 4 deletions(-) diff --git a/init.sh b/init.sh index ef9a2f6..127d24c 100755 --- a/init.sh +++ b/init.sh @@ -36,7 +36,7 @@ export LC_ALL=C export LANG=C # Version of init -export VERSION="0.99.5" +export VERSION="0.99.6" # Store script's path export MYPATH=$(dirname $0) @@ -120,9 +120,22 @@ if [[ $RESUME != true ]]; then [[ -f $STAGE_FILE ]] && rm -f $STAGE_FILE fi +# Loading modules +for mod in $MODULE_LIST; do + . modules/$mod.sh +done + +if [[ $RUN_SHELL == true ]]; then + OLD_PS1=$PS1 + export PS1="(init.sh) $PS1" + bash + export PS1=$OLD_PS1 + prnt I "Sortie du script après exécution du shell." + exit 0 +fi + # Run prechecks [[ JUMP != true ]] && for mod in $MODULE_LIST; do - . modules/$mod.sh version=VER_$mod prnt I "Vérification initiale pour $mod version ${!version}..." precheck_$mod @@ -140,6 +153,7 @@ else prnt I "Toutes les vérification ont été faites." fi echo + if [[ $KEEPGOING == true ]]; then echo -e "${BRed}ATTENTION : Vous avez demandé la poursuite du script en cas d'erreur.${DEFAULTCOL}" echo -e "${BRed}ATTENTION : Cette option peut produires des résultats chaotiques.${DEFAULTCOL}" @@ -148,8 +162,10 @@ if [[ $KEEPGOING == true ]]; then fi echo -e "${BYellow}Si vous continuez après cette étape le système sera modifié !${DEFAULTCOL}" echo + while read -r -t 0.001; do :; done # Dump the buffer -read -n 1 -rsp $"Appuyer sur la touche pour continuer ou une autre pour s'arrêter...\n" key +read -n 1 -rsp $"Appuyer sur la touche pour continuer ou une autre pour s'arrêter..." key +echo if [[ $key == "C" || $key == 'c' ]]; then # We launch modules one after one @@ -158,7 +174,6 @@ if [[ $key == "C" || $key == 'c' ]]; then continue fi # We need this only if JUMP is set but doesn't matter if it's done again - . modules/$mod.sh version=VER_$mod prnt I "Application des modifications pour $mod version ${!version}..." $mod diff --git a/lib/support.sh b/lib/support.sh index 8123597..94b8ac2 100644 --- a/lib/support.sh +++ b/lib/support.sh @@ -36,6 +36,9 @@ Options : -P, --no-proxy Ne pas utiliser de proxy lors de l'utilisation de ce script (n'empêche pas leur configuration via modules) -h, --help Affiche ce texte d'aide. + -s, --shell Lance un shell avec tout l'environnement du script pour + débogage. Aucune action ou vérification n'est faite en + dehors des commandes lancées dans le shell. -l, --logfile Nom du fichier de log. Peut aussi être changé via la variable d'environnement LOGFILE. -v, --version Affiche la version de ce script et celles de diff --git a/lib/zzz_main_fct.sh b/lib/zzz_main_fct.sh index fb9cc3c..1ab44a3 100644 --- a/lib/zzz_main_fct.sh +++ b/lib/zzz_main_fct.sh @@ -68,6 +68,9 @@ read_commandline() "-f"|"--file") local want_conffile=true ;; + "-s"|"--shell") + export RUN_SHELL=true + ;; *) if [[ $want_module == true ]]; then [[ $want_logfile == true ]] && synthax_error