Spotter-VM/lxc-apps/motech/install.sh

54 lines
2.3 KiB
Bash
Raw Normal View History

2018-01-23 18:18:46 +01:00
#!/bin/sh
2018-10-28 16:04:11 +01:00
set -ev
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
# Create database
2019-06-05 18:55:15 +02:00
export MOTECH_PWD=$(head -c 18 /dev/urandom | base64 | tr -d '+/=')
2019-11-30 22:11:38 +01:00
service lxc-motech-postgres start
2019-10-03 21:41:23 +02:00
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
chown -R 108080:108080 /srv/motech/motech_conf
2018-09-13 21:14:53 +02:00
# Populate database and create admin account
2019-11-30 22:11:38 +01:00
service lxc-motech-activemq start
service lxc-motech start
until curl -s "http://motech:8080/module/server/startup/" | grep -q adminLogin; do
2018-01-23 18:18:46 +01:00
sleep 1
done
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-11-30 22:11:38 +01:00
service lxc-motech stop
# Install config update script
2019-10-03 21:41:23 +02:00
cp update-conf.sh /srv/motech/update-conf.sh
2019-10-03 21:41:23 +02:00
# Stop services required for setup
2019-11-30 22:11:38 +01:00
service lxc-motech-activemq stop
service lxc-motech-postgres stop
2018-10-28 19:50:35 +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