From cabb33cf6e8e2067c93c1f79a0416af2466440c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9drix?= Date: Thu, 29 May 2025 07:15:37 +0200 Subject: [PATCH] =?UTF-8?q?annulation=20des=20connexion=20simultan=C3=A9es?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- local/bin/updateall.sh | 43 ++++++++++++++++-------------------------- 1 file changed, 16 insertions(+), 27 deletions(-) diff --git a/local/bin/updateall.sh b/local/bin/updateall.sh index 4a9c180..343ae7d 100755 --- a/local/bin/updateall.sh +++ b/local/bin/updateall.sh @@ -168,18 +168,12 @@ echo "Clé d'installation : $uniqkey" machines=($(get_ssh_aliases)) -MAX_PARALLEL_JOBS=4 # Par exemple, 4 connexions simultanées +echo -e "\n--- Démarrage du traitement ---\n" -limit_jobs() { - while [ "$(jobs -rp | wc -l)" -ge "$MAX_PARALLEL_JOBS" ]; do - sleep 1 - done -} - -# Fonction englobante pour le traitement d'une machine -process_machine() { - local machine="$1" +# Parcourir la liste des machines +for machine in "${machines[@]}"; do + # Vérification si le nom de machine est présent dans le fichier .config/updateall-hosts echo -e "\n" echo -n " >> $machine " @@ -187,9 +181,14 @@ process_machine() { status=$(grep "^$machine " ~/.config/updateall-hosts | awk '{print $2}') if [ "$status" = "1" ]; then echo -e "${GREEN}connue${NC}" - - if check_host "$machine"; then - if check_keyinstall "$machine" "$uniqkey"; then + + check_host "$machine" + machine_online="$?" + + if [ "$machine_online" -eq 1 ]; then + check_keyinstall "$machine" "$uniqkey" + keyinstall_present="$?" + if [ "$keyinstall_present" -eq 0 ]; then update_machine "$machine" create_installkey "$machine" "$uniqkey" ok_machines+=("$machine") @@ -202,7 +201,10 @@ process_machine() { ignored_machines+=("$machine") fi else - if check_host "$machine"; then + check_host "$machine" + machine_online="$?" + + if [ "$machine_online" -eq 1 ]; then echo -e "${RED}vue pour la 1re fois${NC}" confirm_update "$machine" update_machine "$machine" @@ -214,23 +216,10 @@ process_machine() { error_machines+=("$machine") fi fi -} - - -echo -e "\n--- Démarrage du traitement ---\n" - -# Parcourir la liste des machines - -for machine in "${machines[@]}"; do - limit_jobs - process_machine "$machine" & done -wait # Attend que tous les jobs soient terminés - - echo -e "\n--- Résumé des machines ---\n" # Afficher les machines ignorées