Merge pull request #35 from mjanez/fix/xloader-ennvars

Fix xloader token creation
This commit is contained in:
mjanez 2023-04-19 15:39:17 +02:00 committed by GitHub
commit d79a72ee8b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 4 deletions

View File

@ -190,7 +190,9 @@ Use this if you are a maintainer and will not be making code changes to CKAN or
> Please note that when accessing CKAN directly (via a browser) ie: not going through Apache/NGINX you will need to make sure you have "ckan" set up to be an alias to localhost in the local hosts file. Either that or you will need to change the `.env` entry for `CKAN_SITE_URL` > Please note that when accessing CKAN directly (via a browser) ie: not going through Apache/NGINX you will need to make sure you have "ckan" set up to be an alias to localhost in the local hosts file. Either that or you will need to change the `.env` entry for `CKAN_SITE_URL`
>**Warning**:<br> >**Warning**:<br>
> Using the default values on the `.env` file will get you a working CKAN instance. There is a sysadmin user created by default with the values defined in `CKAN_SYSADMIN_NAME` and `CKAN_SYSADMIN_PASSWORD`(`ckan_admin` and `test1234` by default). **This should be obviously changed before running this setup as a public CKAN instance.** > Using the default values on the `.env` file will get you a working CKAN instance. There is a sysadmin user created by default with the values defined in `CKAN_SYSADMIN_NAME` and `CKAN_SYSADMIN_PASSWORD` (`ckan_admin` and `test1234` by default). All ennvars with `API_TOKEN` are automatically regenerated when CKAN is loaded, no editing is required.
>
>**This should be obviously changed before running this setup as a public CKAN instance.**
3. Build the images: 3. Build the images:
```bash ```bash

View File

@ -1,14 +1,29 @@
#!/bin/bash #!/bin/bash
# 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
ckan -c $CKAN_INI user token revoke $TOKEN_ID
if [ $? -eq 0 ]; then
echo "API Token $TOKEN_ID has been revoked"
fi
done
# Add ckanext.xloader.api_token to the CKAN config file # Add ckanext.xloader.api_token to the CKAN config file
echo "Loading ckanext-xloader settings in the CKAN config file" echo "Loading ckanext-xloader settings in the CKAN config file"
ckan config-tool $CKAN_INI \ ckan config-tool $CKAN_INI \
"ckanext.xloader.api_token = xxx" \ "ckanext.xloader.api_token=xxx" \
"ckanext.xloader.jobs_db.uri = $CKANEXT__XLOADER__JOBS__DB_URI" "ckanext.xloader.jobs_db.uri=$CKANEXT__XLOADER__JOBS__DB_URI"
# Create ckanext-xloader API_TOKEN # Create ckanext-xloader API_TOKEN
echo "Set up ckanext.xloader.api_token in the CKAN config file" echo "Set up ckanext.xloader.api_token in the CKAN config file"
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')" 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')"
#TODO: Setup worker background #TODO: Setup worker background
#echo "Set up CKAN jobs worker" #echo "Set up CKAN jobs worker"