From d6f266a129d213b1c2990d2053163bafe99a16b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gardais=20J=C3=A9r=C3=A9my?= Date: Mon, 22 Jun 2020 20:27:10 +0200 Subject: [PATCH] Enable FORCE_MODE for remote host --- cluster/sge.enable.host.queue.sh | 38 +++++++++++++++++++++++++++----- 1 file changed, 32 insertions(+), 6 deletions(-) diff --git a/cluster/sge.enable.host.queue.sh b/cluster/sge.enable.host.queue.sh index 065dd27..256bb5b 100755 --- a/cluster/sge.enable.host.queue.sh +++ b/cluster/sge.enable.host.queue.sh @@ -21,9 +21,6 @@ readonly MACO_TMP_URGENT_FILE="/tmp/.maco.urgent.upgrade" # APT temp file to monitor readonly APT_TMP_FILE="/tmp/.apt.upgrade" -# If the scrip need to check pending upgrade before enable a queue -CHECK_UPGRADE="0" - ## Colors readonly PURPLE='\033[1;35m' readonly RED='\033[0;31m' @@ -97,6 +94,22 @@ define_vars() { # {{{ sge_hostname="$(hostname -f)" fi + ## If the host to manage is the current one + if is_current_host "${sge_hostname}" ; then + debug_message "define_vars − \ +${sge_hostname} is the current host." + ## Enable to verify if pending upgrades are present + CHECK_UPGRADE="0" + else + debug_message "define_vars − \ +${sge_hostname} is not the current host." + ## No way to monitor pending upgrades of a remote host + CHECK_UPGRADE="1" + ## Force SGE to (re)enable the queue even if it was manually disabled + FORCE_MODE="1" + fi + + ## Get all queues name sge_queues_name="$(qhost -h "${sge_hostname:=/dev/null}" -q -xml \ | grep "queue name" \ | cut -d"'" -f2 )" @@ -105,6 +118,22 @@ define_vars() { # {{{ | cut -d"'" -f2 \ | tr -s '\n' ' ' )" +} +# }}} +is_current_host() { # {{{ + + local_current_host="${1}" + local_current_fqdn=$(hostname -f) + + ## Test if the sge_host to manage is the current host + if [ "${local_current_host}" = "${local_current_fqdn}" ]; then + local_current_host_return="0" + else + local_current_host_return="1" + fi + + return "${local_current_host_return}" + } # }}} is_apt_upgrade_present() { # {{{ @@ -337,9 +366,6 @@ if [ ! "${NBARGS}" -eq "0" ]; then ## Use this argument for sge_hostname sge_hostname="${1}" - ## No way to monitor pending upgrades on a remote host - CHECK_UPGRADE="1" - ## Switch to the next argument shift manage_arg=$((manage_arg+1))