From 205207fd15256b39c2afdc64fb677df4aa7ea101 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gardais=20J=C3=A9r=C3=A9my?= Date: Mon, 22 Jun 2020 20:02:52 +0200 Subject: [PATCH] Define extra vars in a function --- cluster/sge.enable.host.queue.sh | 34 +++++++++++++++++++------------- 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/cluster/sge.enable.host.queue.sh b/cluster/sge.enable.host.queue.sh index 37e3d17..065dd27 100755 --- a/cluster/sge.enable.host.queue.sh +++ b/cluster/sge.enable.host.queue.sh @@ -87,6 +87,24 @@ message() { # {{{ return 0 +} +# }}} +define_vars() { # {{{ + + ## If sge_hostname wasn't defined + if [ -z "${sge_hostname}" ]; then + ## Use local host for sge_hostname + sge_hostname="$(hostname -f)" + fi + + sge_queues_name="$(qhost -h "${sge_hostname:=/dev/null}" -q -xml \ + | grep "queue name" \ + | cut -d"'" -f2 )" + sge_queues_name_print="$(qhost -h "${sge_hostname:=/dev/null}" -q -xml \ + | grep "queue name" \ + | cut -d"'" -f2 \ + | tr -s '\n' ' ' )" + } # }}} is_apt_upgrade_present() { # {{{ @@ -256,14 +274,8 @@ Previously disabled by a script (or FORCE is enable), try to enable SGE queue: $ # }}} main() { # {{{ - sge_queues_name="$(qhost -h "${sge_hostname:=/dev/null}" -q -xml \ - | grep "queue name" \ - | cut -d"'" -f2 )" - sge_queues_name_print="$(qhost -h "${sge_hostname:=/dev/null}" -q -xml \ - | grep "queue name" \ - | cut -d"'" -f2 \ - | tr -s '\n' ' ' )" - + ## Define all vars according the selected options + define_vars ## If APT package upgrade is available ### Exit (wait for APT upgrade to be applied) @@ -331,9 +343,6 @@ if [ ! "${NBARGS}" -eq "0" ]; then ## Switch to the next argument shift manage_arg=$((manage_arg+1)) - else - ## Use local host for sge_hostname - sge_hostname="$(hostname -f)" fi # Parse all options (start with a "-") one by one @@ -387,9 +396,6 @@ ${RED}${manage_arg}${COLOR_DEBUG} argument(s) successfully managed." else debug_message "Arguments management − \ No arguments/options to manage." - - ## Use local host for sge_hostname - sge_hostname="$(hostname -f)" fi # }}}