initdb.sh 833 B

123456789101112131415161718192021222324
  1. #!/bin/bash -e
  2. # Create terminalserver network in case it doesn't exist
  3. docker network inspect terminalserver_default 1>/dev/null \
  4. || docker network create terminalserver_default
  5. # Get query for DB creation
  6. mkdir -p ./data/docker-entrypoint-initdb.d
  7. docker compose run --rm --no-deps guacamole /opt/guacamole/bin/initdb.sh --postgresql > ./data/docker-entrypoint-initdb.d/10-initdb.sql
  8. # Update default password for guacadmin
  9. source .env
  10. cat << EOF >> ./data/docker-entrypoint-initdb.d/10-initdb.sql
  11. UPDATE guacamole_user
  12. SET password_salt = NULL, password_hash = SHA256('$GUACADMIN_PASSWORD')
  13. WHERE user_id = 1;
  14. EOF
  15. # Start database
  16. docker compose up -d guacamole-db
  17. # Print tables
  18. docker exec guacamole-db sh -c 'until pg_isready; do sleep 3; done; psql --username=guacamole --dbname=guacamole --command="\dt"'