LXCize Motech setup

This commit is contained in:
Disassembler 2018-09-13 21:14:53 +02:00
parent db9458b4ad
commit 365f983c2d
No known key found for this signature in database
GPG Key ID: 524BD33A0EE29499
4 changed files with 17 additions and 27 deletions

View File

@ -1,7 +1,7 @@
#!/bin/sh
set -e
SOURCE_DIR=$(realpath $(dirname "${0}"))/kanboard
SOURCE_DIR=$(realpath $(dirname "${0}"))/setup
# Check prerequisites
[ ! -e /run/openrc/started/postgres ] && service postgres start && STOP_POSTGRES=1

View File

@ -1,7 +1,7 @@
#!/bin/sh
set -e
SOURCE_DIR=$(realpath $(dirname "${0}"))/mifosx
SOURCE_DIR=$(realpath $(dirname "${0}"))/setup
# Check prerequisites
[ ! -e /run/openrc/started/mariadb ] && service mariadb start && STOP_MARIADB=1

View File

@ -1,22 +1,15 @@
#!/bin/sh
set -e
SOURCE_DIR=$(realpath $(dirname "${0}"))/motech
SOURCE_DIR=$(realpath $(dirname "${0}"))/setup
# Check prerequisites
lxc-ls | grep -q activemq || $(realpath $(dirname "${0}"))/activemq.sh
lxc-ls | grep -q postfix || $(realpath $(dirname "${0}"))/postfix.sh
lxc-ls | grep -q postgres || $(realpath $(dirname "${0}"))/postgres.sh
service postgres start
# Build Docker container
docker build -t motech ${SOURCE_DIR}
cp ${SOURCE_DIR}/etc/init.d/motech /etc/init.d/motech
rc-update -u
[ ! -e /run/openrc/started/activemq ] && service activemq start && STOP_ACTIVEMQ=1
[ ! -e /run/openrc/started/postgres ] && service postgres start && STOP_POSTGRES=1
# Create database
export MOTECH_PWD=$(head -c 18 /dev/urandom | base64)
envsubst <${SOURCE_DIR}/createdb.sql | docker exec -i postgres psql
envsubst <${SOURCE_DIR}/createdb.sql | lxc-attach -u 5432 -g 5432 postgres -- psql
# Configure Motech
mkdir -p /srv/motech/conf/config/org.motechproject.motech-platform-email
@ -26,10 +19,14 @@ cp ${SOURCE_DIR}/srv/motech/conf/config/motech-settings.properties /srv/motech/c
cp ${SOURCE_DIR}/srv/motech/conf/config/org.motechproject.motech-platform-email/motech-email.properties /srv/motech/conf/config/org.motechproject.motech-platform-email/motech-email.properties
chown -R 8013:8013 /srv/motech/conf
# Install service
cp ${SOURCE_DIR}/etc/init.d/motech /etc/init.d/motech
rc-update -u
# Populate database and create admin account
service motech start
echo `date` '- Waiting for database to be populated. This should take about a minute.'
MOTECH_IP=$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' motech)
MOTECH_IP=$(awk '/ motech/ {print $1}' /etc/hosts)
until curl -s "http://${MOTECH_IP}:8080/module/server/startup/" | grep -q adminLogin; do
sleep 1
done
@ -41,5 +38,5 @@ service motech stop
vmmgr update-login motech "${MOTECH_ADMIN_USER}" "${MOTECH_ADMIN_PWD}"
# Stop services required for build
service activemq stop
service postgres stop
[ ! -z ${STOP_ACTIVEMQ} ] && service activemq stop
[ ! -z ${STOP_POSTGRES} ] && service postgres stop

View File

@ -1,20 +1,13 @@
#!/sbin/openrc-run
description="Motech docker container"
description="Motech container"
depend() {
need docker activemq postfix postgres
need cgroups activemq postgres
}
start() {
/usr/bin/docker run -d --rm \
--name motech \
-h motech \
--link activemq \
--link postfix \
--link postgres \
-v /srv/motech/conf:/srv/tomcat/.motech \
motech
lxc-start motech
}
start_post() {
@ -26,5 +19,5 @@ stop_pre() {
}
stop() {
/usr/bin/docker stop motech
lxc-stop motech
}