#!/bin/sh set -e cd $(realpath $(dirname "${0}"))/setup export TEMPLATE=${TEMPLATE:-"default"} # Check prerequisites [ ! -e /run/openrc/started/postgres ] && service postgres start && STOP_POSTGRES=1 # Create PostgreSQL user and database export SAHANADEMO_PWD=$(head -c 18 /dev/urandom | base64) envsubst /srv/sahana-demo/conf/000_config.py envsubst /var/lib/lxc/sahana/sahana/tmp/masterUsers.csv vmmgr update-login sahana-demo "${SAHANADEMO_ADMIN_USER}" "${SAHANADEMO_ADMIN_PWD}" # Replace template in LXC container mount definition sed -i "s/default/${TEMPLATE}/g" /var/lib/lxc/sahana-demo/config # Populate database lxc-execute -u 8001 -g 8001 sahana-demo -- sh -c 'cd /srv/web2py; cp /tmp/masterUsers.csv applications/eden/modules/templates/default/users/masterUsers.csv; ./web2py.py -S eden -M -R applications/eden/static/scripts/tools/noop.py' rm /var/lib/lxc/sahana/sahana/tmp/masterUsers.csv # Install service envsubst /etc/init.d/sahana-demo chmod +x /etc/init.d/sahana-demo # Install config update script cp srv/sahana-demo/update-conf.sh /srv/sahana-demo/update-conf.sh # Stop services required for build [ ! -z ${STOP_POSTGRES} ] && service postgres stop