mirror of
https://github.com/Websoft9/websoft9.git
synced 2025-01-24 01:50:19 +08:00
add metabase
This commit is contained in:
parent
8a92821e0e
commit
5ab802ef4e
50
apps/roles/metabase/templates/create_users.sh
Normal file
50
apps/roles/metabase/templates/create_users.sh
Normal file
@ -0,0 +1,50 @@
|
||||
#!/bin/sh
|
||||
# copy from: https://www.metabase.com/learn/administration/serialization#add-users-to-our-metabase-origin-environment
|
||||
|
||||
ADMIN_EMAIL=${MB_ADMIN_EMAIL:-admin@metabase.local}
|
||||
ADMIN_PASSWORD=${MB_ADMIN_PASSWORD:-Metapass123}
|
||||
|
||||
METABASE_HOST=${MB_HOSTNAME}
|
||||
METABASE_PORT=${MB_PORT:-3000}
|
||||
|
||||
echo "⌚︎ Waiting for Metabase to start"
|
||||
while (! curl -s -m 5 http://${METABASE_HOST}:${METABASE_PORT}/api/session/properties -o /dev/null); do sleep 5; done
|
||||
|
||||
echo "😎 Creating admin user"
|
||||
|
||||
SETUP_TOKEN=$(curl -s -m 5 -X GET \
|
||||
-H "Content-Type: application/json" \
|
||||
http://${METABASE_HOST}:${METABASE_PORT}/api/session/properties \
|
||||
| jq -r '.["setup-token"]'
|
||||
)
|
||||
|
||||
MB_TOKEN=$(curl -s -X POST \
|
||||
-H "Content-type: application/json" \
|
||||
http://${METABASE_HOST}:${METABASE_PORT}/api/setup \
|
||||
-d '{
|
||||
"token": "'${SETUP_TOKEN}'",
|
||||
"user": {
|
||||
"email": "'${ADMIN_EMAIL}'",
|
||||
"first_name": "Metabase",
|
||||
"last_name": "Admin",
|
||||
"password": "'${ADMIN_PASSWORD}'"
|
||||
},
|
||||
"prefs": {
|
||||
"allow_tracking": false,
|
||||
"site_name": "Metawhat"
|
||||
}
|
||||
}' | jq -r '.id')
|
||||
|
||||
|
||||
echo -e "\n👥 Creating some basic users: "
|
||||
curl -s "http://${METABASE_HOST}:${METABASE_PORT}/api/user" \
|
||||
-H 'Content-Type: application/json' \
|
||||
-H "X-Metabase-Session: ${MB_TOKEN}" \
|
||||
-d '{"first_name":"Basic","last_name":"User","email":"basic@somewhere.com","login_attributes":{"region_filter":"WA"},"password":"'${ADMIN_PASSWORD}'"}'
|
||||
|
||||
curl -s "http://${METABASE_HOST}:${METABASE_PORT}/api/user" \
|
||||
-H 'Content-Type: application/json' \
|
||||
-H "X-Metabase-Session: ${MB_TOKEN}" \
|
||||
-d '{"first_name":"Basic 2","last_name":"User","email":"basic2@somewhere.com","login_attributes":{"region_filter":"CA"},"password":"'${ADMIN_PASSWORD}'"}'
|
||||
|
||||
echo -e "\n👥 Basic users created!"
|
@ -1,4 +1,4 @@
|
||||
- name: Copy create_users.sh to /opt/
|
||||
copy:
|
||||
template:
|
||||
src: create_users.sh
|
||||
dest: /opt/create_users.sh
|
||||
|
Loading…
Reference in New Issue
Block a user