2018-01-08 15:48:23 +01:00
|
|
|
#!/bin/sh
|
2017-12-02 00:29:49 +01:00
|
|
|
|
2017-12-04 17:48:37 +01:00
|
|
|
SOURCE_DIR=$(realpath $(dirname "${0}"))/gnuhealth
|
2017-12-02 00:29:49 +01:00
|
|
|
|
2018-01-23 21:27:18 +01:00
|
|
|
# Check prerequisites
|
2018-02-03 11:20:40 +01:00
|
|
|
docker image ls | grep -q postfix || $(realpath $(dirname "${0}"))/postfix.sh
|
2018-01-23 21:27:18 +01:00
|
|
|
docker image ls | grep -q postgres || $(realpath $(dirname "${0}"))/postgres.sh
|
|
|
|
|
2017-12-29 16:31:48 +01:00
|
|
|
# Build Docker container
|
|
|
|
docker build -t gnuhealth ${SOURCE_DIR}
|
2017-12-02 00:29:49 +01:00
|
|
|
|
2017-12-04 08:57:59 +01:00
|
|
|
# Create databases
|
2017-12-02 00:29:49 +01:00
|
|
|
export GNUHEALTH_PWD=$(head -c 18 /dev/urandom | base64 | tr -d '/+=')
|
2017-12-29 16:31:48 +01:00
|
|
|
envsubst <${SOURCE_DIR}/createdb.sql | docker exec -i postgres psql
|
2017-12-03 19:43:50 +01:00
|
|
|
|
2017-12-02 00:29:49 +01:00
|
|
|
# Configure GNU Health
|
2017-12-29 16:31:48 +01:00
|
|
|
mkdir -p /srv/gnuhealth/conf/
|
|
|
|
envsubst <${SOURCE_DIR}/srv/gnuhealth/conf/trytond.conf >/srv/gnuhealth/conf/trytond.conf
|
2017-12-02 00:29:49 +01:00
|
|
|
|
|
|
|
# Populate database
|
|
|
|
export GNUHEALTH_ADMIN_PWD=$(head -c 12 /dev/urandom | base64)
|
2017-12-29 16:31:48 +01:00
|
|
|
echo ${GNUHEALTH_ADMIN_PWD} >/tmp/.adminpwd
|
2018-02-01 11:54:35 +01:00
|
|
|
docker run --rm -h gnuhealth --link postgres -v /srv/gnuhealth/conf:/srv/gnuhealth/gnuhealth/tryton/server/config -v /tmp/.adminpwd:/tmp/.adminpwd -e TRYTONPASSFILE=/tmp/.adminpwd gnuhealth /srv/gnuhealth/gnuhealth/tryton/server/trytond-4.2.9/bin/trytond-admin -d gnuhealth --all -v
|
2017-12-29 16:31:48 +01:00
|
|
|
rm -f /tmp/.adminpwd
|
2017-12-02 00:29:49 +01:00
|
|
|
|
2017-12-04 08:57:59 +01:00
|
|
|
# Populate demo database
|
|
|
|
wget http://health.gnu.org/downloads/postgres_dumps/gnuhealth-3.2rc1.sql.gz -O /tmp/gnuhealth_demo.sql.gz
|
2017-12-29 16:31:48 +01:00
|
|
|
zcat /tmp/gnuhealth_demo.sql.gz | docker exec -i -e PGPASSWORD=${GNUHEALTH_PWD} postgres psql gnuhealth_demo gnuhealth
|
2017-12-04 08:57:59 +01:00
|
|
|
rm -f /tmp/gnuhealth_demo.sql.gz
|
|
|
|
|
2017-12-29 16:31:48 +01:00
|
|
|
# Create GNU Health service
|
|
|
|
cp ${SOURCE_DIR}/etc/init.d/gnuhealth /etc/init.d/gnuhealth
|
2018-02-06 21:54:11 +01:00
|
|
|
rc-update add gnuhealth
|
2017-12-29 16:31:48 +01:00
|
|
|
service gnuhealth start
|
2017-12-03 22:03:24 +01:00
|
|
|
|
2017-12-29 16:31:48 +01:00
|
|
|
# Create nginx app definition
|
|
|
|
cp ${SOURCE_DIR}/etc/nginx/conf.d/gnuhealth.conf /etc/nginx/conf.d/gnuhealth.conf
|
|
|
|
service nginx reload
|
2017-12-03 22:03:24 +01:00
|
|
|
|
2017-12-02 00:29:49 +01:00
|
|
|
# Add portal application definition
|
2017-12-29 16:31:48 +01:00
|
|
|
portal-app-manager gnuhealth "https://{host}:8408/index.html" admin "${GNUHEALTH_ADMIN_PWD}"
|
2018-02-03 17:36:04 +01:00
|
|
|
portal-app-manager gnuhealth-clients -p clienturl "{host}:8808"
|