2018-01-23 18:18:46 +01:00
|
|
|
#!/bin/sh
|
2017-12-07 12:56:11 +01:00
|
|
|
|
|
|
|
SOURCE_DIR=$(realpath $(dirname "${0}"))/motech
|
|
|
|
|
2018-01-23 21:27:18 +01:00
|
|
|
# Check prerequisites
|
2018-01-26 21:58:29 +01:00
|
|
|
docker image ls | grep -q activemq || $(realpath $(dirname "${0}"))/activemq.sh
|
2018-02-03 13:19:24 +01:00
|
|
|
docker image ls | grep -q postfix || $(realpath $(dirname "${0}"))/postfix.sh
|
2018-01-26 21:58:29 +01:00
|
|
|
docker image ls | grep -q postgres || $(realpath $(dirname "${0}"))/postgres.sh
|
|
|
|
docker image ls | grep -q tomcat || $(realpath $(dirname "${0}"))/tomcat.sh
|
2018-01-23 21:27:18 +01:00
|
|
|
|
2018-01-23 18:18:46 +01:00
|
|
|
# Build Docker container
|
|
|
|
docker build -t motech ${SOURCE_DIR}
|
2017-12-07 12:56:11 +01:00
|
|
|
|
|
|
|
# Create database
|
|
|
|
export MOTECH_PWD=$(head -c 18 /dev/urandom | base64)
|
2018-01-23 18:18:46 +01:00
|
|
|
envsubst <${SOURCE_DIR}/createdb.sql | docker exec -i postgres psql
|
|
|
|
|
|
|
|
# Configure Motech
|
|
|
|
mkdir -p /srv/motech/conf/config/org.motechproject.motech-platform-email
|
|
|
|
envsubst <${SOURCE_DIR}/srv/motech/conf/config/bootstrap.properties >/srv/motech/conf/config/bootstrap.properties
|
|
|
|
cp ${SOURCE_DIR}/srv/motech/conf/config-locations.properties /srv/motech/conf/config-locations.properties
|
|
|
|
cp ${SOURCE_DIR}/srv/motech/conf/config/motech-settings.properties /srv/motech/conf/config/motech-settings.properties
|
|
|
|
cp ${SOURCE_DIR}/srv/motech/conf/config/org.motechproject.motech-platform-email/motech-email.properties /srv/motech/conf/config/org.motechproject.motech-platform-email/motech-email.properties
|
|
|
|
chown -R 8013:8013 /srv/motech/conf
|
|
|
|
cp ${SOURCE_DIR}/srv/motech/update-ip.sh /srv/motech/update-ip.sh
|
|
|
|
/srv/motech/update-ip.sh
|
|
|
|
|
|
|
|
# Create Motech service
|
|
|
|
cp ${SOURCE_DIR}/etc/init.d/motech /etc/init.d/motech
|
|
|
|
rc-update add motech boot
|
|
|
|
service motech start
|
2017-12-07 12:56:11 +01:00
|
|
|
|
|
|
|
# Configure Motech admin
|
2018-01-23 18:18:46 +01:00
|
|
|
echo `date` '- Waiting for database to be populated. This should take about a minute.'
|
2018-02-01 14:55:24 +01:00
|
|
|
until curl -s http://127.0.0.1:8013/motech/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"
|
|
|
|
export MOTECH_ADMIN_PWD=$(head -c 12 /dev/urandom | base64)
|
2018-02-01 14:55:24 +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://127.0.0.1:8013/motech/module/server/startup/
|
2017-12-07 12:56:11 +01:00
|
|
|
|
2018-01-23 18:18:46 +01:00
|
|
|
# Create nginx app definition
|
|
|
|
cp ${SOURCE_DIR}/etc/nginx/conf.d/motech.conf /etc/nginx/conf.d/motech.conf
|
|
|
|
service nginx reload
|
2017-12-07 12:56:11 +01:00
|
|
|
|
|
|
|
# Add portal application definition
|
2018-01-23 18:18:46 +01:00
|
|
|
portal-app-manager motech "https://{host}:8413/motech/" "${MOTECH_ADMIN_USER}" "${MOTECH_ADMIN_PWD}"
|