Refactor start_ckan_development.sh.override to update licenses group URL in CKAN configuration

This commit is contained in:
mjanez 2024-09-18 11:20:37 +02:00
parent e082565a85
commit cb278d10b3
No known key found for this signature in database
GPG Key ID: 7A62FDE17C5A4929
1 changed files with 20 additions and 6 deletions

View File

@ -54,7 +54,7 @@ ckan config-tool $CKAN_INI -s DEFAULT "debug = true"
# Set up the Secret key used by Beaker and Flask
# This can be overriden using a CKAN___BEAKER__SESSION__SECRET env var
if grep -E "beaker.session.secret ?= ?$" ckan.ini
if grep -qE "beaker.session.secret ?= ?$" ckan.ini
then
echo "Setting beaker.session.secret in ini file"
ckan config-tool $CKAN_INI "beaker.session.secret=$(python3 -c 'import secrets; print(secrets.token_urlsafe())')"
@ -62,11 +62,6 @@ then
JWT_SECRET=$(python3 -c 'import secrets; print("string:" + secrets.token_urlsafe())')
ckan config-tool $CKAN_INI "api_token.jwt.encode.secret=${JWT_SECRET}"
ckan config-tool $CKAN_INI "api_token.jwt.decode.secret=${JWT_SECRET}"
echo "Update licenses in CKAN"
if [ -n "$CKAN___LICENSES_GROUP_URL" ]; then
ckan config-tool $CKAN_INI "licenses_group_url=${CKAN___LICENSES_GROUP_URL}"
fi
fi
# Update the plugins setting in the ini file with the values defined in the env var
@ -82,6 +77,25 @@ ckan config-tool $SRC_DIR/ckan/test-core.ini \
"solr_url = $TEST_CKAN_SOLR_URL" \
"ckan.redis.url = $TEST_CKAN_REDIS_URL"
# Update local (file://) licenses for Development mode
if [ -n "$LICENSES_GROUP_URL" ]; then
expanded_app_dir=$(eval echo "$APP_DIR")
expanded_src_dir=$(eval echo "$SRC_DIR")
expanded_src_extensions_dir=$(eval echo "$SRC_EXTENSIONS_DIR")
if [[ "$LICENSES_GROUP_URL" == *"$expanded_src_dir"* ]]; then
LICENSES_GROUP_URL=${LICENSES_GROUP_URL//$expanded_src_dir/$expanded_src_extensions_dir}
echo "Updating licenses group URL to: $LICENSES_GROUP_URL"
ckan config-tool $CKAN_INI "licenses_group_url=${LICENSES_GROUP_URL}"
elif [[ "$LICENSES_GROUP_URL" == "file://$expanded_app_dir/src/"* ]]; then
LICENSES_GROUP_URL=${LICENSES_GROUP_URL//file:\/\/$expanded_app_dir\/src\//file:\/\/$expanded_app_dir\/src_extensions\/}
echo "Updating licenses group URL to: $LICENSES_GROUP_URL"
ckan config-tool $CKAN_INI "licenses_group_url=${LICENSES_GROUP_URL}"
else
echo "LICENSES_GROUP_URL does not contain $expanded_src_dir or file://$expanded_app_dir/src/. No changes made."
fi
fi
# Run the prerun script to init CKAN and create the default admin user
python3 prerun.py