Avoid to enable queue during upgrade

This commit is contained in:
Jeremy Gardais 2020-07-06 11:30:24 +02:00
parent 588dc554ef
commit f765e15c7f
Signed by: jegardai
GPG Key ID: E759BAA22501AF32
1 changed files with 43 additions and 0 deletions

View File

@ -97,6 +97,8 @@ define_vars() { # {{{
${sge_hostname} is the current host."
## Enable to verify if pending upgrades are present
CHECK_UPGRADE="0"
## Enable to verify if upgrades are running
CHECK_PROCESS="0"
else ## In case of a remote host
debug_message "define_vars \
${sge_hostname} is not the current host."
@ -108,6 +110,8 @@ ${sge_hostname} is not the current host."
if [ -n "${FORCE_MODE}" ] && [ "${FORCE_MODE}" -eq "0" ]; then
## Disable upgrade checking (remote host, asked behaviour,…)
CHECK_UPGRADE="1"
## Disable process checking (remote host, asked behaviour,…)
CHECK_PROCESS="1"
else
## Ensure to define a value
FORCE_MODE="1"
@ -122,6 +126,9 @@ ${sge_hostname} is not the current host."
| cut -d"'" -f2 \
| tr -s '\n' ' ' )"
## List of process pattern to monitor
maco_proc_pattern="(/opt/maco/bin/maco.autoupdate.sh)"
apt_proc_pattern="(aptitude.*full-upgrade|/usr/bin/dpkg.*--configure|dpkg-deb|/bin/sh /usr/lib/needrestart/dpkg-status)"
}
# }}}
is_current_host() { # {{{
@ -183,6 +190,29 @@ No Maco upgrade require."
return "${return_maco_upgrade_present}"
}
# }}}
is_proc_running() { # {{{
local_proc_pattern="${1}"
local_count_proc_pattern="$(pgrep -f -- "${local_proc_pattern}" | wc -l)"
case "${local_count_proc_pattern}" in
0 ) ## No procs related to this pattern are running
return_proc_running="1"
;;
* ) ## At least one proc seems running
return_proc_running="0"
;;
esac
## Simple debug message to valid current variables
debug_message "is_proc_running \
procs running (with the pattern: ${RED}${local_proc_pattern}${COLOR_DEBUG}) on the current host: ${RED}${local_count_proc_pattern}${COLOR_DEBUG}."
return "${return_proc_running}"
}
# }}}
is_queue_enable() { # {{{
@ -318,6 +348,19 @@ main() { # {{{
&& exit 0
fi
## If we need to watch for processes
if [ "${CHECK_PROCESS}" -eq "0" ]; then
## If anything related to APT is currently running
### Exit
is_proc_running "${apt_proc_pattern}" \
&& exit 0
## If anything related to maco is currently running
### Exit
is_proc_running "${maco_proc_pattern}" \
&& exit 0
fi
## Simple debug message with color to valid current variables
debug_message "main Try to manage \
SGE queue(s): ${RED}${sge_queues_name_print:=/dev/null}${COLOR_DEBUG}\