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

39 lines
1.5 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
2019-10-03 20:36:14 +02:00
# Create Postgres instance
mkdir -p /srv/gnuhealth/postgres_data
chown -R 105432:105432 /srv/gnuhealth/postgres_data
chmod 700 /srv/gnuhealth/postgres_data
lxc-execute -n gnuhealth-postgres -- initdb -D /var/lib/postgresql
# Configure Postgres
cp postgres_data/postgresql.conf /srv/gnuhealth/postgres_data/postgresql.conf
cp postgres_data/pg_hba.conf /srv/gnuhealth/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 '+/=')
2019-10-03 20:36:14 +02:00
service start gnuhealth-postgres
envsubst <createdb.sql | lxc-attach -u 5432 -g 5432 gnuhealth-postgres -- psql
2017-12-02 00:29:49 +01:00
# Configure GNU Health
2019-10-03 20:36:14 +02:00
mkdir -p /srv/gnuhealth/gnuhealth_conf/
envsubst <gnuhealth_conf/trytond.conf >/srv/gnuhealth/gnuhealth_conf/trytond.conf
2017-12-02 00:29:49 +01:00
# Populate database
export GNUHEALTH_ADMIN_USER="admin"
2019-06-05 18:55:15 +02:00
export GNUHEALTH_ADMIN_PWD=$(head -c 12 /dev/urandom | base64 | tr -d '+/=')
2019-10-03 20:36:14 +02:00
lxc-execute gnuhealth -- sh -c "echo ${GNUHEALTH_ADMIN_PWD} >/tmp/.adminpwd; TRYTONPASSFILE=/tmp/.adminpwd trytond-admin -d gnuhealth --all -v; rm /tmp/.adminpwd"
2017-12-02 00:29:49 +01:00
# Populate demo database
2019-10-03 20:36:14 +02:00
lxc-execute gnuhealth -- zcat /srv/gnuhealth/gnuhealth_demo.sql.gz | lxc-attach -u 5432 -g 5432 gnuhealth-postgres -- sh -c "PGPASSWORD=${GNUHEALTH_PWD} psql gnuhealth_demo gnuhealth"
2018-09-13 20:32:57 +02:00
# Install config update script
2019-10-03 20:36:14 +02:00
cp update-conf.sh /srv/gnuhealth/update-conf.sh
2018-09-13 20:32:57 +02:00
# Stop services required for setup
2019-10-03 20:36:14 +02:00
service gnuhealth-postgres stop
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}"