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

56 lines
2.8 KiB
Bash
Raw Permalink Normal View History

2018-01-23 18:18:46 +01:00
#!/bin/sh
2018-10-28 16:04:11 +01:00
set -ev
2020-03-20 14:51:12 +01:00
# Volumes
POSTGRES_DATA="${VOLUMES_DIR}/motech/postgres_data"
ACTIVEMQ_CONF="${VOLUMES_DIR}/motech/activemq_conf"
ACTIVEMQ_DATA="${VOLUMES_DIR}/motech/activemq_data"
MOTECH_CONF="${VOLUMES_DIR}/motech/motech_conf"
2019-10-03 21:41:23 +02:00
# Create Postgres instance
2020-03-20 14:51:12 +01:00
install -o 105432 -g 105432 -m 700 -d ${POSTGRES_DATA}
spoc-container exec motech-postgres -- initdb -D /var/lib/postgresql
2019-10-03 21:41:23 +02:00
# Configure Postgres
2020-03-20 14:51:12 +01:00
install -o 105432 -g 105432 -m 600 postgres_data/postgresql.conf ${POSTGRES_DATA}/postgresql.conf
install -o 105432 -g 105432 -m 600 postgres_data/pg_hba.conf ${POSTGRES_DATA}/pg_hba.conf
2019-10-03 21:41:23 +02:00
# Configure ActiveMQ
2020-03-20 14:51:12 +01:00
install -o 161616 -g 161616 -m 750 -d ${ACTIVEMQ_CONF}
install -o 161616 -g 161616 -m 750 -d ${ACTIVEMQ_DATA}
install -o 161616 -g 161616 -m 640 activemq_conf/activemq.xml ${ACTIVEMQ_CONF}/activemq.xml
# Create database
2019-06-05 18:55:15 +02:00
export MOTECH_PWD=$(head -c 18 /dev/urandom | base64 | tr -d '+/=')
2020-03-20 14:51:12 +01:00
spoc-container start motech-postgres
envsubst <createdb.sql | spoc-container exec motech-postgres -- psql
2018-01-23 18:18:46 +01:00
# Configure Motech
2020-03-20 14:51:12 +01:00
install -o 108080 -g 108080 -m 750 -d ${MOTECH_CONF}
install -o 108080 -g 108080 -m 750 -d ${MOTECH_CONF}/config
install -o 108080 -g 108080 -m 750 -d ${MOTECH_CONF}/config/org.motechproject.motech-platform-email
envsubst <motech_conf/config/bootstrap.properties | install -o 108080 -g 108080 -m 640 /dev/stdin ${MOTECH_CONF}/config/bootstrap.properties
install -o 108080 -g 108080 -m 640 motech_conf/config-locations.properties ${MOTECH_CONF}/config-locations.properties
install -o 108080 -g 108080 -m 640 motech_conf/config/motech-settings.properties ${MOTECH_CONF}/config/motech-settings.properties
install -o 108080 -g 108080 -m 640 motech_conf/config/org.motechproject.motech-platform-email/motech-email.properties ${MOTECH_CONF}/config/org.motechproject.motech-platform-email/motech-email.properties
2018-09-13 21:14:53 +02:00
# Populate database and create admin account
2020-03-20 14:51:12 +01:00
spoc-container start motech-activemq
spoc-container start motech
MOTECH_IP=$(grep ' motech$' /var/lib/spoc/hosts | cut -d' ' -f0)
until curl -s "http://${MOTECH_IP}: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 '+/=')
2020-03-20 14:51:12 +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_IP}:8080/module/server/startup/"
spoc-container stop motech
2019-10-03 21:41:23 +02:00
# Stop services required for setup
2020-03-20 14:51:12 +01:00
spoc-container stop motech-activemq
spoc-container stop motech-postgres
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}"