#!/bin/sh set -ev cd $(realpath $(dirname "${0}"))/install # Create Postgres instance mkdir -p /srv/sahana-demo/postgres_data chown -R 105432:105432 /srv/sahana-demo/postgres_data chmod 700 /srv/sahana-demo/postgres_data lxc-execute -n sahana-demo-postgres -- initdb -D /var/lib/postgresql # Configure Postgres cp postgres_data/postgresql.conf /srv/sahana-demo/postgres_data/postgresql.conf cp postgres_data/pg_hba.conf /srv/sahana-demo/postgres_data/pg_hba.conf # Create PostgreSQL user and database export SAHANADEMO_PWD=$(head -c 18 /dev/urandom | base64 | tr -d '+/=') service sahana-demo-postgres start envsubst /srv/sahana-demo/sahana_conf/000_config.py envsubst /srv/sahana-demo/sahana_data/default/users/masterUsers.csv chown -R 108001:108001 /srv/sahana/sahana_conf /srv/sahana/sahana_data # Populate database lxc-execute -u 8001 -g 8001 sahana-demo -- sh -c 'cd /srv/web2py; ./web2py.py -S eden -M -R applications/eden/static/scripts/tools/noop.py' # Install config update script cp update-conf.sh /srv/sahana-demo/update-conf.sh # Stop services required for setup service sahana-demo-postgres stop # Register application vmmgr register-app sahana-demo sahana-demo "${SAHANADEMO_ADMIN_USER}" "${SAHANADEMO_ADMIN_PWD}"