#!/bin/sh set -ev # Volumes POSTGRES_DATA="${VOLUMES_DIR}/gnuhealth/postgres_data" GNUHEALTH_CONF="${VOLUMES_DIR}/gnuhealth/gnuhealth_conf" # Create Postgres instance install -o 105432 -g 105432 -m 700 -d ${POSTGRES_DATA} spoc-container exec gnuhealth-postgres -- initdb -D /var/lib/postgresql # Configure Postgres install -o 105432 -g 105432 -m 600 postgres_data/postgresql.conf ${POSTGRES_DATA}/postgresql.conf install -o 105432 -g 105432 -m 600 postgres_data/pg_hba.conf ${POSTGRES_DATA}/pg_hba.conf # Create databases export GNUHEALTH_PWD=$(head -c 18 /dev/urandom | base64 | tr -d '+/=') spoc-container start gnuhealth-postgres envsubst /tmp/.adminpwd; TRYTONPASSFILE=/tmp/.adminpwd trytond-admin -d gnuhealth --email ${GNUHEALTH_ADMIN_EMAIL} --all -v; rm /tmp/.adminpwd" # Populate demo database spoc-container exec gnuhealth -- zcat /srv/gnuhealth/gnuhealth_demo.sql.gz | spoc-container exec gnuhealth-postgres -- sh -c "PGPASSWORD=${GNUHEALTH_PWD} psql gnuhealth_demo gnuhealth" # Stop services required for setup spoc-container stop gnuhealth-postgres # Register application vmmgr register-app gnuhealth gh "${GNUHEALTH_ADMIN_USER}" "${GNUHEALTH_ADMIN_PWD}" vmmgr register-prop gnuhealth email "${GNUHEALTH_ADMIN_EMAIL}"