From 8932ee6efec55fbf7c9b6aea35cda54d334e8590 Mon Sep 17 00:00:00 2001 From: Ludovic <54670129+lbr38@users.noreply.github.com> Date: Mon, 19 Jun 2023 11:25:59 +0200 Subject: [PATCH] 2.2.8 --- .github/workflows/release.yml | 2 +- functions/02_check-packages-before-update | 23 ++++++++++++++--------- functions/09_service-restart | 6 +++--- version | 2 +- 4 files changed, 19 insertions(+), 14 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 6c75a0e..e72a306 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -162,7 +162,7 @@ jobs: with: tag_name: ${{ env.VERSION }} release_name: ${{ env.VERSION }} - body: "" + body: "Fixed services restart after update" draft: false prerelease: false diff --git a/functions/02_check-packages-before-update b/functions/02_check-packages-before-update index c8f0976..6742362 100644 --- a/functions/02_check-packages-before-update +++ b/functions/02_check-packages-before-update @@ -49,7 +49,7 @@ function checkPackagesBeforeUpdate # Then unhold them all if [ ! -z "$HOLDED_PACKAGES" ];then - OLD_IFS="$IFS" + OLD_IFS=$IFS IFS=$'\n' for HOLDED_PACKAGE in $(echo "$HOLDED_PACKAGES");do @@ -99,7 +99,7 @@ function checkPackagesBeforeUpdate if egrep -q "^${PACKAGE} " $CHECK_UPDATE_TMP;then # Save the actual IFS (comma) because it will be needed again by the previous FOR loop - old_IFS=$IFS + OLD_IFS=$IFS IFS=$'\n' # For every occurence of the package found in $CHECK_UPDATE_TMP (there could be more than one), @@ -162,7 +162,7 @@ function checkPackagesBeforeUpdate done # Set back the prviously saved IFS (comma) for the previous FOR loop to work - IFS=$old_IFS + IFS=$OLD_IFS # Cas no update is available for this package else @@ -190,7 +190,7 @@ function checkPackagesBeforeUpdate if egrep -q "^${PACKAGE} " $CHECK_UPDATE_TMP;then # Save the actual IFS (comma) because it will be needed again by the previous FOR loop - old_IFS=$IFS + OLD_IFS=$IFS IFS=$'\n' # For every occurence of the package found in $CHECK_UPDATE_TMP (there could be more than one), @@ -200,7 +200,7 @@ function checkPackagesBeforeUpdate done # Set back the prviously saved IFS (comma) for the previous FOR loop to work - IFS=$old_IFS + IFS=$OLD_IFS fi done fi @@ -215,19 +215,24 @@ function checkPackagesBeforeUpdate # Process services that will need a restart after packages update if [ ! -z "$CONF_SOFT_NEED_RESTART" ];then + OLD_IFS=$IFS IFS=',' - # Run through CONF_SOFT_NEED_RESTART - for SERVICE in "${CONF_SOFT_NEED_RESTART[@]}"; do - + # Inject services list into SERVICES_TO_RESTART + read -ra SERVICES_TO_RESTART <<< "$CONF_SOFT_NEED_RESTART" + + # Run through SERVICES_TO_RESTART + for SERVICE in "${SERVICES_TO_RESTART[@]}"; do # Check if specified service really exists, if yes then add it to the final services to restart list - if ! systemctl list-unit-files "${SERVICE}.service" | grep -q "0 unit files";then + if systemctl list-units --all -t service --full | grep "${SERVICE}.service";then SERVICE_TO_BE_RESTARTED+=" $SERVICE" fi done SERVICE_TO_BE_RESTARTED="${SERVICE_TO_BE_RESTARTED} " SERVICE_TO_BE_RESTARTED="${SERVICE_TO_BE_RESTARTED/ /}" + + IFS=$OLD_IFS fi echo "" diff --git a/functions/09_service-restart b/functions/09_service-restart index 9146de8..ab2bfe1 100644 --- a/functions/09_service-restart +++ b/functions/09_service-restart @@ -5,10 +5,10 @@ function restartService { # Si $SERVICE_TO_BE_RESTARTED contient des services nécessitant un redémarrage, on traite if [ ! -z "$SERVICE_TO_BE_RESTARTED" ];then - OLD_IFS="$IFS" - IFS=',' + OLD_IFS=$IFS + IFS=' ' - for SERVICE in $SERVICE_TO_BE_RESTARTED; do + for SERVICE in $(echo "$SERVICE_TO_BE_RESTARTED"); do SERVICE=$(echo "$SERVICE" | sed 's/ //g') echo -ne "→ Restarting ${YELLOW}${SERVICE}${RESET} service: " systemctl restart "$SERVICE" --quiet diff --git a/version b/version index b539ade..eb430cb 100644 --- a/version +++ b/version @@ -1 +1 @@ -2.2.7 \ No newline at end of file +2.2.8 \ No newline at end of file