#!/bin/sh set -ev cd $(realpath $(dirname "${0}"))/install # Create Postgres instance mkdir -p /srv/motech/postgres_data chown -R 105432:105432 /srv/motech/postgres_data chmod 700 /srv/motech/postgres_data lxc-execute -n motech-postgres -- initdb -D /var/lib/postgresql # Configure Postgres cp postgres_data/postgresql.conf /srv/motech/postgres_data/postgresql.conf cp postgres_data/pg_hba.conf /srv/motech/postgres_data/pg_hba.conf # Configure ActiveMQ mkdir -p /srv/motech/activemq_data chown -R 161616:161616 /srv/motech/activemq_data # Create database export MOTECH_PWD=$(head -c 18 /dev/urandom | base64 | tr -d '+/=') service motech-postgres start envsubst /srv/motech/motech_conf/config/bootstrap.properties cp motech_conf/config-locations.properties /srv/motech/motech_conf/config-locations.properties cp motech_conf/config/motech-settings.properties /srv/motech/motech_conf/config/motech-settings.properties cp motech_conf/config/org.motechproject.motech-platform-email/motech-email.properties /srv/motech/motech_conf/config/org.motechproject.motech-platform-email/motech-email.properties chown -R 108080:108080 /srv/motech/motech_conf # Populate database and create admin account service activemq start service motech start until curl -s "http://motech:8080/module/server/startup/" | grep -q adminLogin; do sleep 1 done export MOTECH_ADMIN_USER="admin" export MOTECH_ADMIN_EMAIL="admin@example.com" export MOTECH_ADMIN_PWD=$(head -c 12 /dev/urandom | base64 | tr -d '+/=') curl -H "Content-Type: application/json" -X POST -d "{\"adminLogin\":\"${MOTECH_ADMIN_USER}\",\"adminEmail\":\"${MOTECH_ADMIN_EMAIL}\",\"adminPassword\":\"${MOTECH_ADMIN_PWD}\",\"adminConfirmPassword\":\"${MOTECH_ADMIN_PWD}\",\"language\":\"cs\",\"providerName\":\"\",\"providerUrl\":\"\",\"schedulerUrl\":\"\"}" http://motech:8080/module/server/startup/ service motech stop # Install config update script cp update-conf.sh /srv/motech/update-conf.sh # Stop services required for setup service motech-activemq stop service motech-postgres stop # Register application vmmgr register-app motech motech "${MOTECH_ADMIN_USER}" "${MOTECH_ADMIN_PWD}" TODO: move the activemq conf here