From 3499fadbe7d481852d224929c0dc21f584f76868 Mon Sep 17 00:00:00 2001 From: Nebz <28622481+NebzHB@users.noreply.github.com> Date: Wed, 29 Dec 2021 07:42:51 +0100 Subject: [PATCH 1/8] add english --- dependance.lib | 94 +++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 77 insertions(+), 17 deletions(-) diff --git a/dependance.lib b/dependance.lib index 4c32833..cc35bc1 100644 --- a/dependance.lib +++ b/dependance.lib @@ -5,13 +5,21 @@ PROGRESS_FILE=${TMPFOLDER}/dependance HR=$(printf '=%.0s' {1..70}) TAB="echo -n "________"" +if [ -z $LANG_DEP ]; then + LANG_DEP=fr +fi + echo_success() { echo -en "[ OK ]\r" return 0 } echo_failure() { - echo -en "[ERREUR]\r" + if [ "$LANG_DEP" = "fr" ];then + echo -en "[ERREUR]\r" + else + echo -en "[ERROR]\r" + fi return 1 } @@ -44,7 +52,11 @@ info() { pre() { echo "$HR" - echo "== $(date +'%d/%m/%Y %H:%M:%S') == Installation des dépendances de $PLUGIN" + if [ "$LANG_DEP" = "fr" ];then + echo "== $(date +'%d/%m/%Y %H:%M:%S') == Installation des dépendances de $PLUGIN" + else + echo "== $(date +'%d/%m/%Y %H:%M:%S') == Dependencies installation for $PLUGIN" + fi echo "$HR" echo touch $TMPFOLDER/errorLog.$$ @@ -82,11 +94,19 @@ try() { echo 1 > $TMPFOLDER/hasError.$$ local LINE=${BASH_LINENO[0]} - echo -e "== Erreur à l'étape : $STEP_NAME" >> $TMPFOLDER/errorLog.$$ - echo -e "== Ligne $LINE" >> $TMPFOLDER/errorLog.$$ - echo -e "== La commande \`$*' pose problème" >> $TMPFOLDER/errorLog.$$ - echo -e "== Le code de retour est $EXIT_CODE" >> $TMPFOLDER/errorLog.$$ - echo -e "== Le message d'erreur :" >> $TMPFOLDER/errorLog.$$ + if [ "$LANG_DEP" = "fr" ];then + echo -e "== Erreur à l'étape : $STEP_NAME" >> $TMPFOLDER/errorLog.$$ + echo -e "== Ligne $LINE" >> $TMPFOLDER/errorLog.$$ + echo -e "== La commande \`$*' pose problème" >> $TMPFOLDER/errorLog.$$ + echo -e "== Le code de retour est $EXIT_CODE" >> $TMPFOLDER/errorLog.$$ + echo -e "== Le message d'erreur :" >> $TMPFOLDER/errorLog.$$ + else + echo -e "== Error in step : $STEP_NAME" >> $TMPFOLDER/errorLog.$$ + echo -e "== Line $LINE" >> $TMPFOLDER/errorLog.$$ + echo -e "== Command \`$*' have an issue" >> $TMPFOLDER/errorLog.$$ + echo -e "== Return code is $EXIT_CODE" >> $TMPFOLDER/errorLog.$$ + echo -e "== Error message :" >> $TMPFOLDER/errorLog.$$ + fi echo -e "$cmdout\n" >> $TMPFOLDER/errorLog.$$ echo -e "$HR" >> $TMPFOLDER/errorLog.$$ fi @@ -124,63 +144,103 @@ post() { next fi echo 100 > ${PROGRESS_FILE} - echo "[100% ] : Terminé !" + if [ "$LANG_DEP" = "fr" ];then + echo "[100% ] : Terminé !" + else + echo "[100% ] : Finished !" + fi [[ -f $TMPFOLDER/hasError.$$ ]] && { hasError=$(< $TMPFOLDER/hasError.$$); rm -f $TMPFOLDER/hasError.$$; } echo if [[ $hasError -eq 1 ]]; then echo "$HR" - echo "== KO == Erreur d'Installation" + if [ "$LANG_DEP" = "fr" ];then + echo "== KO == Erreur d'Installation" + else + echo "== KO == Installatino Error" + fi echo "$HR" [[ -f $TMPFOLDER/errorLog.$$ ]] && { HAS_FIX=0 - echo "== ANALYSE DES ERREURS..." + if [ "$LANG_DEP" = "fr" ];then + echo "== ANALYSE DES ERREURS..." + else + echo "== ANALYSING ERRORS..." + fi #try to fix if possible grep "apt --fix-broken install" $TMPFOLDER/errorLog.$$ &>/dev/null FOUND_FIX_BROKEN=$? if [[ $FOUND_FIX_BROKEN -eq 0 ]]; then - echo "== TROUVÉ 'sudo apt --fix-broken install' dans l'erreur, je lance la commande, attendez 45sec et relancez les dépendances pour réessayer" + if [ "$LANG_DEP" = "fr" ];then + echo "== TROUVÉ 'sudo apt --fix-broken install' dans l'erreur, je lance une commande pour corriger, attendez 45sec et relancez les dépendances pour réessayer" + else + echo "== FOUND 'sudo apt --fix-broken install' in error, launching countermeasures, wait 45sec and relaunch dependencies to retry" + fi yes | sudo apt --fix-broken install HAS_FIX=1 fi grep "sudo dpkg --configure -a" $TMPFOLDER/errorLog.$$ &>/dev/null FOUND_DPKG_CONFIGURE_A=$? if [[ $FOUND_DPKG_CONFIGURE_A -eq 0 ]]; then - echo "== TROUVÉ 'dpkg --configure -a' dans l'erreur, je lance la commande, attendez 45sec et relancez les dépendances pour réessayer" + if [ "$LANG_DEP" = "fr" ];then + echo "== TROUVÉ 'dpkg --configure -a' dans l'erreur, je lance une commande pour corriger, attendez 45sec et relancez les dépendances pour réessayer" + else + echo "== FOUND 'dpkg --configure -a' in error, launching countermeasures, wait 45sec and relaunch dependencies to retry" + fi sudo dpkg --configure -a --force-confdef HAS_FIX=1 fi grep "EINTEGRITY" $TMPFOLDER/errorLog.$$ &>/dev/null FOUND_EINTEGRITY=$? if [[ $FOUND_EINTEGRITY -eq 0 ]]; then - echo "== TROUVÉ 'EINTEGRITY' dans l'erreur, je lance une commande pour corriger, attendez 45sec et relancez les dépendances pour réessayer" + if [ "$LANG_DEP" = "fr" ];then + echo "== TROUVÉ 'EINTEGRITY' dans l'erreur, je lance une commande pour corriger, attendez 45sec et relancez les dépendances pour réessayer" + else + echo "== FOUND 'EINTEGRITY' in error, launching countermeasures, wait 45sec and relaunch dependencies to retry" + fi sudo npm cache clean --force HAS_FIX=1 fi grep "npm ERR! fatal: could not create leading directories of '/root/.npm/_cacache/tmp/" $TMPFOLDER/errorLog.$$ &>/dev/null FOUND_E128=$? if [[ $FOUND_E128 -eq 0 ]]; then - echo "== TROUVÉ 'code 128' dans l'erreur, je lance une commande pour corriger, attendez 45sec et relancez les dépendances pour réessayer" + if [ "$LANG_DEP" = "fr" ];then + echo "== TROUVÉ 'code 128' dans l'erreur, je lance une commande pour corriger, attendez 45sec et relancez les dépendances pour réessayer" + else + echo "== FOUND 'code 128' in error, launching countermeasures, wait 45sec and relaunch dependencies to retry" + fi sudo chown -R root:root /root/.npm HAS_FIX=1 fi grep "changed its 'Suite' value from 'testing' to 'oldstable'" $TMPFOLDER/errorLog.$$ &>/dev/null FOUND_OLDSTABLE=$? if [[ $FOUND_OLDSTABLE -eq 0 ]]; then - echo "== TROUVÉ 'changed its 'Suite' value from 'testing' to 'oldstable'' dans l'erreur, je lance une commande pour corriger, attendez 45sec et relancez les dépendances pour réessayer" + if [ "$LANG_DEP" = "fr" ];then + echo "== TROUVÉ -changed its 'Suite' value from 'testing' to 'oldstable'- dans l'erreur, je lance une commande pour corriger, attendez 45sec et relancez les dépendances pour réessayer" + else + echo "== FOUND -changed its 'Suite' value from 'testing' to 'oldstable'- in error, launching countermeasures, wait 45sec and relaunch dependencies to retry" + fi sudo apt-get --allow-releaseinfo-change update HAS_FIX=1 fi if [[ $HAS_FIX -eq 0 ]]; then #show the error - echo "== AUCUNE ERREUR CONNUE DÉTECTÉE" + if [ "$LANG_DEP" = "fr" ];then + echo "== AUCUNE ERREUR CONNUE DÉTECTÉE" + else + echo "== NO KNOWN ERROR DETECTED" + fi cat $TMPFOLDER/errorLog.$$; fi rm -f $TMPFOLDER/errorLog.$$; } else echo "$HR" - echo "== OK == Installation Réussie" + if [ "$LANG_DEP" = "fr" ];then + echo "== OK == Installation Réussie" + else + echo "== OK == Installation Successful" + fi echo "$HR" fi rm -f ${PROGRESS_FILE} From c604feb7217aa8dbbad4b8b817d4e419bdb9a4e5 Mon Sep 17 00:00:00 2001 From: Nebz <28622481+NebzHB@users.noreply.github.com> Date: Wed, 29 Dec 2021 08:39:33 +0100 Subject: [PATCH 2/8] typo --- dependance.lib | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dependance.lib b/dependance.lib index cc35bc1..3da5b1e 100644 --- a/dependance.lib +++ b/dependance.lib @@ -156,7 +156,7 @@ post() { if [ "$LANG_DEP" = "fr" ];then echo "== KO == Erreur d'Installation" else - echo "== KO == Installatino Error" + echo "== KO == Installation Error" fi echo "$HR" [[ -f $TMPFOLDER/errorLog.$$ ]] && { From 8126563ee600764c60b896e1e040077aeb44a9bf Mon Sep 17 00:00:00 2001 From: Nebz <28622481+NebzHB@users.noreply.github.com> Date: Wed, 29 Dec 2021 08:50:44 +0100 Subject: [PATCH 3/8] Update README.md --- README.md | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/README.md b/README.md index 288bf33..8be8d6b 100644 --- a/README.md +++ b/README.md @@ -26,8 +26,37 @@ post **IMPORTANT** : dont use try or silent if the command have >> | or > or < (output/input redirections), or in the last part of a piped command try : will try the commands of the line and catch errors (and display them) + silent : no matter if the commands fails +add LANG_DEP=en before the `. ${BASEDIR}/dependance.lib` line if you want messages in english instead of french +**example** : +``` +######################### INCLUSION LIB ########################## +BASEDIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ) +wget https://raw.githubusercontent.com/NebzHB/dependance.lib/master/dependance.lib -O $BASEDIR/dependance.lib &>/dev/null +PLUGIN=$(basename "$(realpath $BASEDIR/..)") +LANG_DEP=en +. ${BASEDIR}/dependance.lib +################################################################## + +pre +``` + +add TIMED=1 after the second `#####...` line (before the `pre`) to time each step. +**example** : +``` +######################### INCLUSION LIB ########################## +BASEDIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ) +wget https://raw.githubusercontent.com/NebzHB/dependance.lib/master/dependance.lib -O $BASEDIR/dependance.lib &>/dev/null +PLUGIN=$(basename "$(realpath $BASEDIR/..)") +. ${BASEDIR}/dependance.lib +################################################################## +TIMED=1 + +pre +``` + **result if ok** : ``` ====================================================================== From 7f479ea6065b0dc6bcfbe9a668e4cf42ce95e6dc Mon Sep 17 00:00:00 2001 From: Nebz <28622481+NebzHB@users.noreply.github.com> Date: Wed, 29 Dec 2021 08:51:53 +0100 Subject: [PATCH 4/8] Update README.md --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 8be8d6b..d2310cd 100644 --- a/README.md +++ b/README.md @@ -25,9 +25,9 @@ post ``` **IMPORTANT** : dont use try or silent if the command have >> | or > or < (output/input redirections), or in the last part of a piped command -try : will try the commands of the line and catch errors (and display them) +try : will try the commands of the line and catch errors (and display them at the end) -silent : no matter if the commands fails +silent : no matter if the commands fails, it'll be silent add LANG_DEP=en before the `. ${BASEDIR}/dependance.lib` line if you want messages in english instead of french **example** : From 2901bb9681279ff11de6f38edf6ab97c60c28f7f Mon Sep 17 00:00:00 2001 From: Nebz <28622481+NebzHB@users.noreply.github.com> Date: Wed, 29 Dec 2021 08:52:24 +0100 Subject: [PATCH 5/8] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index d2310cd..458c9e9 100644 --- a/README.md +++ b/README.md @@ -51,8 +51,8 @@ BASEDIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ) wget https://raw.githubusercontent.com/NebzHB/dependance.lib/master/dependance.lib -O $BASEDIR/dependance.lib &>/dev/null PLUGIN=$(basename "$(realpath $BASEDIR/..)") . ${BASEDIR}/dependance.lib -################################################################## TIMED=1 +################################################################## pre ``` From 782742c0bad56929951652a3542b42f920619a45 Mon Sep 17 00:00:00 2001 From: Nebz <28622481+NebzHB@users.noreply.github.com> Date: Wed, 29 Dec 2021 08:54:26 +0100 Subject: [PATCH 6/8] Update README.md --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 458c9e9..143a27e 100644 --- a/README.md +++ b/README.md @@ -43,15 +43,15 @@ LANG_DEP=en pre ``` -add TIMED=1 after the second `#####...` line (before the `pre`) to time each step. +add TIMED=1 before the `. ${BASEDIR}/dependance.lib` line to time each step. **example** : ``` ######################### INCLUSION LIB ########################## BASEDIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ) wget https://raw.githubusercontent.com/NebzHB/dependance.lib/master/dependance.lib -O $BASEDIR/dependance.lib &>/dev/null PLUGIN=$(basename "$(realpath $BASEDIR/..)") -. ${BASEDIR}/dependance.lib TIMED=1 +. ${BASEDIR}/dependance.lib ################################################################## pre From fe6cb5e6538227703e33c06f616afbad7d95f63a Mon Sep 17 00:00:00 2001 From: Nebz <28622481+NebzHB@users.noreply.github.com> Date: Wed, 29 Dec 2021 09:01:56 +0100 Subject: [PATCH 7/8] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 143a27e..b6bab23 100644 --- a/README.md +++ b/README.md @@ -29,7 +29,7 @@ try : will try the commands of the line and catch errors (and display them at th silent : no matter if the commands fails, it'll be silent -add LANG_DEP=en before the `. ${BASEDIR}/dependance.lib` line if you want messages in english instead of french +add LANG_DEP=en before the `. ${BASEDIR}/dependance.lib` line if you want messages in english instead of french. **example** : ``` ######################### INCLUSION LIB ########################## From 9d0a74fe5e4115fa63babe0b6401dcc71ee6d06b Mon Sep 17 00:00:00 2001 From: Nebz <28622481+NebzHB@users.noreply.github.com> Date: Wed, 29 Dec 2021 09:02:24 +0100 Subject: [PATCH 8/8] Update README.md --- README.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/README.md b/README.md index b6bab23..cd3ee1c 100644 --- a/README.md +++ b/README.md @@ -29,7 +29,9 @@ try : will try the commands of the line and catch errors (and display them at th silent : no matter if the commands fails, it'll be silent + add LANG_DEP=en before the `. ${BASEDIR}/dependance.lib` line if you want messages in english instead of french. + **example** : ``` ######################### INCLUSION LIB ########################## @@ -43,7 +45,9 @@ LANG_DEP=en pre ``` + add TIMED=1 before the `. ${BASEDIR}/dependance.lib` line to time each step. + **example** : ``` ######################### INCLUSION LIB ########################## @@ -57,6 +61,7 @@ TIMED=1 pre ``` + **result if ok** : ``` ======================================================================