2018-01-19 20:32:16 +01:00
|
|
|
#!/bin/sh
|
2017-12-08 20:28:47 +01:00
|
|
|
|
|
|
|
SOURCE_DIR=$(realpath $(dirname "${0}"))/mifosx
|
|
|
|
|
2018-01-23 21:27:18 +01:00
|
|
|
# Check prerequisites
|
|
|
|
docker image ls | grep -q mariadb || $(realpath $(dirname "${0}"))/mariadb.sh
|
2018-02-03 12:59:09 +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 tomcat || $(realpath $(dirname "${0}"))/tomcat.sh
|
2018-01-23 21:27:18 +01:00
|
|
|
|
2018-01-19 20:32:16 +01:00
|
|
|
# Build Docker container
|
|
|
|
docker build -t mifosx ${SOURCE_DIR}
|
2017-12-08 20:28:47 +01:00
|
|
|
|
|
|
|
# Create databases
|
|
|
|
export MIFOSX_PWD=$(head -c 18 /dev/urandom | base64)
|
2018-01-19 20:32:16 +01:00
|
|
|
envsubst <${SOURCE_DIR}/createdb.sql | docker exec -i mariadb mysql
|
2017-12-08 20:28:47 +01:00
|
|
|
|
|
|
|
# Populate database
|
2018-01-24 15:55:47 +01:00
|
|
|
docker run --rm mifosx cat /tmp/mifospltaform-tenants-first-time-install.sql | docker exec -i mariadb mysql mifosplatform-tenants
|
2018-01-19 20:32:16 +01:00
|
|
|
envsubst <${SOURCE_DIR}/schemapwd.sql | docker exec -i mariadb mysql mifosplatform-tenants
|
|
|
|
|
|
|
|
# Configure Mifos X
|
2018-01-27 14:25:41 +01:00
|
|
|
mkdir -p /srv/mifosx/conf
|
|
|
|
envsubst <${SOURCE_DIR}/srv/mifosx/conf/context.xml >/srv/mifosx/conf/context.xml
|
2018-01-19 20:32:16 +01:00
|
|
|
|
|
|
|
# Create Mifos X service
|
|
|
|
cp ${SOURCE_DIR}/etc/init.d/mifosx /etc/init.d/mifosx
|
2018-02-06 21:54:11 +01:00
|
|
|
rc-update add mifosx
|
2018-01-19 20:32:16 +01:00
|
|
|
service mifosx start
|
2017-12-08 20:28:47 +01:00
|
|
|
|
|
|
|
# Update admin account
|
2018-01-23 21:01:47 +01:00
|
|
|
echo `date` '- Waiting for database to be populated. This should take about a minute.'
|
2018-01-19 20:32:16 +01:00
|
|
|
until docker logs mifosx 2>&1 | grep -q 'Migrating schema `mifostenant-default` to version 5000'; do
|
|
|
|
sleep 1
|
|
|
|
done
|
2017-12-08 20:28:47 +01:00
|
|
|
export MIFOSX_ADMIN_USER=admin
|
|
|
|
export MIFOSX_ADMIN_EMAIL=admin@example.com
|
2017-12-08 21:34:22 +01:00
|
|
|
export MIFOSX_ADMIN_PWD=$(head -c 12 /dev/urandom | base64 | tr -d "+")
|
2017-12-08 20:28:47 +01:00
|
|
|
export MIFOSX_ADMIN_HASH=$(echo -n "${MIFOSX_ADMIN_PWD}{1}" | sha256sum | awk '{print $1}')
|
2018-01-19 20:32:16 +01:00
|
|
|
envsubst <${SOURCE_DIR}/adminpwd.sql | docker exec -i mariadb mysql mifostenant-default
|
2017-12-08 20:28:47 +01:00
|
|
|
|
2018-01-19 20:32:16 +01:00
|
|
|
# Create nginx app definition
|
|
|
|
cp ${SOURCE_DIR}/etc/nginx/conf.d/mifosx.conf /etc/nginx/conf.d/mifosx.conf
|
|
|
|
service nginx reload
|
2017-12-08 20:28:47 +01:00
|
|
|
|
|
|
|
# Add portal application definition
|
2018-01-19 20:32:16 +01:00
|
|
|
portal-app-manager mifosx "https://{host}:8412/community-app/" "${MIFOSX_ADMIN_USER}" "${MIFOSX_ADMIN_PWD}"
|
2017-12-08 20:28:47 +01:00
|
|
|
portal-app-manager mifosx-mobile
|