Enable FORCE_MODE for remote host

This commit is contained in:
Jeremy Gardais 2020-06-22 20:27:10 +02:00
parent 205207fd15
commit d6f266a129
Signed by: jegardai
GPG Key ID: E759BAA22501AF32
1 changed files with 32 additions and 6 deletions

View File

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