2018-01-19 20:32:16 +01:00
|
|
|
#!/bin/sh
|
2018-07-15 21:55:35 +02:00
|
|
|
set -e
|
2017-12-08 20:28:47 +01:00
|
|
|
|
2018-10-26 15:02:11 +02:00
|
|
|
cd $(realpath $(dirname "${0}"))/install
|
2017-12-08 20:28:47 +01:00
|
|
|
|
2018-01-23 21:27:18 +01:00
|
|
|
# Check prerequisites
|
2018-09-13 21:10:32 +02:00
|
|
|
[ ! -e /run/openrc/started/mariadb ] && service mariadb start && STOP_MARIADB=1
|
2017-12-08 20:28:47 +01:00
|
|
|
|
|
|
|
# Create databases
|
|
|
|
export MIFOSX_PWD=$(head -c 18 /dev/urandom | base64)
|
2018-10-25 22:22:36 +02:00
|
|
|
envsubst <createdb.sql | lxc-attach mariadb -- mysql
|
2017-12-08 20:28:47 +01:00
|
|
|
|
|
|
|
# Populate database
|
2018-09-13 21:10:32 +02:00
|
|
|
cat /var/lib/lxc/mifosx/mifosx/tmp/mifospltaform-tenants-first-time-install.sql | lxc-attach mariadb -- mysql mifosplatform-tenants
|
2018-10-25 22:22:36 +02:00
|
|
|
envsubst <schemapwd.sql | lxc-attach mariadb -- mysql mifosplatform-tenants
|
2018-01-19 20:32:16 +01:00
|
|
|
|
|
|
|
# Configure Mifos X
|
2018-01-27 14:25:41 +01:00
|
|
|
mkdir -p /srv/mifosx/conf
|
2018-10-25 22:22:36 +02:00
|
|
|
envsubst <srv/mifosx/conf/context.xml >/srv/mifosx/conf/context.xml
|
|
|
|
cp srv/mifosx/conf/server.xml /srv/mifosx/conf/server.xml
|
2018-01-19 20:32:16 +01:00
|
|
|
|
2018-09-13 21:10:32 +02:00
|
|
|
# Install service
|
2018-10-25 22:22:36 +02:00
|
|
|
cp etc/init.d/mifosx /etc/init.d/mifosx
|
2018-09-13 21:10:32 +02:00
|
|
|
rc-update -u
|
|
|
|
|
2018-04-29 20:48:57 +02:00
|
|
|
# Populate database
|
2018-01-19 20:32:16 +01:00
|
|
|
service mifosx start
|
2018-01-23 21:01:47 +01:00
|
|
|
echo `date` '- Waiting for database to be populated. This should take about a minute.'
|
2018-09-13 21:10:32 +02:00
|
|
|
until grep -q 'Migrating schema `mifostenant-default` to version 5000' /var/log/lxc/mifosx.log; do
|
2018-01-19 20:32:16 +01:00
|
|
|
sleep 1
|
|
|
|
done
|
2018-07-15 21:55:35 +02:00
|
|
|
service mifosx stop
|
2018-08-02 21:10:21 +02:00
|
|
|
# Fix missing previous_run_status column
|
2018-09-13 21:10:32 +02:00
|
|
|
echo 'ALTER TABLE `scheduled_email_campaign` ADD `previous_run_status` VARCHAR(10) NULL;' | lxc-attach mariadb -- mysql mifostenant-default
|
2018-04-29 20:48:57 +02:00
|
|
|
|
|
|
|
# Update admin account
|
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-10-25 22:22:36 +02:00
|
|
|
envsubst <adminpwd.sql | lxc-attach mariadb -- mysql mifostenant-default
|
2018-09-04 21:42:26 +02:00
|
|
|
vmmgr update-login mifosx "${MIFOSX_ADMIN_USER}" "${MIFOSX_ADMIN_PWD}"
|
2018-07-15 21:55:35 +02:00
|
|
|
|
2018-09-20 15:45:00 +02:00
|
|
|
# Install config update script
|
2018-10-25 22:22:36 +02:00
|
|
|
cp srv/mifosx/update-conf.sh /srv/mifosx/update-conf.sh
|
2018-09-20 15:45:00 +02:00
|
|
|
|
2018-09-13 21:10:32 +02:00
|
|
|
# Stop services required for setup
|
|
|
|
[ ! -z ${STOP_MARIADB} ] && service mariadb stop
|