Exit if all SGE queues were manually disabled

This commit is contained in:
Jeremy Gardais 2020-07-06 16:16:25 +02:00
parent 47d7060743
commit fdbc34e5cc
Signed by: jegardai
GPG Key ID: E759BAA22501AF32
1 changed files with 34 additions and 4 deletions

View File

@ -136,6 +136,8 @@ ${sge_hostname} is not the current host."
## List of files to monitor ## List of files to monitor
file_nologin_path="/etc/nologin" file_nologin_path="/etc/nologin"
cluster_dir="/opt/ipr/cluster"
sge_queue_flag_pattern="${cluster_dir}/.sge.*.disable"
} }
# }}} # }}}
is_current_host() { # {{{ is_current_host() { # {{{
@ -224,25 +226,48 @@ procs running (with the pattern: ${RED}${local_proc_pattern}${COLOR_DEBUG}) on t
# }}} # }}}
is_file_present() { # {{{ is_file_present() { # {{{
local_file_path="${1}" local_file_present="${1}"
## File doesn't exist by default ## File doesn't exist by default
return_is_file_present="1" return_is_file_present="1"
### Check if the file exists ### Check if the file exists
# shellcheck disable=SC2086 # shellcheck disable=SC2086
if find ${local_file_path} > /dev/null 2>&1; then if find ${local_file_present} > /dev/null 2>&1; then
return_is_file_present="0" return_is_file_present="0"
debug_message "is_file_present \ debug_message "is_file_present \
The file ${RED}${local_file_path}${COLOR_DEBUG} exists." The file ${RED}${local_file_present}${COLOR_DEBUG} exists."
else else
return_is_file_present="1" return_is_file_present="1"
debug_message "is_file_present \ debug_message "is_file_present \
The file ${RED}${local_file_path}${COLOR_DEBUG} doesn't exist." The file ${RED}${local_file_present}${COLOR_DEBUG} doesn't exist."
fi fi
return "${return_is_file_present}" return "${return_is_file_present}"
}
# }}}
is_file_absent() { # {{{
local_file_absent="${1}"
## File exists by default
return_is_file_absent="1"
### Check if the file exists
# shellcheck disable=SC2086
if find ${local_file_absent} > /dev/null 2>&1; then
return_is_file_absent="1"
debug_message "is_file_absent \
The file ${RED}${local_file_absent}${COLOR_DEBUG} exists."
else
return_is_file_absent="0"
debug_message "is_file_absent \
The file ${RED}${local_file_absent}${COLOR_DEBUG} doesn't exist."
fi
return "${return_is_file_absent}"
} }
# }}} # }}}
is_queue_enable() { # {{{ is_queue_enable() { # {{{
@ -397,6 +422,11 @@ main() { # {{{
### Exit ### Exit
is_file_present "${file_nologin_path}" \ is_file_present "${file_nologin_path}" \
&& exit 0 && exit 0
## If all SGE queue(s) were manually disabled
### Exit
is_file_absent "${sge_queue_flag_pattern}" \
|| exit 0
fi fi
## Simple debug message with color to valid current variables ## Simple debug message with color to valid current variables