From df39d103e6b4091c91a9db6951cb09e148e3f77e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gardais=20J=C3=A9r=C3=A9my?= Date: Mon, 6 Jul 2020 15:07:23 +0200 Subject: [PATCH] Exit if nologin file exists --- cluster/sge.enable.host.queue.sh | 37 ++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/cluster/sge.enable.host.queue.sh b/cluster/sge.enable.host.queue.sh index fa4bc8e..2913f72 100755 --- a/cluster/sge.enable.host.queue.sh +++ b/cluster/sge.enable.host.queue.sh @@ -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}\