Ensure to don't have any SGE queue enable

This commit is contained in:
Jeremy Gardais 2020-06-19 10:43:10 +02:00
parent 0505db5082
commit 2257ab7742
Signed by: jegardai
GPG Key ID: E759BAA22501AF32
2 changed files with 58 additions and 12 deletions

View File

@ -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

View File

@ -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