LXCize MifosX setup
This commit is contained in:
parent
b7aedad589
commit
db9458b4ad
@ -4,46 +4,42 @@ set -e
|
|||||||
SOURCE_DIR=$(realpath $(dirname "${0}"))/mifosx
|
SOURCE_DIR=$(realpath $(dirname "${0}"))/mifosx
|
||||||
|
|
||||||
# Check prerequisites
|
# Check prerequisites
|
||||||
lxc-ls | grep -q mariadb || $(realpath $(dirname "${0}"))/mariadb.sh
|
[ ! -e /run/openrc/started/mariadb ] && service mariadb start && STOP_MARIADB=1
|
||||||
lxc-ls | grep -q postfix || $(realpath $(dirname "${0}"))/postfix.sh
|
|
||||||
service mariadb start
|
|
||||||
|
|
||||||
# Build Docker container
|
|
||||||
docker build -t mifosx ${SOURCE_DIR}
|
|
||||||
cp ${SOURCE_DIR}/etc/init.d/mifosx /etc/init.d/mifosx
|
|
||||||
rc-update -u
|
|
||||||
|
|
||||||
# Create databases
|
# Create databases
|
||||||
export MIFOSX_PWD=$(head -c 18 /dev/urandom | base64)
|
export MIFOSX_PWD=$(head -c 18 /dev/urandom | base64)
|
||||||
envsubst <${SOURCE_DIR}/createdb.sql | docker exec -i mariadb mysql
|
envsubst <${SOURCE_DIR}/createdb.sql | lxc-attach mariadb -- mysql
|
||||||
|
|
||||||
# Populate database
|
# Populate database
|
||||||
docker run --rm mifosx cat /tmp/mifospltaform-tenants-first-time-install.sql | docker exec -i mariadb mysql mifosplatform-tenants
|
cat /var/lib/lxc/mifosx/mifosx/tmp/mifospltaform-tenants-first-time-install.sql | lxc-attach mariadb -- mysql mifosplatform-tenants
|
||||||
envsubst <${SOURCE_DIR}/schemapwd.sql | docker exec -i mariadb mysql mifosplatform-tenants
|
envsubst <${SOURCE_DIR}/schemapwd.sql | lxc-attach mariadb -- mysql mifosplatform-tenants
|
||||||
|
|
||||||
# Configure Mifos X
|
# Configure Mifos X
|
||||||
mkdir -p /srv/mifosx/conf
|
mkdir -p /srv/mifosx/conf
|
||||||
envsubst <${SOURCE_DIR}/srv/mifosx/conf/context.xml >/srv/mifosx/conf/context.xml
|
envsubst <${SOURCE_DIR}/srv/mifosx/conf/context.xml >/srv/mifosx/conf/context.xml
|
||||||
cp ${SOURCE_DIR}/srv/mifosx/conf/server.xml /srv/mifosx/conf/server.xml
|
cp ${SOURCE_DIR}/srv/mifosx/conf/server.xml /srv/mifosx/conf/server.xml
|
||||||
|
|
||||||
|
# Install service
|
||||||
|
cp ${SOURCE_DIR}/etc/init.d/mifosx /etc/init.d/mifosx
|
||||||
|
rc-update -u
|
||||||
|
|
||||||
# Populate database
|
# Populate database
|
||||||
service mifosx start
|
service mifosx start
|
||||||
echo `date` '- Waiting for database to be populated. This should take about a minute.'
|
echo `date` '- Waiting for database to be populated. This should take about a minute.'
|
||||||
until docker logs mifosx 2>&1 | grep -q 'Migrating schema `mifostenant-default` to version 5000'; do
|
until grep -q 'Migrating schema `mifostenant-default` to version 5000' /var/log/lxc/mifosx.log; do
|
||||||
sleep 1
|
sleep 1
|
||||||
done
|
done
|
||||||
service mifosx stop
|
service mifosx stop
|
||||||
# Fix missing previous_run_status column
|
# Fix missing previous_run_status column
|
||||||
echo 'ALTER TABLE `scheduled_email_campaign` ADD `previous_run_status` VARCHAR(10) NULL;' | docker exec -i mariadb mysql mifostenant-default
|
echo 'ALTER TABLE `scheduled_email_campaign` ADD `previous_run_status` VARCHAR(10) NULL;' | lxc-attach mariadb -- mysql mifostenant-default
|
||||||
|
|
||||||
# Update admin account
|
# Update admin account
|
||||||
export MIFOSX_ADMIN_USER=admin
|
export MIFOSX_ADMIN_USER=admin
|
||||||
export MIFOSX_ADMIN_EMAIL=admin@example.com
|
export MIFOSX_ADMIN_EMAIL=admin@example.com
|
||||||
export MIFOSX_ADMIN_PWD=$(head -c 12 /dev/urandom | base64 | tr -d "+")
|
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}')
|
export MIFOSX_ADMIN_HASH=$(echo -n "${MIFOSX_ADMIN_PWD}{1}" | sha256sum | awk '{print $1}')
|
||||||
envsubst <${SOURCE_DIR}/adminpwd.sql | docker exec -i mariadb mysql mifostenant-default
|
envsubst <${SOURCE_DIR}/adminpwd.sql | lxc-attach mariadb -- mysql mifostenant-default
|
||||||
vmmgr update-login mifosx "${MIFOSX_ADMIN_USER}" "${MIFOSX_ADMIN_PWD}"
|
vmmgr update-login mifosx "${MIFOSX_ADMIN_USER}" "${MIFOSX_ADMIN_PWD}"
|
||||||
|
|
||||||
# Stop services required for build
|
# Stop services required for setup
|
||||||
service mariadb stop
|
[ ! -z ${STOP_MARIADB} ] && service mariadb stop
|
||||||
service postfix stop
|
|
||||||
|
@ -1,20 +1,13 @@
|
|||||||
#!/sbin/openrc-run
|
#!/sbin/openrc-run
|
||||||
|
|
||||||
description="Mifos X docker container"
|
description="Mifos X container"
|
||||||
|
|
||||||
depend() {
|
depend() {
|
||||||
need docker mariadb postfix
|
need cgroups mariadb
|
||||||
}
|
}
|
||||||
|
|
||||||
start() {
|
start() {
|
||||||
/usr/bin/docker run -d --rm \
|
lxc-start mifosx
|
||||||
--name mifosx \
|
|
||||||
-h mifosx \
|
|
||||||
--link mariadb \
|
|
||||||
--link postfix \
|
|
||||||
-v /srv/mifosx/conf/server.xml:/srv/tomcat/conf/server.xml \
|
|
||||||
-v /srv/mifosx/conf/context.xml:/srv/tomcat/webapps/fineract-provider/META-INF/context.xml \
|
|
||||||
mifosx
|
|
||||||
}
|
}
|
||||||
|
|
||||||
start_post() {
|
start_post() {
|
||||||
@ -26,5 +19,5 @@ stop_pre() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
stop() {
|
stop() {
|
||||||
/usr/bin/docker stop mifosx
|
lxc-stop mifosx
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user