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 1, 2022
1 parent 436f9f6 commit d4d3090
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 3 deletions.
5 changes: 3 additions & 2 deletions bahmni-metabase/docker/scripts/create_admin.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ 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 '{
Expand All @@ -23,6 +23,7 @@ curl -s -X POST \
"allow_tracking": false,
"site_name": "Bahmni Metabase"
}
}'
}' | jq -r '.id')


echo -e "\n Admin users 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 added 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": "'${MB_MYSQL_ENGINE}'",
"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 d4d3090

Please sign in to comment.