Skip to content

Commit

Permalink
Fix the script when sourced from zsh
Browse files Browse the repository at this point in the history
When the novarc file is sourced from the Zsh, it fails due to a few
Bash specifics:
- $BASH_SOURCE - does not exist in Zsh
- readarray - does not exist in Zsh

Resolves issue #176

Signed-off-by: Marcin Wilk <[email protected]>
  • Loading branch information
Marcin Wilk committed Jul 25, 2024
1 parent 4c7cbee commit 08c2078
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions openstack/novarc
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ juju_status_json_cache=`mktemp`
cleanup () { rm -rf $juju_status_json_cache; }
trap cleanup EXIT KILL

scriptdir=$(readlink --canonicalize $(dirname ${BASH_SOURCE}))
scriptdir=$(readlink --canonicalize $(dirname ${BASH_SOURCE[0]-$0}))

# cache juju status
juju status --format=json > $juju_status_json_cache
Expand All @@ -25,7 +25,7 @@ if [ -n "`juju config keystone ssl_cert`" ]; then
elif ((`jq -r '.applications[]| select(."charm-name"=="vault")' $juju_status_json_cache| wc -l`)); then
# Vault-based ssl
if `jq -r '.applications.vault.relations.certificates[]' $juju_status_json_cache| grep -q keystone`; then
readarray -t VAULT_STATUS < <(juju status vault --format=json | jq -r '.applications.vault.units."vault/0"."workload-status" | .current,.message')
VAULT_STATUS=( $(juju status vault --format=json | jq -r '.applications.vault.units."vault/0"."workload-status" | .current,.message') )
if [[ "${VAULT_STATUS[0]}" == "blocked" && "${VAULT_STATUS[1]}" == "Vault needs to be initialized" ]]; then
read -p "$(cat <<-END
This deployment is using vault-based ssl certificates
Expand Down Expand Up @@ -57,7 +57,7 @@ unset _OS_PARAMS
# If user was specified use it
if [[ $# -gt 1 && $1 = --service ]]; then
RELATION_ID=$(juju run --unit $2/leader -- relation-ids identity-service | cut -d : -f 2)
readarray -t CREDENTIALS < <(juju run --unit $2/leader -- relation-get --relation ${RELATION_ID} --format json - keystone/0)
CREDENTIALS=( $(juju run --unit $2/leader -- relation-get --relation ${RELATION_ID} --format json - keystone/0) )

export OS_USERNAME=$(echo ${CREDENTIALS} | jq --raw-output .service_username)
export OS_USER_DOMAIN_NAME=$(echo ${CREDENTIALS} | jq --raw-output .service_domain)
Expand All @@ -73,7 +73,7 @@ else
# if the admin password is not set in the configuration, then it's read
# from the leader databag.
_CONFIG_PASSWD="$(juju config keystone admin-password| awk '{print tolower($0)}')"
if [ "${_CONFIG_PASSWD}" == "none" ] || [ "${_CONFIG_PASSWD}" == "" ]; then
if [[ "${_CONFIG_PASSWD}" == "none" ]] || [[ "${_CONFIG_PASSWD}" == "" ]]; then
export OS_PASSWORD=$(juju run -u keystone/leader leader-get admin_passwd)
else
export OS_PASSWORD="$(juju config keystone admin-password)"
Expand Down

0 comments on commit 08c2078

Please sign in to comment.