Make Sigmah SPOC-compatible
This commit is contained in:
parent
236c15dbac
commit
ecfafd0c4a
27
lxc-apps/sigmah/app
Normal file
27
lxc-apps/sigmah/app
Normal file
@ -0,0 +1,27 @@
|
||||
{
|
||||
"version": "2.0.2-200313",
|
||||
"meta": {
|
||||
"title": "Sigmah",
|
||||
"desc-cs": "Finanční řízení sbírek",
|
||||
"desc-en": "Donation management",
|
||||
"license": "GPL"
|
||||
},
|
||||
"containers": {
|
||||
"sigmah": {
|
||||
"image": "sigmah_2.0.2-200313",
|
||||
"depends": [
|
||||
"sigmah-postgres"
|
||||
],
|
||||
"mounts": {
|
||||
"sigmah/sigmah_conf": "srv/sigmah/conf",
|
||||
"sigmah/sigmah_data": "srv/sigmah/data"
|
||||
}
|
||||
},
|
||||
"sigmah-postgres": {
|
||||
"image": "postgres_12.2.0-200313",
|
||||
"mounts": {
|
||||
"sigmah/postgres_data": "var/lib/postgresql"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
IMAGE sigmah_2.0.2-190620
|
||||
FROM alpine3.9-tomcat8.5_8.5.41-190620
|
||||
IMAGE sigmah_2.0.2-200313
|
||||
FROM alpine3.11-tomcat8.5_8.5.51-200313
|
||||
|
||||
RUN EOF
|
||||
# Download Sigmah
|
||||
@ -25,8 +25,8 @@ RUN EOF
|
||||
rm /tmp/sigmah.war
|
||||
EOF
|
||||
|
||||
COPY lxc
|
||||
COPY image.d
|
||||
|
||||
USER 8080 8080
|
||||
USER tomcat
|
||||
WORKDIR /srv/tomcat
|
||||
CMD /usr/bin/catalina.sh run
|
@ -1,36 +1,40 @@
|
||||
#!/bin/sh
|
||||
set -ev
|
||||
|
||||
# Volumes
|
||||
POSTGRES_DATA="${VOLUMES_DIR}/sigmah/postgres_data"
|
||||
SIGMAH_DATA="${VOLUMES_DIR}/sigmah/sigmah_data"
|
||||
SIGMAH_CONF="${VOLUMES_DIR}/sigmah/sigmah_conf"
|
||||
SIGMAH_LAYER="${LAYERS_DIR}/sigmah_2.0.2-200313"
|
||||
|
||||
# Create Postgres instance
|
||||
mkdir -p /srv/sigmah/postgres_data
|
||||
chown -R 105432:105432 /srv/sigmah/postgres_data
|
||||
chmod 700 /srv/sigmah/postgres_data
|
||||
lxc-execute -n sigmah-postgres -- initdb -D /var/lib/postgresql
|
||||
install -o 105432 -g 105432 -m 700 -d ${POSTGRES_DATA}
|
||||
spoc-container exec sigmah-postgres -- initdb -D /var/lib/postgresql
|
||||
|
||||
# Configure Postgres
|
||||
cp postgres_data/postgresql.conf /srv/sigmah/postgres_data/postgresql.conf
|
||||
cp postgres_data/pg_hba.conf /srv/sigmah/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
|
||||
|
||||
# Create database
|
||||
export SIGMAH_PWD=$(head -c 18 /dev/urandom | base64 | tr -d '+/=')
|
||||
service lxc-sigmah-postgres start
|
||||
envsubst <createdb.sql | lxc-attach -u 5432 -g 5432 sigmah-postgres -- psql
|
||||
spoc-container start sigmah-postgres
|
||||
envsubst <createdb.sql | spoc-container exec sigmah-postgres -- psql
|
||||
|
||||
# Configure Sigmah
|
||||
mkdir -p /srv/sigmah/sigmah_conf /srv/sigmah/sigmah_data/files /srv/sigmah/sigmah_data/archives
|
||||
chown -R 108080:108080 /srv/sigmah/sigmah_data
|
||||
envsubst <sigmah_conf/persistence.xml >/srv/sigmah/sigmah_conf/persistence.xml
|
||||
cp sigmah_conf/sigmah.properties /srv/sigmah/sigmah_conf/sigmah.properties
|
||||
chown -R 108080:108080 /srv/sigmah/sigmah_conf
|
||||
lxchelper extract sigmah /srv/tomcat/webapps/sigmah/sigmah/images/header/org-default-logo.png /srv/sigmah/sigmah_data/files/logo.png
|
||||
install -o 108080 -g 108080 -m 750 -d ${SIGMAH_CONF}
|
||||
install -o 108080 -g 108080 -m 750 -d ${SIGMAH_DATA}/files
|
||||
install -o 108080 -g 108080 -m 750 -d ${SIGMAH_DATA}/archives
|
||||
envsubst <sigmah_conf/persistence.xml | install -o 108080 -g 108080 -m 640 /dev/stdin ${SIGMAH_CONF}/persistence.xml
|
||||
install -o 108080 -g 108080 -m 640 sigmah_conf/sigmah.properties ${SIGMAH_CONF}/sigmah.properties
|
||||
cp -p ${SIGMAH_LAYER}/srv/tomcat/webapps/sigmah/sigmah/images/header/org-default-logo.png ${SIGMAH_DATA}/files/logo.png
|
||||
|
||||
# Populate database
|
||||
export SIGMAH_ADMIN_USER=Admin
|
||||
export SIGMAH_ADMIN_EMAIL=admin@example.com
|
||||
export SIGMAH_ADMIN_PWD=$(head -c 12 /dev/urandom | base64 | tr -d '+/=')
|
||||
export SIGMAH_ADMIN_HASH=$(python3 -c "import bcrypt; print(bcrypt.hashpw('${SIGMAH_ADMIN_PWD}'.encode(), bcrypt.gensalt(prefix=b'2a')).decode())")
|
||||
lxc-execute sigmah -- cat /srv/sigmah-MinimumDataKit.sql | lxc-attach sigmah-postgres -- sh -c "PGPASSWORD=${SIGMAH_PWD} psql -U sigmah sigmah"
|
||||
lxc-execute sigmah -- cat /srv/sigmah-newOrganizationLaunchScript.sql | \
|
||||
spoc-container exec sigmah -- cat /srv/sigmah-MinimumDataKit.sql | spoc-container exec sigmah-postgres -- sh -c "PGPASSWORD=${SIGMAH_PWD} psql -U sigmah sigmah"
|
||||
spoc-container exec sigmah -- cat /srv/sigmah-newOrganizationLaunchScript.sql | \
|
||||
sed -e "s|§OrganizationName§|Demo organization|g" \
|
||||
-e "s|§OrganizationLogoFilename§|logo.png|g" \
|
||||
-e "s|§HeadquartersCountryCode§|CZ|g" \
|
||||
@ -39,13 +43,10 @@ lxc-execute sigmah -- cat /srv/sigmah-newOrganizationLaunchScript.sql | \
|
||||
-e "s|§UserFirstName§|${SIGMAH_ADMIN_USER}|g" \
|
||||
-e "s|§UserLocale§|en|g" \
|
||||
-e "s|\$2a\$10\$pMcTA1p9fefR8U9NoOPei.H0eq/TbbdSF27M0tn9iDWBrA4JHeCDC|${SIGMAH_ADMIN_HASH}|" \
|
||||
| lxc-attach sigmah-postgres -- sh -c "PGPASSWORD=${SIGMAH_PWD} psql -U sigmah sigmah"
|
||||
|
||||
# Install config update script
|
||||
cp update-conf.sh /srv/sigmah/update-conf.sh
|
||||
| spoc-container exec sigmah-postgres -- sh -c "PGPASSWORD=${SIGMAH_PWD} psql -U sigmah sigmah"
|
||||
|
||||
# Stop services required for setup
|
||||
service lxc-sigmah-postgres stop
|
||||
spoc-container stop sigmah-postgres
|
||||
|
||||
# Register application
|
||||
vmmgr register-app sigmah sigmah "${SIGMAH_ADMIN_EMAIL}" "${SIGMAH_ADMIN_PWD}"
|
||||
|
@ -1,27 +0,0 @@
|
||||
{
|
||||
"version": "2.0.2-190620",
|
||||
"meta": {
|
||||
"title": "Sigmah",
|
||||
"desc-cs": "Finanční řízení sbírek",
|
||||
"desc-en": "Donation management",
|
||||
"license": "GPL"
|
||||
},
|
||||
"containers": {
|
||||
"sigmah": {
|
||||
"image": "sigmah_2.0.2-190620",
|
||||
"depends": [
|
||||
"sigmah-postgres"
|
||||
],
|
||||
"mounts": [
|
||||
["DIR", "/srv/sigmah/sigmah_conf", "/srv/sigmah/conf"],
|
||||
["DIR", "/srv/sigmah/sigmah_data", "/srv/sigmah/data"]
|
||||
]
|
||||
},
|
||||
"sigmah-postgres": {
|
||||
"image": "postgres_11.3.0-190620",
|
||||
"mounts": [
|
||||
["DIR", "/srv/sigmah/postgres_data", "/var/lib/postgresql"]
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
@ -2,7 +2,7 @@
|
||||
set -ev
|
||||
|
||||
# Remove persistent data
|
||||
rm -rf /srv/sigmah
|
||||
rm -rf "${VOLUMES_DIR}/sigmah"
|
||||
|
||||
# Unregister application
|
||||
vmmgr unregister-app sigmah
|
||||
|
Loading…
Reference in New Issue
Block a user