Exit if nologin file exists
This commit is contained in:
parent
f765e15c7f
commit
df39d103e6
|
@ -99,6 +99,8 @@ ${sge_hostname} is the current host."
|
|||
CHECK_UPGRADE="0"
|
||||
## Enable to verify if upgrades are running
|
||||
CHECK_PROCESS="0"
|
||||
## Enable to watch if some files are present
|
||||
CHECK_FILE="0"
|
||||
else ## In case of a remote host
|
||||
debug_message "define_vars − \
|
||||
${sge_hostname} is not the current host."
|
||||
|
@ -112,6 +114,8 @@ ${sge_hostname} is not the current host."
|
|||
CHECK_UPGRADE="1"
|
||||
## Disable process checking (remote host, asked behaviour,…)
|
||||
CHECK_PROCESS="1"
|
||||
## Disable files monitoring
|
||||
CHECK_FILE="1"
|
||||
else
|
||||
## Ensure to define a value
|
||||
FORCE_MODE="1"
|
||||
|
@ -129,6 +133,9 @@ ${sge_hostname} is not the current host."
|
|||
## 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)"
|
||||
|
||||
## List of files to monitor
|
||||
file_nologin_path="/etc/nologin"
|
||||
}
|
||||
# }}}
|
||||
is_current_host() { # {{{
|
||||
|
@ -213,6 +220,28 @@ procs running (with the pattern: ${RED}${local_proc_pattern}${COLOR_DEBUG}) on t
|
|||
|
||||
return "${return_proc_running}"
|
||||
|
||||
}
|
||||
# }}}
|
||||
is_file_present() { # {{{
|
||||
|
||||
local_file_path="${1}"
|
||||
|
||||
## File doesn't exist by default
|
||||
return_is_file_present="1"
|
||||
|
||||
### Check if the file exists
|
||||
if [ -f "${local_file_path}" ]; then
|
||||
return_is_file_present="0"
|
||||
debug_message "is_file_present − \
|
||||
The file ${RED}${local_file_path}${COLOR_DEBUG} exists."
|
||||
else
|
||||
return_is_file_present="1"
|
||||
debug_message "is_file_present − \
|
||||
The file ${RED}${local_file_path}${COLOR_DEBUG} doesn't exist."
|
||||
fi
|
||||
|
||||
return "${return_is_file_present}"
|
||||
|
||||
}
|
||||
# }}}
|
||||
is_queue_enable() { # {{{
|
||||
|
@ -361,6 +390,14 @@ main() { # {{{
|
|||
&& exit 0
|
||||
fi
|
||||
|
||||
## If we need to watch files
|
||||
if [ "${CHECK_FILE}" -eq "0" ]; then
|
||||
## If nologin file exist
|
||||
### Exit
|
||||
is_file_present "${file_nologin_path}" \
|
||||
&& 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}\
|
||||
|
|
Loading…
Reference in New Issue