Skip to content

Commit

Permalink
BAH-2581 | Add. Integrating Metabase with Open MRS Database
Browse files Browse the repository at this point in the history
  • Loading branch information
kusumikab committed Dec 5, 2022
1 parent 436f9f6 commit 96deeec
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 5 deletions.
8 changes: 4 additions & 4 deletions bahmni-metabase/docker/scripts/create_admin.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,21 @@ SETUP_TOKEN=$(curl -s -m 5 -X GET \
| jq -r '.["setup-token"]'
)

curl -s -X POST \
MB_TOKEN=$(curl -s -X POST \
-H "Content-type: application/json" \
http://${MB_HOST}:${MB_PORT}/api/setup \
-d '{
"token": "'${SETUP_TOKEN}'",
"user": {
"email": "'${MB_ADMIN_EMAIL}'",
"first_name": "'${MB_ADMIN_FIRST_NAME}'",
"last_name": "'${MB_ADMIN_LAST_NAME}'",
"password": "'${MB_ADMIN_PASSWORD}'"
},
"prefs": {
"allow_tracking": false,
"site_name": "Bahmni Metabase"
}
}'
}' | jq -r '.id')

echo -e "\n Admin users created!"

echo -e "\n Admin user created!"
21 changes: 21 additions & 0 deletions bahmni-metabase/docker/scripts/create_openmrs_db.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/bin/sh


echo "Adding OPENMRS Database to Metabase"

curl -s -X POST \
-H "Content-type: application/json" \
-H "X-Metabase-Session: ${MB_TOKEN}" \
http://${MB_HOST}:${MB_PORT}/api/database \
-d '{
"engine": "'${OPENMRS_DB_TYPE}'",
"name": "'${OPENMRS_DB_HOST}'",
"details": {
"host": "'${OPENMRS_DB_HOST}'",
"db": "'${OPENMRS_DB_NAME}'",
"user": "'${OPENMRS_DB_USERNAME}'",
"password": "'${OPENMRS_DB_PASSWORD}'"
}
}'

echo "OPENMRS Database added to Metabase"
6 changes: 5 additions & 1 deletion bahmni-metabase/docker/scripts/metabase_init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,8 @@
echo "Waiting for Metabase to start"
while (! curl -s -m 5 http://${MB_HOST}:${MB_PORT}/api/session/properties -o /dev/null); do sleep 5; done

/app/scripts/create_admin.sh
echo "Metabase initiated successfully."

source /app/scripts/create_admin.sh

source /app/scripts/create_openmrs_db.sh

0 comments on commit 96deeec

Please sign in to comment.