50 lines
1.9 KiB
Bash
Executable File
50 lines
1.9 KiB
Bash
Executable File
#!/bin/sh
|
|
set -ev
|
|
|
|
# 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
|
|
lxc-execute mifosx-mariadb -- mysql_install_db --user=mysql --datadir=/var/lib/mysql --auth-root-authentication-method=socket --skip-test-db
|
|
|
|
# Create databases
|
|
export MIFOSX_PWD=$(head -c 18 /dev/urandom | base64 | tr -d '+/=')
|
|
service mifosx-mariadb start
|
|
envsubst <createdb.sql | lxc-attach mifosx-mariadb -- mysql
|
|
|
|
# Populate database
|
|
lxc-execute mifosx -- cat /tmp/mifospltaform-tenants-first-time-install.sql | lxc-attach mifosx-mariadb -- mysql mifosplatform-tenants
|
|
envsubst <schemapwd.sql | lxc-attach mifosx-mariadb -- mysql mifosplatform-tenants
|
|
|
|
# Configure Mifos X
|
|
mkdir -p /srv/mifosx_conf
|
|
envsubst <mifosx_conf/context.xml >/srv/mifosx/mifosx_conf/context.xml
|
|
cp mifosx_conf/server.xml /srv/mifosx/mifosx_conf/server.xml
|
|
|
|
# Populate database
|
|
service start mifosx
|
|
until grep -q 'org.apache.catalina.startup.Catalina.start Server startup' /var/log/lxc/mifosx.log; do
|
|
sleep 1
|
|
done
|
|
service stop mifosx
|
|
|
|
# Fix missing previous_run_status column
|
|
echo 'ALTER TABLE `scheduled_email_campaign` ADD `previous_run_status` VARCHAR(10) NULL;' | lxc-attach mifosx-mariadb -- mysql mifostenant-default
|
|
|
|
# Update admin account
|
|
export MIFOSX_ADMIN_USER=admin
|
|
export MIFOSX_ADMIN_EMAIL=admin@example.com
|
|
export MIFOSX_ADMIN_PWD=$(head -c 12 /dev/urandom | base64 | tr -d '+/=')
|
|
export MIFOSX_ADMIN_HASH=$(echo -n "${MIFOSX_ADMIN_PWD}{1}" | sha256sum | awk '{print $1}')
|
|
envsubst <adminpwd.sql | lxc-attach mifosx-mariadb -- mysql mifostenant-default
|
|
|
|
# Install config update script
|
|
cp update-conf.sh /srv/mifosx/update-conf.sh
|
|
|
|
# Stop services required for setup
|
|
service mifosx-mariadb stop
|
|
|
|
# Register application
|
|
vmmgr register-app mifosx mifosx "${MIFOSX_ADMIN_USER}" "${MIFOSX_ADMIN_PWD}"
|