This repository has been archived on 2025-08-09. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
web-app-template/create-db.sh
Tim 805abcb364
All checks were successful
Build Docker Image / Explore-Gitea-Actions (push) Successful in 3m8s
#73 add init for db
2024-08-19 23:10:49 +02:00

22 lines
1.1 KiB
Bash
Executable File

PW_POSTGRES=$(openssl rand -base64 32)
PW_UMAMI=$(openssl rand -base64 32)
PW_KEYCLOAK=$(openssl rand -base64 32)
PW_APP=$(openssl rand -base64 32)
printf "DATABASE_URL=postgresql://umami:$PW_UMAMI@postgres:5432/umami\nDATABASE_TYPE=postgresql\nAPP_SECRET=$(openssel rand -base64 128)" > .env.umami
printf "KC_DB_URL=postgresql://keycloak:$PW_KEYCLOAK@postgres:5432/keycloak" > .env.keycloak
psql -U postgres -c "CREATE ROLE umami WITH LOGIN PASSWORD '$PW_UMAMI';"
psql -U postgres -c "CREATE ROLE keycloak WITH LOGIN PASSWORD '$PW_KEYCLOAK';"
psql -U postgres -c "CREATE ROLE app WITH LOGIN PASSWORD '$PW_APP';"
psql -U postgres -c "CREATE DATABASE umami WITH OWNER umami ENCODING 'UTF8' LC_COLLATE='en_US.utf8' LC_CTYPE='en_US.utf8';"
psql -U postgres -c "CREATE DATABASE keycloak WITH OWNER keycloak ENCODING 'UTF8' LC_COLLATE='en_US.utf8' LC_CTYPE='en_US.utf8';"
psql -U postgres -c "CREATE DATABASE app WITH OWNER app ENCODING 'UTF8' LC_COLLATE='en_US.utf8' LC_CTYPE='en_US.utf8';"
psql -U postgres -c "ALTER ROLE postgres WITH PASSWORD '$PW_POSTGRES';"
echo "Postgres password: $PW_POSTGRES"