44#
55set -e
66
7+ CKAN_USER_NAME=" ${CKAN_USER_NAME:- admin} "
8+ CKAN_DISPLAY_NAME=" ${CKAN_DISPLAY_NAME:- Administrator} "
9+ CKAN_USER_EMAIL=" ${CKAN_USER_EMAIL:- admin@ localhost} "
710CKAN_ACTION_URL=http://ckan:3000/api/action
811
912if [ " $VENV_DIR " != " " ]; then
1013 . ${VENV_DIR} /bin/activate
1114fi
1215
13- CKAN_USER_NAME=" ${CKAN_USER_NAME:- admin} "
14- CKAN_DISPLAY_NAME=" ${CKAN_DISPLAY_NAME:- Administrator} "
15- CKAN_USER_EMAIL=" ${CKAN_USER_EMAIL:- admin@ localhost} "
16-
1716add_user_if_needed () {
1817 echo " Adding user '$2 ' ($1 ) with email address [$3 ]"
1918 ckan_cli user show " $1 " | grep " $1 " || ckan_cli user add " $1 " \
@@ -25,7 +24,6 @@ add_user_if_needed () {
2524add_user_if_needed " $CKAN_USER_NAME " " $CKAN_DISPLAY_NAME " " $CKAN_USER_EMAIL "
2625ckan_cli sysadmin add " ${CKAN_USER_NAME} "
2726
28- # We know the "admin" sysadmin account exists, so we'll use her API KEY to create further data
2927API_KEY=$( ckan_cli user show " ${CKAN_USER_NAME} " | tr -d ' \n' | sed -r ' s/^(.*)apikey=(\S*)(.*)/\2/' )
3028if [ " $API_KEY " = " None" ]; then
3129 echo " No API Key found on ${CKAN_USER_NAME} , generating API Token..."
@@ -45,17 +43,18 @@ add_user_if_needed test_org_admin "Test Admin" test_org_admin@localhost
4543add_user_if_needed test_org_editor " Test Editor" test_org_editor@localhost
4644add_user_if_needed test_org_member " Test Member" test_org_member@localhost
4745
48- echo " Creating ${TEST_ORG_TITLE} Organisation :"
46+ echo " Creating ${TEST_ORG_TITLE} organisation :"
4947
5048TEST_ORG=$( \
5149 curl -LsH " Authorization: ${API_KEY} " \
5250 --data " name=${TEST_ORG_NAME} &title=${TEST_ORG_TITLE} " \
5351 ${CKAN_ACTION_URL} /organization_create
5452)
53+ echo " ${TEST_ORG_TITLE} organisation is: ${TEST_ORG} "
5554
56- TEST_ORG_ID=$( echo $TEST_ORG | sed -r ' s/^(.*)"id": "(.*)",(.*)/\2/ ' )
55+ TEST_ORG_ID=$( echo $TEST_ORG | python $APP_DIR /scripts/extract-id.py )
5756
58- echo " Assigning test users to ${TEST_ORG_TITLE} Organisation :"
57+ echo " Assigning test users to ' ${TEST_ORG_TITLE} ' organisation ( ${TEST_ORG_ID} ) :"
5958
6059curl -LsH " Authorization: ${API_KEY} " \
6160 --data " id=${TEST_ORG_ID} &object=test_org_admin&object_type=user&capacity=admin" \
0 commit comments