From 2ffd4c6344a31cdbb750df2e70d68aa347b16dd1 Mon Sep 17 00:00:00 2001 From: "pu!s@r" Date: Sat, 6 Aug 2022 10:05:50 +0200 Subject: [PATCH] =?UTF-8?q?[EVO]=20G=C3=A9rer=20un=20nom=20d'h=C3=B4te=20d?= =?UTF-8?q?iff=C3=A9rent=20du=20nom=20de=20noeud?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- balance-containers/run.bash | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/balance-containers/run.bash b/balance-containers/run.bash index 10a2f41..4d4f187 100755 --- a/balance-containers/run.bash +++ b/balance-containers/run.bash @@ -9,6 +9,12 @@ scriptName=$(basename $0) # Définir l'emplacement de la liste containersList="${currentPath}/containers.csv" +# Récupérer le nom d'hôte LXD +nodename=$(/snap/bin/lxc info | grep "server_name" | awk -F':' '{print $NF}' | sed 's# ##g') + +# SI le nom d'hôte LXD n'est pas défini, le mettre à hostname +[[ -z '${nodename}' ]] && nodename=$(hostname) + # Définir l'aide show_usage() { echo "Usage: ${currentPath}/${scriptName} [options [parameters]]" @@ -80,7 +86,7 @@ case "${1}" in target="${2}" # Parcourir la liste de conteneur locaux - for line in $(lxc list --columns Ln --format csv 2> /dev/null | grep $(hostname)); do + for line in $(lxc list --columns Ln --format csv 2> /dev/null | grep ${nodename}); do ct=$(echo $line | awk -F',' '{print $2}') migrate_ct done