2023-03-22 10:52:41 +01:00
|
|
|
#!/bin/bash
|
|
|
|
|
2023-04-19 15:37:42 +02:00
|
|
|
# Set the name of the token to revoke
|
|
|
|
TOKEN_NAME="xloader"
|
|
|
|
|
|
|
|
# Get the list of tokens and extract the IDs for tokens with the specified name
|
|
|
|
TOKEN_IDS=$(ckan -c $CKAN_INI user token list ckan_admin | grep "$TOKEN_NAME" | awk -F'[][]' '{print $2}' | tr -d '[]')
|
|
|
|
|
|
|
|
# Revoke each previous token of xloader
|
|
|
|
for TOKEN_ID in $TOKEN_IDS
|
|
|
|
do
|
2024-03-05 07:40:19 +01:00
|
|
|
if [ -z "$TOKEN_ID" ]; then
|
|
|
|
echo "[docker-entrypoint.01_setup_xloader] No API Token to revoke"
|
|
|
|
continue
|
|
|
|
fi
|
|
|
|
ckan -c $CKAN_INI user token revoke -- $TOKEN_ID
|
2023-04-19 15:37:42 +02:00
|
|
|
if [ $? -eq 0 ]; then
|
2024-02-21 09:16:47 +01:00
|
|
|
echo "[docker-entrypoint.01_setup_xloader] API Token $TOKEN_ID has been revoked"
|
2023-04-19 15:37:42 +02:00
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
2023-03-22 10:52:41 +01:00
|
|
|
# Add ckanext.xloader.api_token to the CKAN config file
|
2024-02-21 09:16:47 +01:00
|
|
|
echo "[docker-entrypoint.01_setup_xloader] Loading ckanext-xloader settings in the CKAN config file"
|
2023-03-22 10:52:41 +01:00
|
|
|
ckan config-tool $CKAN_INI \
|
2023-04-19 15:37:42 +02:00
|
|
|
"ckanext.xloader.api_token=xxx" \
|
|
|
|
"ckanext.xloader.jobs_db.uri=$CKANEXT__XLOADER__JOBS__DB_URI"
|
2023-03-22 10:52:41 +01:00
|
|
|
|
|
|
|
# Create ckanext-xloader API_TOKEN
|
2024-02-21 09:16:47 +01:00
|
|
|
echo "[docker-entrypoint.01_setup_xloader] Set up ckanext.xloader.api_token in the CKAN config file"
|
2024-04-15 12:33:28 +02:00
|
|
|
ckan config-tool $CKAN_INI "ckanext.xloader.api_token=$(ckan -c $CKAN_INI user token add ckan_admin xloader | tail -n 1 | tr -d '\t')"
|