From c0389bba8561878a4dc085215733eb9bc13d4ebb Mon Sep 17 00:00:00 2001 From: Disassembler Date: Mon, 4 Dec 2017 08:57:59 +0100 Subject: [PATCH] Add GNU Health demo database, closes #164 --- basic/srv/portal/index.html | 1 + gnuhealth.sh | 9 ++++++++- gnuhealth/tmp/gnuhealth-createdb.sql | 4 ++++ 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/basic/srv/portal/index.html b/basic/srv/portal/index.html index e4e1a9f..b63d439 100644 --- a/basic/srv/portal/index.html +++ b/basic/srv/portal/index.html @@ -175,6 +175,7 @@ diff --git a/gnuhealth.sh b/gnuhealth.sh index 11826d0..3a3e525 100755 --- a/gnuhealth.sh +++ b/gnuhealth.sh @@ -29,7 +29,7 @@ patch -d /srv/gnuhealth/sao -p0 <${SOURCE_DIR}/gnuhealth/gnuhealth-sao-dependenc virtualenv --system-site-packages -p /usr/bin/python3 /srv/gnuhealth echo '. /srv/gnuhealth/bin/activate' >/srv/gnuhealth/.bash_profile -# Create database +# Create databases export GNUHEALTH_PWD=$(head -c 18 /dev/urandom | base64 | tr -d '/+=') envsubst <${SOURCE_DIR}/gnuhealth/tmp/gnuhealth-createdb.sql >/tmp/gnuhealth-createdb.sql sudo -u postgres psql -f /tmp/gnuhealth-createdb.sql @@ -55,6 +55,13 @@ echo ${GNUHEALTH_ADMIN_PWD} >/srv/gnuhealth/.adminpwd sudo -u gnuhealth -i TRYTONPASSFILE=/srv/gnuhealth/.adminpwd /srv/gnuhealth/gnuhealth/tryton/server/trytond-4.2.7/bin/trytond-admin -d gnuhealth --all -v rm -f /srv/gnuhealth/.adminpwd +# Populate demo database +wget http://health.gnu.org/downloads/postgres_dumps/gnuhealth-3.2rc1.sql.gz -O /tmp/gnuhealth_demo.sql.gz +export PGPASSWORD=${GNUHEALTH_PWD} +zcat /tmp/gnuhealth_demo.sql.gz | psql gnuhealth_demo gnuhealth +unset PGPASSWORD +rm -f /tmp/gnuhealth_demo.sql.gz + # Configure GNU Health service cp ${SOURCE_DIR}/gnuhealth/lib/systemd/system/gnuhealth.service /lib/systemd/system/gnuhealth.service systemctl daemon-reload diff --git a/gnuhealth/tmp/gnuhealth-createdb.sql b/gnuhealth/tmp/gnuhealth-createdb.sql index b02dd82..542df79 100644 --- a/gnuhealth/tmp/gnuhealth-createdb.sql +++ b/gnuhealth/tmp/gnuhealth-createdb.sql @@ -2,3 +2,7 @@ CREATE ROLE gnuhealth NOSUPERUSER NOCREATEDB NOCREATEROLE NOINHERIT LOGIN ENCRYP CREATE DATABASE gnuhealth; REVOKE ALL ON DATABASE gnuhealth FROM public; ALTER DATABASE gnuhealth OWNER TO gnuhealth; + +CREATE DATABASE gnuhealth_demo; +REVOKE ALL ON DATABASE gnuhealth_demo FROM public; +ALTER DATABASE gnuhealth_demo OWNER TO gnuhealth;