From 2257ab7742e063c9e0943ebc12af8e8d33e1ffb4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gardais=20J=C3=A9r=C3=A9my?= Date: Fri, 19 Jun 2020 10:43:10 +0200 Subject: [PATCH] Ensure to don't have any SGE queue enable --- cluster/apt.apply.update.sh | 35 +++++++++++++++++++++++++++++------ cluster/maco.apply.update.sh | 35 +++++++++++++++++++++++++++++------ 2 files changed, 58 insertions(+), 12 deletions(-) diff --git a/cluster/apt.apply.update.sh b/cluster/apt.apply.update.sh index 1c0d927..d8a5cf9 100755 --- a/cluster/apt.apply.update.sh +++ b/cluster/apt.apply.update.sh @@ -1,7 +1,7 @@ #!/bin/sh # This script will try to apply APT upgrades if all conditions are satisfied -# 1. SGE queue is disable +# 1. All SGE queues are disable # 2. No SGE jobs are running # 3. No process related to Maco are running @@ -51,8 +51,9 @@ usage() { # {{{ usage: $PROGNAME Apply any APT package upgrade if the host is free: - * SGE queue is disable + * All SGE queues are disable * No SGE jobs are running + * No other upgrades are running EXAMPLES: - Apply upgrade on the current host @@ -128,7 +129,7 @@ No Maco upgrade require." } # }}} -is_maco_upgrade_absent() { # {{{ +is_maco_upgrade_absent() { # {{{ return_maco_upgrade_absent="0" @@ -184,6 +185,28 @@ state is: ${RED}${local_sge_queue_state:=/dev/null}${COLOR_DEBUG}." return "${return_queue_enable}" +} +# }}} +is_any_queue_enable() { # {{{ + + local_any_queue_enable_hostname="${1}" + local_any_queue_enable_name="${2}" + + ## By default, all queues are disable + return_any_queue_enable="1" + + ## Test all queues one by one + for loop_enable_queue in ${local_any_queue_enable_name}; do + + ### If a queue is enable + #### Change the return value + is_queue_enable "${local_any_queue_enable_hostname}" "${loop_enable_queue}" \ + && return_any_queue_enable="0" + + done + + return "${return_any_queue_enable}" + } # }}} is_job_running() { # {{{ @@ -263,7 +286,7 @@ main() { # {{{ manage_args "${ARGS}" sge_hostname="$(hostname -f)" - sge_queue_name="$(qhost -h "${sge_hostname:=/dev/null}" -q -xml \ + sge_queues_name="$(qhost -h "${sge_hostname:=/dev/null}" -q -xml \ | grep "queue name" \ | cut -d"'" -f2 )" @@ -274,9 +297,9 @@ main() { # {{{ is_apt_upgrade_absent \ && exit 0 - ## If SGE queue is enable + ## If any SGE queue is enable ### Exit - is_queue_enable "${sge_hostname}" "${sge_queue_name}" \ + is_any_queue_enable "${sge_hostname}" "${sge_queues_name}" \ && exit 0 ## If any SGE job runs diff --git a/cluster/maco.apply.update.sh b/cluster/maco.apply.update.sh index e57d550..1badd57 100755 --- a/cluster/maco.apply.update.sh +++ b/cluster/maco.apply.update.sh @@ -1,7 +1,7 @@ #!/bin/sh # This script will try to apply Maco upgrade if all conditions are satisfied -# 1. SGE queue is disable +# 1. All SGE queues are disable # 2. No SGE jobs are running # 3. No process related to Maco are already running @@ -51,8 +51,9 @@ usage() { # {{{ usage: $PROGNAME Apply any Maco upgrade if the host is free: - * SGE queue is disable + * All SGE queues are disable * No SGE jobs are running + * No other upgrades are running EXAMPLES: - Apply Maco upgrade on the current host @@ -87,7 +88,7 @@ NO APT upgrade available for this system." } # }}} -is_maco_upgrade_absent() { # {{{ +is_maco_upgrade_absent() { # {{{ return_maco_upgrade_absent="0" @@ -143,6 +144,28 @@ state is: ${RED}${local_sge_queue_state:=/dev/null}${COLOR_DEBUG}." return "${return_queue_enable}" +} +# }}} +is_any_queue_enable() { # {{{ + + local_any_queue_enable_hostname="${1}" + local_any_queue_enable_name="${2}" + + ## By default, all queues are disable + return_any_queue_enable="1" + + ## Test all queues one by one + for loop_enable_queue in ${local_any_queue_enable_name}; do + + ### If a queue is enable + #### Change the return value + is_queue_enable "${local_any_queue_enable_hostname}" "${loop_enable_queue}" \ + && return_any_queue_enable="0" + + done + + return "${return_any_queue_enable}" + } # }}} is_job_running() { # {{{ @@ -203,7 +226,7 @@ main() { # {{{ manage_args "${ARGS}" sge_hostname="$(hostname -f)" - sge_queue_name="$(qhost -h "${sge_hostname:=/dev/null}" -q -xml \ + sge_queues_name="$(qhost -h "${sge_hostname:=/dev/null}" -q -xml \ | grep "queue name" \ | cut -d"'" -f2 )" @@ -220,9 +243,9 @@ main() { # {{{ is_maco_upgrade_absent \ && exit 0 - ## If SGE queue is enable + ## If any SGE queue is enable ### Exit - is_queue_enable "${sge_hostname}" "${sge_queue_name}" \ + is_any_queue_enable "${sge_hostname}" "${sge_queues_name}" \ && exit 0 ## If any SGE job runs