Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Write bash script to install cloudstorage #222

Open
KatiRG opened this issue Jun 16, 2022 · 2 comments
Open

Write bash script to install cloudstorage #222

KatiRG opened this issue Jun 16, 2022 · 2 comments
Assignees
Labels
enhancement New feature or request upgrade2.9

Comments

@KatiRG
Copy link
Collaborator

KatiRG commented Jun 16, 2022

Eventually to be incorporated into the main ckan install script ckan_install.sh.

Note: currently using an un-merged branch of cloudstorage while waiting for it to be finalized...

@KatiRG
Copy link
Collaborator Author

KatiRG commented Jun 20, 2022

I was unable to insert a string containing the escape character \ into ckan.ini using the helper fn replace_str_in_file() -- the escape character always gets omitted.

As a work-around, the string containing the escape character is stored in a text file snippet, and the snippet is then appended to ckan.ini in the appropriate place:

# Escape special characters in Azure secret with str_to_sed_str() and duplicate any % chars
AZURESECRET_FORMATTED=$(str_to_sed_str $(sed '/%/s/$/%%/' <<<$AZURESECRET))
# Store formatted Azure secret in a text file
echo "\"${AZURESECRET_FORMATTED}\"" > secret_snippet.txt
# Add secret to ckan.ini by appending text file
sed -i '/"secret":/ r secret_snippet.txt' $CKANINI
rm secret_snippet.txt

However...this appends the secret in a new line which will cause an error:

File "<unknown>", line 3
    "secret":
            ^
SyntaxError: unexpected EOF while parsing

@KatiRG
Copy link
Collaborator Author

KatiRG commented Jun 21, 2022

Issue with escape characters resolved:

function replace_str_in_ckan_ini() {
    ORIGINAL_STR=`str_to_sed_str "$1"`
    REPLACEMENT_STR=`str_to_sed_str "$2"`
    sed -i -r 's/'"$ORIGINAL_STR"'/'"$REPLACEMENT_STR"'/' $CKANINIPATH
}

export SECRET_ESCAPED=$(str_to_sed_str $(sed '/%/s/$/%%/' <<<$AZURESECRET))
replace_str_in_ckan_ini "<access key 1>" "$SECRET_ESCAPED" "$CKANINIPATH"

KatiRG added a commit that referenced this issue Jun 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request upgrade2.9
Projects
None yet
Development

No branches or pull requests

1 participant