parallélisme des connexions
This commit is contained in:
@@ -168,12 +168,18 @@ echo "Clé d'installation : $uniqkey"
|
|||||||
machines=($(get_ssh_aliases))
|
machines=($(get_ssh_aliases))
|
||||||
|
|
||||||
|
|
||||||
echo -e "\n--- Démarrage du traitement ---\n"
|
MAX_PARALLEL_JOBS=4 # Par exemple, 4 connexions simultanées
|
||||||
|
|
||||||
# Parcourir la liste des machines
|
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"
|
||||||
|
|
||||||
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 -e "\n"
|
||||||
echo -n " >> $machine "
|
echo -n " >> $machine "
|
||||||
|
|
||||||
@@ -181,14 +187,9 @@ for machine in "${machines[@]}"; do
|
|||||||
status=$(grep "^$machine " ~/.config/updateall-hosts | awk '{print $2}')
|
status=$(grep "^$machine " ~/.config/updateall-hosts | awk '{print $2}')
|
||||||
if [ "$status" = "1" ]; then
|
if [ "$status" = "1" ]; then
|
||||||
echo -e "${GREEN}connue${NC}"
|
echo -e "${GREEN}connue${NC}"
|
||||||
|
|
||||||
check_host "$machine"
|
if check_host "$machine"; then
|
||||||
machine_online="$?"
|
if check_keyinstall "$machine" "$uniqkey"; then
|
||||||
|
|
||||||
if [ "$machine_online" -eq 1 ]; then
|
|
||||||
check_keyinstall "$machine" "$uniqkey"
|
|
||||||
keyinstall_present="$?"
|
|
||||||
if [ "$keyinstall_present" -eq 0 ]; then
|
|
||||||
update_machine "$machine"
|
update_machine "$machine"
|
||||||
create_installkey "$machine" "$uniqkey"
|
create_installkey "$machine" "$uniqkey"
|
||||||
ok_machines+=("$machine")
|
ok_machines+=("$machine")
|
||||||
@@ -201,10 +202,7 @@ for machine in "${machines[@]}"; do
|
|||||||
ignored_machines+=("$machine")
|
ignored_machines+=("$machine")
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
check_host "$machine"
|
if check_host "$machine"; then
|
||||||
machine_online="$?"
|
|
||||||
|
|
||||||
if [ "$machine_online" -eq 1 ]; then
|
|
||||||
echo -e "${RED}vue pour la 1re fois${NC}"
|
echo -e "${RED}vue pour la 1re fois${NC}"
|
||||||
confirm_update "$machine"
|
confirm_update "$machine"
|
||||||
update_machine "$machine"
|
update_machine "$machine"
|
||||||
@@ -216,10 +214,23 @@ for machine in "${machines[@]}"; do
|
|||||||
error_machines+=("$machine")
|
error_machines+=("$machine")
|
||||||
fi
|
fi
|
||||||
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
|
done
|
||||||
|
|
||||||
|
wait # Attend que tous les jobs soient terminés
|
||||||
|
|
||||||
|
|
||||||
echo -e "\n--- Résumé des machines ---\n"
|
echo -e "\n--- Résumé des machines ---\n"
|
||||||
|
|
||||||
# Afficher les machines ignorées
|
# Afficher les machines ignorées
|
||||||
|
|||||||
Reference in New Issue
Block a user