Define extra vars in a function

This commit is contained in:
Jeremy Gardais 2020-06-22 20:02:52 +02:00
parent 60c307b933
commit 205207fd15
Signed by: jegardai
GPG Key ID: E759BAA22501AF32
1 changed files with 20 additions and 14 deletions

View File

@ -87,6 +87,24 @@ message() { # {{{
return 0 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() { # {{{ is_apt_upgrade_present() { # {{{
@ -256,14 +274,8 @@ Previously disabled by a script (or FORCE is enable), try to enable SGE queue: $
# }}} # }}}
main() { # {{{ main() { # {{{
sge_queues_name="$(qhost -h "${sge_hostname:=/dev/null}" -q -xml \ ## Define all vars according the selected options
| grep "queue name" \ define_vars
| cut -d"'" -f2 )"
sge_queues_name_print="$(qhost -h "${sge_hostname:=/dev/null}" -q -xml \
| grep "queue name" \
| cut -d"'" -f2 \
| tr -s '\n' ' ' )"
## If APT package upgrade is available ## If APT package upgrade is available
### Exit (wait for APT upgrade to be applied) ### Exit (wait for APT upgrade to be applied)
@ -331,9 +343,6 @@ if [ ! "${NBARGS}" -eq "0" ]; then
## Switch to the next argument ## Switch to the next argument
shift shift
manage_arg=$((manage_arg+1)) manage_arg=$((manage_arg+1))
else
## Use local host for sge_hostname
sge_hostname="$(hostname -f)"
fi fi
# Parse all options (start with a "-") one by one # Parse all options (start with a "-") one by one
@ -387,9 +396,6 @@ ${RED}${manage_arg}${COLOR_DEBUG} argument(s) successfully managed."
else else
debug_message "Arguments management \ debug_message "Arguments management \
No arguments/options to manage." No arguments/options to manage."
## Use local host for sge_hostname
sge_hostname="$(hostname -f)"
fi fi
# }}} # }}}