2018-01-23 18:18:46 +01:00
|
|
|
#!/bin/sh
|
2018-10-28 16:04:11 +01:00
|
|
|
set -ev
|
2017-12-07 12:56:11 +01:00
|
|
|
|
2019-10-03 21:41:23 +02:00
|
|
|
# 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
|
2017-12-07 12:56:11 +01:00
|
|
|
|
|
|
|
# Create database
|
2019-06-05 18:55:15 +02:00
|
|
|
export MOTECH_PWD=$(head -c 18 /dev/urandom | base64 | tr -d '+/=')
|
2019-10-03 21:41:23 +02:00
|
|
|
service motech-postgres start
|
|
|
|
envsubst <createdb.sql | lxc-attach -u 5432 -g 5432 motech-postgres -- psql
|
2018-01-23 18:18:46 +01:00
|
|
|
|
|
|
|
# Configure Motech
|
2019-10-03 21:41:23 +02:00
|
|
|
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
|
2019-10-14 07:59:06 +02:00
|
|
|
chown -R 108080:108080 /srv/motech/motech_conf
|
2018-09-13 21:14:53 +02:00
|
|
|
|
2018-04-29 20:48:57 +02:00
|
|
|
# Populate database and create admin account
|
2019-10-03 21:41:23 +02:00
|
|
|
service activemq start
|
|
|
|
service motech start
|
2018-11-04 19:50:23 +01:00
|
|
|
until curl -s "http://motech:8080/module/server/startup/" | grep -q adminLogin; do
|
2018-01-23 18:18:46 +01:00
|
|
|
sleep 1
|
|
|
|
done
|
2017-12-07 12:56:11 +01:00
|
|
|
export MOTECH_ADMIN_USER="admin"
|
|
|
|
export MOTECH_ADMIN_EMAIL="admin@example.com"
|
2019-06-05 18:55:15 +02:00
|
|
|
export MOTECH_ADMIN_PWD=$(head -c 12 /dev/urandom | base64 | tr -d '+/=')
|
2018-11-07 14:08:30 +01:00
|
|
|
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/
|
2019-10-03 21:41:23 +02:00
|
|
|
service motech stop
|
2018-07-15 21:55:35 +02:00
|
|
|
|
2018-09-20 15:45:00 +02:00
|
|
|
# Install config update script
|
2019-10-03 21:41:23 +02:00
|
|
|
cp update-conf.sh /srv/motech/update-conf.sh
|
2018-09-20 15:45:00 +02:00
|
|
|
|
2019-10-03 21:41:23 +02:00
|
|
|
# Stop services required for setup
|
|
|
|
service motech-activemq stop
|
|
|
|
service motech-postgres stop
|
2018-10-28 19:50:35 +01:00
|
|
|
|
2018-11-03 15:53:51 +01:00
|
|
|
# Register application
|
2019-02-26 21:12:41 +01:00
|
|
|
vmmgr register-app motech motech "${MOTECH_ADMIN_USER}" "${MOTECH_ADMIN_PWD}"
|
2019-10-03 21:41:23 +02:00
|
|
|
|
|
|
|
TODO: move the activemq conf here
|