Spotter-VM/lxc-apps/gnuhealth/install.sh

39 lines
1.6 KiB
Bash
Raw Normal View History

2018-01-08 15:48:23 +01:00
#!/bin/sh
2018-10-28 16:04:11 +01:00
set -ev
2017-12-02 00:29:49 +01:00
2020-03-17 13:39:43 +01:00
# Volumes
POSTGRES_DATA="${VOLUMES_DIR}/gnuhealth/postgres_data"
GNUHEALTH_CONF="${VOLUMES_DIR}/gnuhealth/gnuhealth_conf"
2019-10-03 20:36:14 +02:00
# Create Postgres instance
2020-03-17 13:39:43 +01:00
install -o 105432 -g 105432 -m 700 -d ${POSTGRES_DATA}
spoc-container exec gnuhealth-postgres -- initdb -D /var/lib/postgresql
2019-10-03 20:36:14 +02:00
# Configure Postgres
2020-03-17 13:39:43 +01:00
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
2017-12-02 00:29:49 +01:00
# Create databases
2019-06-05 18:55:15 +02:00
export GNUHEALTH_PWD=$(head -c 18 /dev/urandom | base64 | tr -d '+/=')
2020-03-17 13:39:43 +01:00
spoc-container start gnuhealth-postgres
envsubst <createdb.sql | spoc-container exec gnuhealth-postgres -- psql
2017-12-02 00:29:49 +01:00
# Configure GNU Health
2020-03-17 13:39:43 +01:00
install -o 108080 -g 108080 -m 750 -d ${GNUHEALTH_CONF}
envsubst <gnuhealth_conf/trytond.conf | install -o 108080 -g 108080 -m 640 /dev/stdin ${GNUHEALTH_CONF}/trytond.conf
2017-12-02 00:29:49 +01:00
# Populate database
export GNUHEALTH_ADMIN_USER="admin"
2020-03-17 13:39:43 +01:00
export GNUHEALTH_ADMIN_EMAIL="admin@example.com"
2019-06-05 18:55:15 +02:00
export GNUHEALTH_ADMIN_PWD=$(head -c 12 /dev/urandom | base64 | tr -d '+/=')
2020-03-17 13:39:43 +01:00
spoc-container exec gnuhealth -- sh -c "echo ${GNUHEALTH_ADMIN_PWD} >/tmp/.adminpwd; TRYTONPASSFILE=/tmp/.adminpwd trytond-admin -d gnuhealth --email ${GNUHEALTH_ADMIN_EMAIL} --all -v; rm /tmp/.adminpwd"
2017-12-02 00:29:49 +01:00
# Populate demo database
2020-03-17 13:39:43 +01:00
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"
2018-09-13 20:32:57 +02:00
# Stop services required for setup
2020-03-17 13:39:43 +01:00
spoc-container stop gnuhealth-postgres
2018-10-28 19:50:35 +01:00
# Register application
2019-02-26 21:12:41 +01:00
vmmgr register-app gnuhealth gh "${GNUHEALTH_ADMIN_USER}" "${GNUHEALTH_ADMIN_PWD}"