Make Motech SPOC-compatible
This commit is contained in:
parent
35345dc529
commit
40e26e4407
34
lxc-apps/motech/app
Normal file
34
lxc-apps/motech/app
Normal file
@ -0,0 +1,34 @@
|
||||
{
|
||||
"version": "1.3.0-200313",
|
||||
"meta": {
|
||||
"title": "Motech",
|
||||
"desc-cs": "Automatizace komunikace",
|
||||
"desc-en": "Communication automation",
|
||||
"license": "GPL"
|
||||
},
|
||||
"containers": {
|
||||
"motech": {
|
||||
"image": "motech_1.3.0-200313",
|
||||
"depends": [
|
||||
"motech-activemq",
|
||||
"motech-postgres"
|
||||
],
|
||||
"mounts": {
|
||||
"motech/motech_conf": "srv/tomcat/.motech"
|
||||
}
|
||||
},
|
||||
"motech-activemq": {
|
||||
"image": "activemq_5.15.9-200313",
|
||||
"mounts": {
|
||||
"motech/activemq_conf/activemq.xml": "srv/activemq/conf/activemq.xml:file",
|
||||
"motech/activemq_data": "srv/activemq/data"
|
||||
}
|
||||
},
|
||||
"motech-postgres": {
|
||||
"image": "postgres_12.2.0-200313",
|
||||
"mounts": {
|
||||
"motech/postgres_data": "var/lib/postgresql"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
IMAGE motech_1.3.0-190620
|
||||
FROM alpine3.9-tomcat7_7.0.94-190620
|
||||
IMAGE motech_1.3.0-200313
|
||||
FROM alpine3.11-tomcat7_7.0.99-200313
|
||||
|
||||
RUN EOF
|
||||
# Download Motech
|
||||
@ -9,8 +9,8 @@ RUN EOF
|
||||
|
||||
# Update Postgres JDBC driver
|
||||
rm -f /srv/tomcat/webapps/ROOT/WEB-INF/lib/postgresql-9.1-901.jdbc4.jar /srv/tomcat/webapps/ROOT/WEB-INF/bundles/postgresql-9.1-901.jdbc4.jar
|
||||
wget https://jdbc.postgresql.org/download/postgresql-42.2.5.jar -O /srv/tomcat/webapps/ROOT/WEB-INF/lib/postgresql-42.2.5.jar
|
||||
cp /srv/tomcat/webapps/ROOT/WEB-INF/lib/postgresql-42.2.5.jar /srv/tomcat/webapps/ROOT/WEB-INF/bundles/postgresql-42.2.5.jar
|
||||
wget https://jdbc.postgresql.org/download/postgresql-42.2.11.jar -O /srv/tomcat/webapps/ROOT/WEB-INF/lib/postgresql-42.2.11.jar
|
||||
cp /srv/tomcat/webapps/ROOT/WEB-INF/lib/postgresql-42.2.11.jar /srv/tomcat/webapps/ROOT/WEB-INF/bundles/postgresql-42.2.11.jar
|
||||
|
||||
# Change webapps ownership
|
||||
chown -R tomcat:tomcat /srv/tomcat/webapps
|
||||
@ -19,6 +19,6 @@ RUN EOF
|
||||
rm -f /tmp/motech.war
|
||||
EOF
|
||||
|
||||
USER 8080 8080
|
||||
USER tomcat
|
||||
WORKDIR /srv/tomcat
|
||||
CMD catalina.sh run
|
||||
CMD /usr/bin/catalina.sh run
|
@ -1,52 +1,55 @@
|
||||
#!/bin/sh
|
||||
set -ev
|
||||
|
||||
# Volumes
|
||||
POSTGRES_DATA="${VOLUMES_DIR}/motech/postgres_data"
|
||||
ACTIVEMQ_CONF="${VOLUMES_DIR}/motech/activemq_conf"
|
||||
ACTIVEMQ_DATA="${VOLUMES_DIR}/motech/activemq_data"
|
||||
MOTECH_CONF="${VOLUMES_DIR}/motech/motech_conf"
|
||||
|
||||
# Create Postgres instance
|
||||
mkdir -p /srv/motech/postgres_data
|
||||
chown -R 105432:105432 /srv/motech/postgres_data
|
||||
chmod 700 /srv/motech/postgres_data
|
||||
lxc-execute -n motech-postgres -- initdb -D /var/lib/postgresql
|
||||
install -o 105432 -g 105432 -m 700 -d ${POSTGRES_DATA}
|
||||
spoc-container exec motech-postgres -- initdb -D /var/lib/postgresql
|
||||
|
||||
# Configure Postgres
|
||||
cp postgres_data/postgresql.conf /srv/motech/postgres_data/postgresql.conf
|
||||
cp postgres_data/pg_hba.conf /srv/motech/postgres_data/pg_hba.conf
|
||||
install -o 105432 -g 105432 -m 600 postgres_data/postgresql.conf ${POSTGRES_DATA}/postgresql.conf
|
||||
install -o 105432 -g 105432 -m 600 postgres_data/pg_hba.conf ${POSTGRES_DATA}/pg_hba.conf
|
||||
|
||||
# Configure ActiveMQ
|
||||
mkdir -p /srv/motech/activemq_conf /srv/motech/activemq_data
|
||||
cp activemq_conf/activemq.xml /srv/motech/activemq_conf/activemq.xml
|
||||
chown -R 161616:161616 /srv/motech/activemq_conf /srv/motech/activemq_data
|
||||
install -o 161616 -g 161616 -m 750 -d ${ACTIVEMQ_CONF}
|
||||
install -o 161616 -g 161616 -m 750 -d ${ACTIVEMQ_DATA}
|
||||
install -o 161616 -g 161616 -m 640 activemq_conf/activemq.xml ${ACTIVEMQ_CONF}/activemq.xml
|
||||
|
||||
# Create database
|
||||
export MOTECH_PWD=$(head -c 18 /dev/urandom | base64 | tr -d '+/=')
|
||||
service lxc-motech-postgres start
|
||||
envsubst <createdb.sql | lxc-attach -u 5432 -g 5432 motech-postgres -- psql
|
||||
spoc-container start motech-postgres
|
||||
envsubst <createdb.sql | spoc-container exec motech-postgres -- psql
|
||||
|
||||
# Configure Motech
|
||||
mkdir -p /srv/motech/motech_conf/config/org.motechproject.motech-platform-email
|
||||
envsubst <motech_conf/config/bootstrap.properties >/srv/motech/motech_conf/config/bootstrap.properties
|
||||
cp motech_conf/config-locations.properties /srv/motech/motech_conf/config-locations.properties
|
||||
cp motech_conf/config/motech-settings.properties /srv/motech/motech_conf/config/motech-settings.properties
|
||||
cp motech_conf/config/org.motechproject.motech-platform-email/motech-email.properties /srv/motech/motech_conf/config/org.motechproject.motech-platform-email/motech-email.properties
|
||||
chown -R 108080:108080 /srv/motech/motech_conf
|
||||
install -o 108080 -g 108080 -m 750 -d ${MOTECH_CONF}
|
||||
install -o 108080 -g 108080 -m 750 -d ${MOTECH_CONF}/config
|
||||
install -o 108080 -g 108080 -m 750 -d ${MOTECH_CONF}/config/org.motechproject.motech-platform-email
|
||||
envsubst <motech_conf/config/bootstrap.properties | install -o 108080 -g 108080 -m 640 /dev/stdin ${MOTECH_CONF}/config/bootstrap.properties
|
||||
install -o 108080 -g 108080 -m 640 motech_conf/config-locations.properties ${MOTECH_CONF}/config-locations.properties
|
||||
install -o 108080 -g 108080 -m 640 motech_conf/config/motech-settings.properties ${MOTECH_CONF}/config/motech-settings.properties
|
||||
install -o 108080 -g 108080 -m 640 motech_conf/config/org.motechproject.motech-platform-email/motech-email.properties ${MOTECH_CONF}/config/org.motechproject.motech-platform-email/motech-email.properties
|
||||
|
||||
# Populate database and create admin account
|
||||
service lxc-motech-activemq start
|
||||
service lxc-motech start
|
||||
until curl -s "http://motech:8080/module/server/startup/" | grep -q adminLogin; do
|
||||
spoc-container start motech-activemq
|
||||
spoc-container start motech
|
||||
MOTECH_IP=$(grep ' motech$' /var/lib/spoc/hosts | cut -d' ' -f0)
|
||||
until curl -s "http://${MOTECH_IP}:8080/module/server/startup/" | grep -q adminLogin; do
|
||||
sleep 1
|
||||
done
|
||||
export MOTECH_ADMIN_USER="admin"
|
||||
export MOTECH_ADMIN_EMAIL="admin@example.com"
|
||||
export MOTECH_ADMIN_PWD=$(head -c 12 /dev/urandom | base64 | tr -d '+/=')
|
||||
curl -H "Content-Type: application/json" -X POST -d "{\"adminLogin\":\"${MOTECH_ADMIN_USER}\",\"adminEmail\":\"${MOTECH_ADMIN_EMAIL}\",\"adminPassword\":\"${MOTECH_ADMIN_PWD}\",\"adminConfirmPassword\":\"${MOTECH_ADMIN_PWD}\",\"language\":\"cs\",\"providerName\":\"\",\"providerUrl\":\"\",\"schedulerUrl\":\"\"}" http://motech:8080/module/server/startup/
|
||||
service lxc-motech stop
|
||||
|
||||
# Install config update script
|
||||
cp update-conf.sh /srv/motech/update-conf.sh
|
||||
curl -H "Content-Type: application/json" -X POST -d "{\"adminLogin\":\"${MOTECH_ADMIN_USER}\",\"adminEmail\":\"${MOTECH_ADMIN_EMAIL}\",\"adminPassword\":\"${MOTECH_ADMIN_PWD}\",\"adminConfirmPassword\":\"${MOTECH_ADMIN_PWD}\",\"language\":\"cs\",\"providerName\":\"\",\"providerUrl\":\"\",\"schedulerUrl\":\"\"}" "http://${MOTECH_IP}:8080/module/server/startup/"
|
||||
spoc-container stop motech
|
||||
|
||||
# Stop services required for setup
|
||||
service lxc-motech-activemq stop
|
||||
service lxc-motech-postgres stop
|
||||
spoc-container stop motech-activemq
|
||||
spoc-container stop motech-postgres
|
||||
|
||||
# Register application
|
||||
vmmgr register-app motech motech "${MOTECH_ADMIN_USER}" "${MOTECH_ADMIN_PWD}"
|
||||
|
@ -1,34 +0,0 @@
|
||||
{
|
||||
"version": "1.3.0-190620",
|
||||
"meta": {
|
||||
"title": "Motech",
|
||||
"desc-cs": "Automatizace komunikace",
|
||||
"desc-en": "Communication automation",
|
||||
"license": "GPL"
|
||||
},
|
||||
"containers": {
|
||||
"motech": {
|
||||
"image": "motech_1.3.0-190620",
|
||||
"depends": [
|
||||
"motech-activemq",
|
||||
"motech-postgres"
|
||||
],
|
||||
"mounts": [
|
||||
["DIR", "/srv/motech/motech_conf", "/srv/tomcat/.motech"]
|
||||
]
|
||||
},
|
||||
"motech-activemq": {
|
||||
"image": "activemq_5.15.9-190620",
|
||||
"mounts": [
|
||||
["FILE", "/srv/motech/activemq_conf/activemq.xml", "/srv/activemq/conf/activemq.xml"],
|
||||
["DIR", "/srv/motech/activemq_data", "/srv/activemq/data"]
|
||||
]
|
||||
},
|
||||
"motech-postgres": {
|
||||
"image": "postgres_11.3.0-190620",
|
||||
"mounts": [
|
||||
["DIR", "/srv/motech/postgres_data", "/var/lib/postgresql"]
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
@ -2,7 +2,7 @@
|
||||
set -ev
|
||||
|
||||
# Remove persistent data
|
||||
rm -rf /srv/motech
|
||||
rm -rf "${VOLUMES_DIR}/motech"
|
||||
|
||||
# Unregister application
|
||||
vmmgr unregister-app motech
|
||||
|
Loading…
Reference in New Issue
Block a user