2018-01-19 20:32:16 +01:00
|
|
|
#!/bin/sh
|
2018-10-28 16:04:11 +01:00
|
|
|
set -ev
|
2017-12-08 20:28:47 +01:00
|
|
|
|
2019-10-03 21:29:19 +02:00
|
|
|
# Create MariaDB instance
|
|
|
|
mkdir -p /srv/mifosx/mariadb_conf /srv/mifosx/mariadb_data
|
|
|
|
chown 103306:103306 /srv/mifosx/mariadb_data
|
|
|
|
cp mariadb_conf/my.cnf /srv/mifosx/mariadb_conf/my.cnf
|
|
|
|
chown -R 100000:100000 /srv/mifosx/mariadb_conf
|
2019-12-13 21:28:55 +01:00
|
|
|
lxc-execute mifosx-mariadb -- mysql_install_db --user=mysql --datadir=/var/lib/mysql --auth-root-authentication-method=socket --auth-root-socket-user=mysql --skip-test-db
|
2017-12-08 20:28:47 +01:00
|
|
|
|
|
|
|
# Create databases
|
2019-06-05 18:55:15 +02:00
|
|
|
export MIFOSX_PWD=$(head -c 18 /dev/urandom | base64 | tr -d '+/=')
|
2019-11-30 22:11:38 +01:00
|
|
|
service lxc-mifosx-mariadb start
|
2019-12-13 21:28:55 +01:00
|
|
|
envsubst <createdb.sql | lxc-attach mifosx-mariadb -- mysql -u mysql
|
2017-12-08 20:28:47 +01:00
|
|
|
|
2018-01-19 20:32:16 +01:00
|
|
|
# Configure Mifos X
|
2019-12-13 21:40:27 +01:00
|
|
|
mkdir -p /srv/mifosx/mifosx_conf
|
2019-10-03 21:29:19 +02:00
|
|
|
envsubst <mifosx_conf/context.xml >/srv/mifosx/mifosx_conf/context.xml
|
|
|
|
cp mifosx_conf/server.xml /srv/mifosx/mifosx_conf/server.xml
|
2019-12-13 21:40:27 +01:00
|
|
|
chown -R 100000:100000 /srv/mifosx/mifosx_conf
|
|
|
|
|
|
|
|
# Populate database
|
|
|
|
lxc-execute mifosx -- cat /tmp/mifospltaform-tenants-first-time-install.sql | lxc-attach mifosx-mariadb -- mysql -u mysql mifosplatform-tenants
|
|
|
|
envsubst <schemapwd.sql | lxc-attach mifosx-mariadb -- mysql -u mysql mifosplatform-tenants
|
2018-09-13 21:10:32 +02:00
|
|
|
|
2018-04-29 20:48:57 +02:00
|
|
|
# Populate database
|
2019-12-13 21:40:27 +01:00
|
|
|
service lxc-mifosx start
|
2018-12-10 09:31:18 +01:00
|
|
|
until grep -q 'org.apache.catalina.startup.Catalina.start Server startup' /var/log/lxc/mifosx.log; do
|
2018-01-19 20:32:16 +01:00
|
|
|
sleep 1
|
|
|
|
done
|
2019-12-13 21:40:27 +01:00
|
|
|
service lxc-mifosx stop
|
2019-03-01 12:22:17 +01:00
|
|
|
|
2018-08-02 21:10:21 +02:00
|
|
|
# Fix missing previous_run_status column
|
2019-12-13 21:28:55 +01:00
|
|
|
echo 'ALTER TABLE `scheduled_email_campaign` ADD `previous_run_status` VARCHAR(10) NULL;' | lxc-attach mifosx-mariadb -- mysql -u 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
|
2019-06-05 18:55:15 +02: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}')
|
2019-12-13 21:28:55 +01:00
|
|
|
envsubst <adminpwd.sql | lxc-attach mifosx-mariadb -- mysql -u mysql mifostenant-default
|
2018-07-15 21:55:35 +02:00
|
|
|
|
2018-09-20 15:45:00 +02:00
|
|
|
# Install config update script
|
2019-10-03 21:29:19 +02:00
|
|
|
cp 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
|
2019-11-30 22:11:38 +01:00
|
|
|
service lxc-mifosx-mariadb stop
|
2018-10-28 19:50:35 +01:00
|
|
|
|
2018-11-03 15:53:51 +01:00
|
|
|
# Register application
|
2019-02-26 21:12:41 +01:00
|
|
|
vmmgr register-app mifosx mifosx "${MIFOSX_ADMIN_USER}" "${MIFOSX_ADMIN_PWD}"
|