#!/bin/sh set -e cd $(realpath $(dirname "${0}"))/setup # Check prerequisites [ ! -e /run/openrc/started/postgres ] && service postgres start && STOP_POSTGRES=1 # Create PostgreSQL user and database export SAMBRO_PWD=$(head -c 18 /dev/urandom | base64) envsubst /srv/sambro/conf/000_config.py envsubst /var/lib/lxc/sahana/sahana/tmp/masterUsers.csv cp srv/sambro/conf/00_settings.py /srv/sambro/conf/00_settings.py cp srv/sambro/data/SAMBRO/config.py /srv/sambro/data/SAMBRO/config.py vmmgr update-login sambro "${SAMBRO_ADMIN_USER}" "${SAMBRO_ADMIN_PWD}" # Populate database lxc-execute -u 8001 -g 8001 sambro -- 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 # Set "production values" (increases performance) only if the DEBUG environment variable is not set if [ ${DEBUG:-0} -eq 0 ]; then sed -i 's/settings.base.migrate = True/settings.base.migrate = False/' /srv/sambro/conf/000_config.py sed -i 's/settings.base.debug = True/settings.base.debug = False/' /srv/sambro/conf/000_config.py sed -i 's/#settings.base.prepopulate = 0/settings.base.prepopulate = 0/' /srv/sambro/conf/000_config.py fi # Install service cp etc/init.d/sambro /etc/init.d/sambro rc-update -u # Install config update script cp srv/sambro/update-conf.sh /srv/sambro/update-conf.sh # Stop services required for build [ ! -z ${STOP_POSTGRES} ] && service postgres stop