Rename days to attempts

If we run X times the script with available upgrade, the SGE queue will
be disabled.
This commit is contained in:
Jeremy Gardais 2020-11-30 14:45:23 +01:00
parent a18bd2cb96
commit fbe10bda8f
Signed by: jegardai
GPG Key ID: E759BAA22501AF32
1 changed files with 15 additions and 15 deletions

View File

@ -155,29 +155,29 @@ Used slots did not reach ${RED}${local_percentage}%${COLOR_DEBUG} of total slots
}
# }}}
is_pending_upgrade_more_than_days() { # {{{
is_pending_upgrade_more_than_attempts() { # {{{
local_days="${1}"
local_attempts="${1}"
local_line_size="24"
local_max_file_size="$(( ${local_days} * ${local_line_size} ))"
local_max_file_size="$(( ${local_attempts} * ${local_line_size} ))"
debug_message "is_pending_upgrade_more_than_days (${local_days}) \
Check if ${APT_TMP_FILE} has a size bigger than ${RED}${local_max_file_size:=/dev/null}${COLOR_DEBUG} bytes (${local_days} days * ${local_line_size} bytes size for one line)."
debug_message "is_pending_upgrade_more_than_attempts (${local_attempts}) \
Check if ${APT_TMP_FILE} has a size bigger than ${RED}${local_max_file_size:=/dev/null}${COLOR_DEBUG} bytes (${local_attempts} attempts * ${local_line_size} bytes size for one line)."
if [ $(find "${APT_TMP_FILE}" -type f -size +"${local_max_file_size}"c 2>/dev/null) ]; then
## Temp file seems to exist for more than the maximum days
return_pending_upgrade_more_than_days="0"
debug_message "is_pending_upgrade_more_than_days \
There is pending upgrade(s) for more than ${RED}${local_days:=/dev/null}${COLOR_DEBUG} days."
## Temp file seems to exist for more than the maximum attempts
return_pending_upgrade_more_than_attempts="0"
debug_message "is_pending_upgrade_more_than_attempts \
There is pending upgrade(s) for more than ${RED}${local_attempts:=/dev/null}${COLOR_DEBUG} attempts."
else
return_pending_upgrade_more_than_days="1"
debug_message "is_pending_upgrade_more_than_days \
NO pending upgrades for more than ${RED}${local_days:=/dev/null}${COLOR_DEBUG} days."
return_pending_upgrade_more_than_attempts="1"
debug_message "is_pending_upgrade_more_than_attempts \
NO pending upgrades for more than ${RED}${local_attempts:=/dev/null}${COLOR_DEBUG} attempts."
fi
return "${return_pending_upgrade_more_than_days}"
return "${return_pending_upgrade_more_than_attempts}"
}
# }}}
@ -248,11 +248,11 @@ main() { # {{{
&& exit 0
## }}}
## If pending upgrade since 3~4 days {{{
## If pending upgrade since 3 attempts {{{
## APT package upgrade is available
### Create a temp file
### Disable SGE queue
is_pending_upgrade_more_than_days "3" \
is_pending_upgrade_more_than_attempts "3" \
&& touch "${APT_TMP_FILE}" && echo "APT upgrade is available." >> "${APT_TMP_FILE}" \
&& sh "${sge_disable_host_queue_script}" \
&& exit 0