Test if given hostname is the current host
This commit is contained in:
parent
3d6d8de497
commit
e96c9ff548
|
@ -61,6 +61,17 @@ define_vars() { # {{{
|
|||
sge_hostname="$(hostname -f)"
|
||||
fi
|
||||
|
||||
## If the host to manage is the current one
|
||||
if is_current_host "${sge_hostname}" ; then
|
||||
debug_message "define_vars − \
|
||||
${sge_hostname} is the current host."
|
||||
LOCAL_HOST="0"
|
||||
else ## In case of a remote host
|
||||
debug_message "define_vars − \
|
||||
${sge_hostname} is not the current host."
|
||||
LOCAL_HOST="1"
|
||||
fi
|
||||
|
||||
## Get all queues name
|
||||
sge_queues_name="$(qhost -h "${sge_hostname:=/dev/null}" -q -xml \
|
||||
| grep "queue name" \
|
||||
|
@ -70,6 +81,22 @@ define_vars() { # {{{
|
|||
| cut -d"'" -f2 \
|
||||
| tr -s '\n' ' ' )"
|
||||
|
||||
}
|
||||
# }}}
|
||||
is_current_host() { # {{{
|
||||
|
||||
local_current_host="${1}"
|
||||
local_current_fqdn=$(hostname -f)
|
||||
|
||||
## Test if the sge_host to manage is the current host
|
||||
if [ "${local_current_host}" = "${local_current_fqdn}" ]; then
|
||||
local_current_host_return="0"
|
||||
else
|
||||
local_current_host_return="1"
|
||||
fi
|
||||
|
||||
return "${local_current_host_return}"
|
||||
|
||||
}
|
||||
# }}}
|
||||
is_queue_enable() { # {{{
|
||||
|
@ -172,8 +199,14 @@ disable_sge_queue() { # {{{
|
|||
Try to disable SGE queue: ${RED}${local_sge_queue_name:=/dev/null}@${local_sge_hostname:=/dev/null}${COLOR_DEBUG}."
|
||||
|
||||
## SGE command to disable the queue
|
||||
## and get returned value
|
||||
## and create a file for local queue
|
||||
qmod --disable "${local_sge_queue_name}@${local_sge_hostname}" > /dev/null \
|
||||
&& return_disable_queue="${?}"
|
||||
&& return_disable_queue="${?}" \
|
||||
&& {
|
||||
[ "${LOCAL_HOST}" -eq "0" ] && printf '%s' "by ${PROGNAME} script" > "${sge_queue_deactivator}"
|
||||
}
|
||||
|
||||
|
||||
return "${return_disable_queue}"
|
||||
|
||||
|
|
Loading…
Reference in New Issue