Rework MifosX

This commit is contained in:
Disassembler 2019-10-03 21:29:19 +02:00
parent 990a9dcb71
commit 57cd65115d
No known key found for this signature in database
GPG Key ID: 524BD33A0EE29499
11 changed files with 74 additions and 59 deletions

View File

@ -28,11 +28,6 @@ export CTS_SECRET=$(head -c 26 /dev/urandom | base64 | tr -d '+/=')
envsubst <cts_conf/spotter.py >/srv/cts/cts_conf/spotter.py
touch /srv/cts/cts_conf/__init__.py
# Set "production values" (increases performance) only if the DEBUG environment variable is not set
if [ ${DEBUG:-0} -eq 0 ]; then
sed -i 's/DEBUG = True/DEBUG = False/' /srv/cts/cts_conf/spotter.py
fi
# Populate database
lxc-execute cts -- manage.py migrate

View File

@ -43,5 +43,5 @@ CELERY_EAGER_PROPAGATES_EXCEPTIONS = True
TIME_ZONE = 'Europe/Prague'
LANGUAGE_CODE = 'cs'
DEBUG = True
DEBUG = False
TEMPLATE_DEBUG = DEBUG

View File

@ -3,49 +3,49 @@ set -ev
cd $(realpath $(dirname "${0}"))/install
# Check prerequisites
[ ! -e /run/openrc/started/mariadb ] && service mariadb start && STOP_MARIADB=1
# 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 '+/=')
envsubst <createdb.sql | lxc-attach mariadb -- mysql
service mifosx-mariadb start
envsubst <createdb.sql | lxc-attach mifosx-mariadb -- mysql
# Populate database
cat /var/lib/lxc/mifosx/mifosx/tmp/mifospltaform-tenants-first-time-install.sql | lxc-attach mariadb -- mysql mifosplatform-tenants
envsubst <schemapwd.sql | lxc-attach mariadb -- mysql mifosplatform-tenants
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 <srv/mifosx/conf/context.xml >/srv/mifosx/conf/context.xml
cp srv/mifosx/conf/server.xml /srv/mifosx/conf/server.xml
# Install service
cp etc/init.d/mifosx /etc/init.d/mifosx
rc-update -u
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
>/var/log/lxc/mifosx.log
lxc-start mifosx
service start mifosx
until grep -q 'org.apache.catalina.startup.Catalina.start Server startup' /var/log/lxc/mifosx.log; do
sleep 1
done
lxc-stop mifosx
service stop mifosx
# Fix missing previous_run_status column
echo 'ALTER TABLE `scheduled_email_campaign` ADD `previous_run_status` VARCHAR(10) NULL;' | lxc-attach mariadb -- mysql mifostenant-default
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 mariadb -- mysql mifostenant-default
envsubst <adminpwd.sql | lxc-attach mifosx-mariadb -- mysql mifostenant-default
# Install config update script
cp srv/mifosx/update-conf.sh /srv/mifosx/update-conf.sh
cp update-conf.sh /srv/mifosx/update-conf.sh
# Stop services required for setup
[ ! -z ${STOP_MARIADB} ] && service mariadb stop
service mifosx-mariadb stop
# Register application
vmmgr register-app mifosx mifosx "${MIFOSX_ADMIN_USER}" "${MIFOSX_ADMIN_PWD}"

View File

@ -1,23 +0,0 @@
#!/sbin/openrc-run
description="Mifos X container"
depend() {
need mariadb
}
start() {
lxc-start mifosx
}
start_post() {
vmmgr register-proxy mifosx
}
stop_pre() {
vmmgr unregister-proxy mifosx
}
stop() {
lxc-stop mifosx
}

View File

@ -0,0 +1,24 @@
[mysqld]
skip-external-locking
skip-name-resolve
key_buffer_size = 16M
max_allowed_packet = 1M
table_open_cache = 64
sort_buffer_size = 512K
net_buffer_length = 8K
read_buffer_size = 256K
read_rnd_buffer_size = 512K
myisam_sort_buffer_size = 8M
[mysqldump]
quick
max_allowed_packet = 1M
[mysql]
no-auto-rehash
[myisamchk]
key_buffer_size = 20M
sort_buffer_size = 20M
read_buffer = 2M
write_buffer = 2M

View File

@ -40,7 +40,4 @@ RUN EOF
rm /tmp/locale-cs.patch
EOF
MOUNT FILE /srv/mifosx/conf/server.xml srv/tomcat/conf/server.xml
MOUNT FILE /srv/mifosx/conf/context.xml srv/tomcat/webapps/fineract-provider/META-INF/context.xml
CMD s6-svscan /etc/services.d

28
lxc-apps/mifosx/meta Normal file
View File

@ -0,0 +1,28 @@
{
"version": "18.03.01-190620",
"meta": {
"title": "Mifos X",
"desc-cs": "Mikrofinancování rozvojových projektů",
"desc-en": "Development projects microfinancing",
"license": "GPL",
},
"containers": {
"mifosx": {
"image": "mifosx_18.03.01-190620",
"depends": [
"mifosx-mariadb"
],
"mounts": [
["FILE", "/srv/mifosx/mifosx_conf/server.xml", "/srv/tomcat/conf/server.xml"],
["FILE", "/srv/mifosx/mifosx_conf/context.xml", "/srv/tomcat/webapps/fineract-provider/META-INF/context.xml"]
]
},
"mifosx-mariadb": {
"image": "mariadb_10.3.15-190620",
"mounts": [
["FILE", "/srv/mifosx/mariadb_conf/my.cnf", "/etc/my.cnf"],
["DIR", "/srv/mifosx/mariadb_data", "/var/lib/mysql"]
]
}
}
}

View File

@ -1,14 +1,8 @@
#!/bin/sh
set -ev
# Remove service
rm -f /etc/init.d/mifosx
rc-update -u
# Drop database and user
[ ! -e /run/openrc/started/mariadb ] && service mariadb start && STOP_MARIADB=1
echo 'DROP DATABASE IF EXISTS `mifosplatform-tenants`; DROP DATABASE IF EXISTS `mifostenant-default`; DROP USER IF EXISTS `mifosx`;' | lxc-attach mariadb -- mysql
[ ! -z ${STOP_MARIADB} ] && service mariadb stop
# Remove persistent data
rm -rf /srv/mifosx
# Unregister application
vmmgr unregister-app mifosx