Rework Sigmah
This commit is contained in:
parent
4391b33fbc
commit
4ac414c691
@ -3,23 +3,32 @@ set -ev
|
|||||||
|
|
||||||
cd $(realpath $(dirname "${0}"))/install
|
cd $(realpath $(dirname "${0}"))/install
|
||||||
|
|
||||||
# Check prerequisites
|
# Create Postgres instance
|
||||||
[ ! -e /run/openrc/started/postgres ] && service postgres start && STOP_POSTGRES=1
|
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
|
||||||
|
|
||||||
|
# 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
|
||||||
|
|
||||||
# Create database
|
# Create database
|
||||||
export SIGMAH_PWD=$(head -c 18 /dev/urandom | base64 | tr -d '+/=')
|
export SIGMAH_PWD=$(head -c 18 /dev/urandom | base64 | tr -d '+/=')
|
||||||
envsubst <createdb.sql | lxc-attach -u 5432 -g 5432 postgres -- psql
|
service sigmah-postgres start
|
||||||
|
envsubst <createdb.sql | lxc-attach -u 5432 -g 5432 sigmah-postgres -- psql
|
||||||
|
|
||||||
# Configure Sigmah
|
# Configure Sigmah
|
||||||
mkdir -p /srv/sigmah/conf /srv/sigmah/data/files /srv/sigmah/data/archives
|
mkdir -p /srv/sigmah/sigmah_conf /srv/sigmah/sigmah_data/files /srv/sigmah/sigmah_data/archives
|
||||||
chown -R 8011:8011 /srv/sigmah/data
|
chown -R 108011:108011 /srv/sigmah/sigmah_data
|
||||||
envsubst <srv/sigmah/conf/persistence.xml >/srv/sigmah/conf/persistence.xml
|
envsubst <sigmah_conf/persistence.xml >/srv/sigmah/sigmah_conf/persistence.xml
|
||||||
cp srv/sigmah/conf/sigmah.properties /srv/sigmah/conf/sigmah.properties
|
cp sigmah_conf/sigmah.properties /srv/sigmah/sigmah_conf/sigmah.properties
|
||||||
cp /var/lib/lxc/sigmah/sigmah/srv/tomcat/webapps/sigmah/sigmah/images/header/org-default-logo.png /srv/sigmah/data/files/logo.png
|
chown -R 108011:108011 /srv/sigmah/sigmah_conf
|
||||||
|
lxc-execute sigmah -- cat /srv/tomcat/webapps/sigmah/sigmah/images/header/org-default-logo.png >/srv/sigmah/sigmah_data/files/logo.png
|
||||||
|
|
||||||
# Populate database
|
# Populate database
|
||||||
cp -f /var/lib/lxc/sigmah/sigmah/srv/sigmah-MinimumDataKit.sql /tmp/
|
lxc-execute sigmah -- cat /srv/sigmah-MinimumDataKit.sql >/tmp/sigmah-MinimumDataKit.sql
|
||||||
cp -f /var/lib/lxc/sigmah/sigmah/srv/sigmah-newOrganizationLaunchScript.sql /tmp/
|
lxc-execute sigmah -- cat /srv/sigmah-newOrganizationLaunchScript.sql >/tmp/sigmah-newOrganizationLaunchScript.sql
|
||||||
export SIGMAH_ADMIN_USER=Admin
|
export SIGMAH_ADMIN_USER=Admin
|
||||||
export SIGMAH_ADMIN_EMAIL=admin@example.com
|
export SIGMAH_ADMIN_EMAIL=admin@example.com
|
||||||
export SIGMAH_ADMIN_PWD=$(head -c 12 /dev/urandom | base64 | tr -d '+/=')
|
export SIGMAH_ADMIN_PWD=$(head -c 12 /dev/urandom | base64 | tr -d '+/=')
|
||||||
@ -32,19 +41,17 @@ sed -i "s|§UserName§|${SIGMAH_ADMIN_USER}|g" /tmp/sigmah-newOrganizationLaunch
|
|||||||
sed -i "s|§UserFirstName§|${SIGMAH_ADMIN_USER}|g" /tmp/sigmah-newOrganizationLaunchScript.sql
|
sed -i "s|§UserFirstName§|${SIGMAH_ADMIN_USER}|g" /tmp/sigmah-newOrganizationLaunchScript.sql
|
||||||
sed -i "s|§UserLocale§|en|g" /tmp/sigmah-newOrganizationLaunchScript.sql
|
sed -i "s|§UserLocale§|en|g" /tmp/sigmah-newOrganizationLaunchScript.sql
|
||||||
sed -i "s|\$2a\$10\$pMcTA1p9fefR8U9NoOPei.H0eq/TbbdSF27M0tn9iDWBrA4JHeCDC|${SIGMAH_ADMIN_HASH}|" /tmp/sigmah-newOrganizationLaunchScript.sql
|
sed -i "s|\$2a\$10\$pMcTA1p9fefR8U9NoOPei.H0eq/TbbdSF27M0tn9iDWBrA4JHeCDC|${SIGMAH_ADMIN_HASH}|" /tmp/sigmah-newOrganizationLaunchScript.sql
|
||||||
cat /tmp/sigmah-MinimumDataKit.sql | lxc-attach postgres -- sh -c "PGPASSWORD=${SIGMAH_PWD} psql -U sigmah sigmah"
|
cat /tmp/sigmah-MinimumDataKit.sql | lxc-attach sigmah-postgres -- sh -c "PGPASSWORD=${SIGMAH_PWD} psql -U sigmah sigmah"
|
||||||
cat /tmp/sigmah-newOrganizationLaunchScript.sql | lxc-attach postgres -- sh -c "PGPASSWORD=${SIGMAH_PWD} psql -U sigmah sigmah"
|
cat /tmp/sigmah-newOrganizationLaunchScript.sql | lxc-attach sigmah-postgres -- sh -c "PGPASSWORD=${SIGMAH_PWD} psql -U sigmah sigmah"
|
||||||
rm -f /tmp/sigmah-MinimumDataKit.sql /tmp/sigmah-newOrganizationLaunchScript.sql
|
rm -f /tmp/sigmah-MinimumDataKit.sql /tmp/sigmah-newOrganizationLaunchScript.sql
|
||||||
|
|
||||||
# Install service
|
|
||||||
cp etc/init.d/sigmah /etc/init.d/sigmah
|
|
||||||
rc-update -u
|
|
||||||
|
|
||||||
# Install config update script
|
# Install config update script
|
||||||
cp srv/sigmah/update-conf.sh /srv/sigmah/update-conf.sh
|
cp update-conf.sh /srv/sigmah/update-conf.sh
|
||||||
|
|
||||||
# Stop services required for build
|
# Stop services required for setup
|
||||||
[ ! -z ${STOP_POSTGRES} ] && service postgres stop
|
service sigmah-postgres stop
|
||||||
|
|
||||||
# Register application
|
# Register application
|
||||||
vmmgr register-app sigmah sigmah "${SIGMAH_ADMIN_EMAIL}" "${SIGMAH_ADMIN_PWD}"
|
vmmgr register-app sigmah sigmah "${SIGMAH_ADMIN_EMAIL}" "${SIGMAH_ADMIN_PWD}"
|
||||||
|
|
||||||
|
# TODO: SQL skripty jako soucast installu?
|
||||||
|
@ -1,23 +0,0 @@
|
|||||||
#!/sbin/openrc-run
|
|
||||||
|
|
||||||
description="Sigmah container"
|
|
||||||
|
|
||||||
depend() {
|
|
||||||
need postgres
|
|
||||||
}
|
|
||||||
|
|
||||||
start() {
|
|
||||||
lxc-start sigmah
|
|
||||||
}
|
|
||||||
|
|
||||||
start_post() {
|
|
||||||
vmmgr register-proxy sigmah
|
|
||||||
}
|
|
||||||
|
|
||||||
stop_pre() {
|
|
||||||
vmmgr unregister-proxy sigmah
|
|
||||||
}
|
|
||||||
|
|
||||||
stop() {
|
|
||||||
lxc-stop sigmah
|
|
||||||
}
|
|
0
lxc-apps/sigmah/install/srv/sigmah/update-conf.sh → lxc-apps/sigmah/install/update-conf.sh
Executable file → Normal file
0
lxc-apps/sigmah/install/srv/sigmah/update-conf.sh → lxc-apps/sigmah/install/update-conf.sh
Executable file → Normal file
@ -32,10 +32,6 @@ EOF
|
|||||||
|
|
||||||
COPY lxc
|
COPY lxc
|
||||||
|
|
||||||
MOUNT DIR /srv/sigmah/data srv/sigmah/data
|
|
||||||
MOUNT FILE /srv/sigmah/conf/persistence.xml srv/tomcat/webapps/sigmah/WEB-INF/classes/META-INF/persistence.xml
|
|
||||||
MOUNT FILE /srv/sigmah/conf/sigmah.properties srv/tomcat/webapps/sigmah/WEB-INF/classes/sigmah.properties
|
|
||||||
|
|
||||||
USER 8011 8011
|
USER 8011 8011
|
||||||
WORKDIR /srv/tomcat
|
WORKDIR /srv/tomcat
|
||||||
CMD catalina.sh run
|
CMD catalina.sh run
|
||||||
|
27
lxc-apps/sigmah/meta
Normal file
27
lxc-apps/sigmah/meta
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
{
|
||||||
|
"version": "5.1.9-190620",
|
||||||
|
"meta": {
|
||||||
|
"title": "Sigmah",
|
||||||
|
"desc-cs": "Finanční řízení sbírek",
|
||||||
|
"desc-en": "Donation management",
|
||||||
|
"license": "GPL",
|
||||||
|
},
|
||||||
|
"containers": {
|
||||||
|
"sigmah": {
|
||||||
|
"image": "sigmah_5.1.9-190620",
|
||||||
|
"depends": [
|
||||||
|
"sigmah-postgres"
|
||||||
|
],
|
||||||
|
"mounts": [
|
||||||
|
["DIR", "/srv/sigmah/sigmah_conf", "/srv/sigmah/conf"],
|
||||||
|
["DIR", "/srv/sigmah/sigmah_data", "/srv/sigmah/data"]
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"sigmah-postgres": {
|
||||||
|
"image": "postgis_11.3.0-190620",
|
||||||
|
"mounts": [
|
||||||
|
["DIR", "/srv/sigmah/postgres_data", "/var/lib/postgresql"]
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,14 +1,8 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
set -ev
|
set -ev
|
||||||
|
|
||||||
# Remove service
|
# Remove persistent data
|
||||||
rm -f /etc/init.d/sigmah
|
rm -rf /srv/sigmah
|
||||||
rc-update -u
|
|
||||||
|
|
||||||
# Drop database and user
|
|
||||||
[ ! -e /run/openrc/started/postgres ] && service postgres start && STOP_POSTGRES=1
|
|
||||||
echo 'DROP DATABASE IF EXISTS sigmah; DROP ROLE IF EXISTS sigmah;' | lxc-attach -u 5432 -g 5432 postgres -- psql
|
|
||||||
[ ! -z ${STOP_POSTGRES} ] && service postgres stop
|
|
||||||
|
|
||||||
# Unregister application
|
# Unregister application
|
||||||
vmmgr unregister-app sigmah
|
vmmgr unregister-app sigmah
|
||||||
|
Loading…
Reference in New Issue
Block a user