From 7e3fcdb5f9d205ad2a30b0a8b893b116786dd750 Mon Sep 17 00:00:00 2001 From: Robin Candau Date: Sun, 19 May 2024 21:53:21 +0200 Subject: [PATCH 01/10] Make the reboot countdown after a kernel upgrade showing remaining seconds in real time This commit makes the 5 seconds countdow before a reboot to apply a pending kernel update show the remaining seconds in real time. --- src/script/arch-update.sh | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/script/arch-update.sh b/src/script/arch-update.sh index 43a67a6..a76de8b 100755 --- a/src/script/arch-update.sh +++ b/src/script/arch-update.sh @@ -606,8 +606,11 @@ kernel_reboot() { case "${answer}" in "$(eval_gettext "Y")"|"$(eval_gettext "y")") echo - main_msg "$(eval_gettext "Rebooting in 5 seconds...\nPress ctrl+c to abort")" - sleep 5 + for sec in {5..1}; do + main_msg "$(eval_gettext "Rebooting in ${sec}...\r")" + sleep 1 + done + if ! reboot; then echo error_msg "$(eval_gettext "An error has occurred during the reboot process\nThe reboot has been aborted\n")" && quit_msg From 15166c40e2abe5dc08cfc387f7fbeb22f2310137 Mon Sep 17 00:00:00 2001 From: Robin Candau Date: Sun, 19 May 2024 21:59:37 +0200 Subject: [PATCH 02/10] Add the necessary -n option to echo --- src/script/arch-update.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/script/arch-update.sh b/src/script/arch-update.sh index a76de8b..dbbeef7 100755 --- a/src/script/arch-update.sh +++ b/src/script/arch-update.sh @@ -89,13 +89,13 @@ mkdir -p "${statedir}" "${tmpdir}" # Definition of the main_msg function: Display a message as a main message main_msg() { msg="${1}" - echo -e "${blue}==>${color_off}${bold} ${msg}${color_off}" + echo -ne "${blue}==>${color_off}${bold} ${msg}${color_off}" } # Definition of the info_msg function: Display a message as an information message info_msg() { msg="${1}" - echo -e "${green}==>${color_off}${bold} ${msg}${color_off}" + echo -ne "${green}==>${color_off}${bold} ${msg}${color_off}" } # Definition of the ask_msg function: Display a message as an interactive question @@ -107,13 +107,13 @@ ask_msg() { # Definition of the warning_msg function: Display a message as a warning message warning_msg() { msg="${1}" - echo -e "${yellow}==> WARNING:${color_off}${bold} ${msg}${color_off}" + echo -ne "${yellow}==> WARNING:${color_off}${bold} ${msg}${color_off}" } # Definition of the error_msg function: Display a message as an error message error_msg() { msg="${1}" - echo -e >&2 "${red}==> ERROR:${color_off}${bold} ${msg}${color_off}" + echo -ne >&2 "${red}==> ERROR:${color_off}${bold} ${msg}${color_off}" } # Definition of the continue_msg function: Display the continue message From b09d4a6757875ccacd0e849a59d7bf4710f1aea1 Mon Sep 17 00:00:00 2001 From: Robin Candau Date: Sun, 19 May 2024 22:02:43 +0200 Subject: [PATCH 03/10] Don't use main msg functions --- src/script/arch-update.sh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/script/arch-update.sh b/src/script/arch-update.sh index dbbeef7..dfa09b5 100755 --- a/src/script/arch-update.sh +++ b/src/script/arch-update.sh @@ -89,13 +89,13 @@ mkdir -p "${statedir}" "${tmpdir}" # Definition of the main_msg function: Display a message as a main message main_msg() { msg="${1}" - echo -ne "${blue}==>${color_off}${bold} ${msg}${color_off}" + echo -e "${blue}==>${color_off}${bold} ${msg}${color_off}" } # Definition of the info_msg function: Display a message as an information message info_msg() { msg="${1}" - echo -ne "${green}==>${color_off}${bold} ${msg}${color_off}" + echo -e "${green}==>${color_off}${bold} ${msg}${color_off}" } # Definition of the ask_msg function: Display a message as an interactive question @@ -107,13 +107,13 @@ ask_msg() { # Definition of the warning_msg function: Display a message as a warning message warning_msg() { msg="${1}" - echo -ne "${yellow}==> WARNING:${color_off}${bold} ${msg}${color_off}" + echo -e "${yellow}==> WARNING:${color_off}${bold} ${msg}${color_off}" } # Definition of the error_msg function: Display a message as an error message error_msg() { msg="${1}" - echo -ne >&2 "${red}==> ERROR:${color_off}${bold} ${msg}${color_off}" + echo -e >&2 "${red}==> ERROR:${color_off}${bold} ${msg}${color_off}" } # Definition of the continue_msg function: Display the continue message @@ -607,7 +607,7 @@ kernel_reboot() { "$(eval_gettext "Y")"|"$(eval_gettext "y")") echo for sec in {5..1}; do - main_msg "$(eval_gettext "Rebooting in ${sec}...\r")" + echo -ne "${blue}==>${color_off}${bold} "$(eval_gettext "Rebooting in ${sec}...\r")"${color_off}" sleep 1 done From 9755b81555f20aa35a1f54ae234364c0e051ef91 Mon Sep 17 00:00:00 2001 From: Robin Candau Date: Sun, 19 May 2024 22:33:57 +0200 Subject: [PATCH 04/10] Hide cursor during the countdown --- src/script/arch-update.sh | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/script/arch-update.sh b/src/script/arch-update.sh index dfa09b5..b4fa491 100755 --- a/src/script/arch-update.sh +++ b/src/script/arch-update.sh @@ -606,8 +606,13 @@ kernel_reboot() { case "${answer}" in "$(eval_gettext "Y")"|"$(eval_gettext "y")") echo + + restore_cursor() { + tput cnorm + } + trap restore_cursor EXIT for sec in {5..1}; do - echo -ne "${blue}==>${color_off}${bold} "$(eval_gettext "Rebooting in ${sec}...\r")"${color_off}" + tput civis ; echo -ne "${blue}==>${color_off}${bold} "$(eval_gettext "Rebooting in ${sec}...\r")"${color_off}" sleep 1 done From 114f3d7dd9a2701fa222332258d434091b2ceb8a Mon Sep 17 00:00:00 2001 From: Robin Candau Date: Sun, 19 May 2024 22:41:23 +0200 Subject: [PATCH 05/10] Ignore shellcheck disable=SC2317 which incorrectly believe that code is unreachable as it is invoked in a trap --- src/script/arch-update.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/src/script/arch-update.sh b/src/script/arch-update.sh index b4fa491..e23b611 100755 --- a/src/script/arch-update.sh +++ b/src/script/arch-update.sh @@ -607,6 +607,7 @@ kernel_reboot() { "$(eval_gettext "Y")"|"$(eval_gettext "y")") echo + # shellcheck disable=SC2317 restore_cursor() { tput cnorm } From 13c20c3a163fe9d0f541a1fb16bed03257be2f38 Mon Sep 17 00:00:00 2001 From: Robin Candau Date: Sun, 19 May 2024 22:43:12 +0200 Subject: [PATCH 06/10] Ignore shellcheck SC2329 which incorrectly believe that code is unreachable as it is invoked in a trap --- src/script/arch-update.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/script/arch-update.sh b/src/script/arch-update.sh index e23b611..915b403 100755 --- a/src/script/arch-update.sh +++ b/src/script/arch-update.sh @@ -607,7 +607,7 @@ kernel_reboot() { "$(eval_gettext "Y")"|"$(eval_gettext "y")") echo - # shellcheck disable=SC2317 + # shellcheck disable=SC2317,SC2329 restore_cursor() { tput cnorm } From 323c4dcc03dace758c6737d0a15ca4fc5b8dc662 Mon Sep 17 00:00:00 2001 From: Robin Candau Date: Sun, 19 May 2024 22:44:40 +0200 Subject: [PATCH 07/10] Fix shellcheck --- src/script/arch-update.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/script/arch-update.sh b/src/script/arch-update.sh index 915b403..49bc05d 100755 --- a/src/script/arch-update.sh +++ b/src/script/arch-update.sh @@ -613,7 +613,7 @@ kernel_reboot() { } trap restore_cursor EXIT for sec in {5..1}; do - tput civis ; echo -ne "${blue}==>${color_off}${bold} "$(eval_gettext "Rebooting in ${sec}...\r")"${color_off}" + tput civis ; echo -ne "${blue}==>${color_off}${bold} $(eval_gettext "Rebooting in ${sec}...\r")${color_off}" sleep 1 done From e63e2afd378c5adb91fa1e55fe6df3a526ae0637 Mon Sep 17 00:00:00 2001 From: Robin Candau Date: Sun, 19 May 2024 22:53:04 +0200 Subject: [PATCH 08/10] Update translation files --- po/arch-update.pot | 14 +++++++------- po/fr.po | 16 ++++++++-------- src/script/arch-update.sh | 2 +- 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/po/arch-update.pot b/po/arch-update.pot index 6bca749..70362d4 100644 --- a/po/arch-update.pot +++ b/po/arch-update.pot @@ -423,38 +423,38 @@ msgstr "" msgid "Would you like to reboot now? [y/N]" msgstr "" -#: src/script/arch-update.sh:609 +#: src/script/arch-update.sh:616 #, sh-format -msgid "Rebooting in 5 seconds...\\nPress ctrl+c to abort" +msgid "Rebooting in ${sec}...\\r" msgstr "" -#: src/script/arch-update.sh:613 +#: src/script/arch-update.sh:622 #, sh-format msgid "" "An error has occurred during the reboot process\\nThe reboot has been " "aborted\\n" msgstr "" -#: src/script/arch-update.sh:621 +#: src/script/arch-update.sh:630 #, sh-format msgid "" "The reboot hasn't been performed\\nPlease, consider rebooting to finalize " "the pending kernel update\\n" msgstr "" -#: src/script/arch-update.sh:625 +#: src/script/arch-update.sh:634 #, sh-format msgid "No pending kernel update found\\n" msgstr "" -#: src/script/arch-update.sh:673 +#: src/script/arch-update.sh:682 #, sh-format msgid "" "The '${config_file}' configuration file already exists\\nPlease, remove it " "before generating a new one" msgstr "" -#: src/script/arch-update.sh:678 +#: src/script/arch-update.sh:687 #, sh-format msgid "The '${config_file}' configuration file has been generated" msgstr "" diff --git a/po/fr.po b/po/fr.po index 1944a53..a4a4cf6 100644 --- a/po/fr.po +++ b/po/fr.po @@ -452,12 +452,12 @@ msgstr "" msgid "Would you like to reboot now? [y/N]" msgstr "Voulez-vous redémarrer votre système maintenant ? [o/N]" -#: src/script/arch-update.sh:609 +#: src/script/arch-update.sh:616 #, sh-format -msgid "Rebooting in 5 seconds...\\nPress ctrl+c to abort" -msgstr "Redémarrage dans 5 secondes...\\nAppuyez sur ctrl+c pour annuler" +msgid "Rebooting in ${sec}...\\r" +msgstr "Redémarrage dans ${sec}...\\r" -#: src/script/arch-update.sh:613 +#: src/script/arch-update.sh:622 #, sh-format msgid "" "An error has occurred during the reboot process\\nThe reboot has been " @@ -466,7 +466,7 @@ msgstr "" "Une erreur est survenue pendant le processus de redémarrage\\nLe redémarrage a été " "abandonné\\n" -#: src/script/arch-update.sh:621 +#: src/script/arch-update.sh:630 #, sh-format msgid "" "The reboot hasn't been performed\\nPlease, consider rebooting to finalize " @@ -475,12 +475,12 @@ msgstr "" "Le redémarrage n'a pas été effectué\\nVeuillez considérer redémarrer votre système pour finaliser " "la mise à jour du noyau en attente\\n" -#: src/script/arch-update.sh:625 +#: src/script/arch-update.sh:634 #, sh-format msgid "No pending kernel update found\\n" msgstr "Aucune mise à jour du noyau en attente n'a été trouvée\\n" -#: src/script/arch-update.sh:673 +#: src/script/arch-update.sh:682 #, sh-format msgid "" "The '${config_file}' configuration file already exists\\nPlease, remove it " @@ -489,7 +489,7 @@ msgstr "" "Le fichier de configuration '${config_file}' existe déjà.\\nVeuillez le supprimer " "avant d'en générer un nouveau" -#: src/script/arch-update.sh:678 +#: src/script/arch-update.sh:687 #, sh-format msgid "The '${config_file}' configuration file has been generated" msgstr "Le fichier de configuration '${config_file}' a été généré" diff --git a/src/script/arch-update.sh b/src/script/arch-update.sh index 49bc05d..352b716 100755 --- a/src/script/arch-update.sh +++ b/src/script/arch-update.sh @@ -613,7 +613,7 @@ kernel_reboot() { } trap restore_cursor EXIT for sec in {5..1}; do - tput civis ; echo -ne "${blue}==>${color_off}${bold} $(eval_gettext "Rebooting in ${sec}...\r")${color_off}" + tput civis ; echo -ne "${blue}==>${color_off}${bold} $(eval_gettext "Rebooting in \${sec}...\r")${color_off}" sleep 1 done From 81be7eff1f497cf20a7c5e078e83a49f1430fb7a Mon Sep 17 00:00:00 2001 From: Robin Candau Date: Sun, 19 May 2024 22:57:26 +0200 Subject: [PATCH 09/10] Ignore SC2034 which wrongly see the sec var as unused because it is escaped for gettext --- src/script/arch-update.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/src/script/arch-update.sh b/src/script/arch-update.sh index 352b716..82fd0c3 100755 --- a/src/script/arch-update.sh +++ b/src/script/arch-update.sh @@ -613,6 +613,7 @@ kernel_reboot() { } trap restore_cursor EXIT for sec in {5..1}; do + # shellcheck disable=SC2034 tput civis ; echo -ne "${blue}==>${color_off}${bold} $(eval_gettext "Rebooting in \${sec}...\r")${color_off}" sleep 1 done From 7d8c8e0e71360d91527661cfa5a440febfec0da8 Mon Sep 17 00:00:00 2001 From: Robin Candau Date: Sun, 19 May 2024 22:59:06 +0200 Subject: [PATCH 10/10] Ignore SC2034 which wrongly see the sec var as unused because it is escaped for gettext --- src/script/arch-update.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/script/arch-update.sh b/src/script/arch-update.sh index 82fd0c3..c86fd32 100755 --- a/src/script/arch-update.sh +++ b/src/script/arch-update.sh @@ -612,8 +612,8 @@ kernel_reboot() { tput cnorm } trap restore_cursor EXIT + # shellcheck disable=SC2034 for sec in {5..1}; do - # shellcheck disable=SC2034 tput civis ; echo -ne "${blue}==>${color_off}${bold} $(eval_gettext "Rebooting in \${sec}...\r")${color_off}" sleep 1 done