53 lines
2.4 KiB
Bash
Executable File
53 lines
2.4 KiB
Bash
Executable File
#!/bin/sh
|
|
set -ev
|
|
|
|
# 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_conf /srv/motech/activemq_data
|
|
cp activemq_conf/activemq.xml /srv/motech/activemq_conf/activemq.xml
|
|
chown -R 161616:161616 /srv/motech/activemq_conf /srv/motech/activemq_data
|
|
|
|
# Create database
|
|
export MOTECH_PWD=$(head -c 18 /dev/urandom | base64 | tr -d '+/=')
|
|
service lxc-motech-postgres start
|
|
envsubst <createdb.sql | lxc-attach -u 5432 -g 5432 motech-postgres -- psql
|
|
|
|
# Configure Motech
|
|
mkdir -p /srv/motech/motech_conf/config/org.motechproject.motech-platform-email
|
|
envsubst <motech_conf/config/bootstrap.properties >/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 lxc-motech-activemq start
|
|
service lxc-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 lxc-motech stop
|
|
|
|
# Install config update script
|
|
cp update-conf.sh /srv/motech/update-conf.sh
|
|
|
|
# Stop services required for setup
|
|
service lxc-motech-activemq stop
|
|
service lxc-motech-postgres stop
|
|
|
|
# Register application
|
|
vmmgr register-app motech motech "${MOTECH_ADMIN_USER}" "${MOTECH_ADMIN_PWD}"
|