Rework SeedDMS

This commit is contained in:
Disassembler 2019-10-05 15:27:14 +02:00
parent 826b244bae
commit 4391b33fbc
Signed by: Disassembler
GPG Key ID: 524BD33A0EE29499
8 changed files with 55 additions and 64 deletions

View File

@ -3,41 +3,45 @@ 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/seeddms/postgres_data
chown -R 105432:105432 /srv/seeddms/postgres_data
chmod 700 /srv/seeddms/postgres_data
lxc-execute -n seeddms-postgres -- initdb -D /var/lib/postgresql
# Configure Postgres
cp postgres_data/postgresql.conf /srv/seeddms/postgres_data/postgresql.conf
cp postgres_data/pg_hba.conf /srv/seeddms/postgres_data/pg_hba.conf
# Populate database # Populate database
export SEEDDMS_PWD=$(head -c 18 /dev/urandom | base64 | tr -d '+/=') export SEEDDMS_PWD=$(head -c 18 /dev/urandom | base64 | tr -d '+/=')
envsubst <createdb.sql | lxc-attach -u 5432 -g 5432 postgres -- psql service seeddms-postgres start
cat /var/lib/lxc/seeddms/seeddms/srv/seeddms/create_tables-postgres.sql | lxc-attach postgres -- sh -c "PGPASSWORD=${SEEDDMS_PWD} psql seeddms seeddms" envsubst <createdb.sql | lxc-attach -u 5432 -g 5432 seeddms-postgres -- psql
cat custom.sql | lxc-attach -u 5432 -g 5432 postgres -- psql seeddms lxc-execute seeddms -- cat /srv/seeddms/create_tables-postgres.sql | lxc-attach seeddms-postgres -- sh -c "PGPASSWORD=${SEEDDMS_PWD} psql seeddms seeddms"
cat custom.sql | lxc-attach -u 5432 -g 5432 seeddms-postgres -- psql seeddms
# Copy existing files into persistent storage # Copy existing files into persistent storage
mkdir -p /srv/seeddms/conf /srv/seeddms/data mkdir -p /srv/seeddms/seeddms_conf /srv/seeddms/seeddms)data
cp -rp /var/lib/lxc/seeddms/seeddms/srv/seeddms/conf/. /srv/seeddms/conf chown 108010:108010 /srv/seeddms/conf
cp -rp /var/lib/lxc/seeddms/seeddms/srv/seeddms/data/. /srv/seeddms/data chown 108010:108010 /srv/seeddms/data
chown -R 8010:8010 /srv/seeddms/data lxc-execute seeddms -- tar -cC /srv/seeddms/conf . | tar -xC /srv/seeddms/seeddms_conf
lxc-execute seeddms -- tar -cC /srv/seeddms/data . | tar -xC /srv/seeddms/seeddms_data
# Configure SeedDMS # Configure SeedDMS
envsubst <srv/seeddms/conf/settings.xml >/srv/seeddms/conf/settings.xml envsubst <seeddms_conf/settings.xml >/srv/seeddms/seeddms_conf/settings.xml
export SEEDDMS_ADMIN_USER=admin export SEEDDMS_ADMIN_USER=admin
export SEEDDMS_ADMIN_PWD=$(head -c 12 /dev/urandom | base64 | tr -d '+/=') export SEEDDMS_ADMIN_PWD=$(head -c 12 /dev/urandom | base64 | tr -d '+/=')
export SEEDDMS_ADMIN_EMAIL=admin@example.com export SEEDDMS_ADMIN_EMAIL=admin@example.com
envsubst <adminpwd.sql | lxc-attach -u 5432 -g 5432 postgres -- psql seeddms envsubst <adminpwd.sql | lxc-attach -u 5432 -g 5432 seeddms-postgres -- psql seeddms
chown -R 8010:8010 /srv/seeddms/conf chown -R 108010:108010 /srv/seeddms/seeddms_conf
# Install cron job
cp etc/periodic/15min/seeddms /etc/periodic/15min/seeddms
# Install service
cp etc/init.d/seeddms /etc/init.d/seeddms
rc-update -u
# Install config update script # Install config update script
cp srv/seeddms/update-conf.sh /srv/seeddms/update-conf.sh cp update-conf.sh /srv/seeddms/update-conf.sh
# Stop services required for build # Stop services required for setup
[ ! -z ${STOP_POSTGRES} ] && service postgres stop service seeddms-postgres stop
# Register application # Register application
vmmgr register-app seeddms dms "${SEEDDMS_ADMIN_USER}" "${SEEDDMS_ADMIN_PWD}" vmmgr register-app seeddms dms "${SEEDDMS_ADMIN_USER}" "${SEEDDMS_ADMIN_PWD}"
# TODO: cron

View File

@ -1,23 +0,0 @@
#!/sbin/openrc-run
description="SeedDMS container"
depend() {
need postgres
}
start() {
lxc-start seeddms
}
start_post() {
vmmgr register-proxy seeddms
}
stop_pre() {
vmmgr unregister-proxy seeddms
}
stop() {
lxc-stop seeddms
}

View File

@ -1,5 +0,0 @@
#!/bin/sh
if [ -e /run/openrc/started/seeddms ]; then
lxc-attach -u 8010 -g 8010 seeddms -- /srv/seeddms/seeddms/utils/seeddms-indexer >/dev/null
fi

View File

@ -44,7 +44,4 @@ RUN EOF
rm -rf /srv/seeddms/data/conf /srv/seeddms/www/ext/example rm -rf /srv/seeddms/data/conf /srv/seeddms/www/ext/example
EOF EOF
MOUNT DIR /srv/seeddms/conf srv/seeddms/conf
MOUNT DIR /srv/seeddms/data srv/seeddms/data
CMD s6-svscan /etc/services.d CMD s6-svscan /etc/services.d

27
lxc-apps/seeddms/meta Normal file
View File

@ -0,0 +1,27 @@
{
"version": "5.1.9-190620",
"meta": {
"title": "SeedDMS",
"desc-cs": "Archiv dokumentace",
"desc-en": "Document management system",
"license": "GPL",
},
"containers": {
"seeddms": {
"image": "seeddms_5.1.9-190620",
"depends": [
"seeddms-postgres"
],
"mounts": [
["DIR", "/srv/seeddms/seeddms_conf", "/srv/seeddms/conf"],
["DIR", "/srv/seeddms/seeddms_data", "/srv/seeddms/data"]
]
},
"seeddms-postgres": {
"image": "postgis_11.3.0-190620",
"mounts": [
["DIR", "/srv/seeddms/postgres_data", "/var/lib/postgresql"]
]
}
}
}

View File

@ -1,17 +1,8 @@
#!/bin/sh #!/bin/sh
set -ev set -ev
# Remove cronjob # Remove persistent data
rm -f /etc/periodic/15min/seeddms rm -rf /srv/seeddms
# Remove service
rm -f /etc/init.d/seeddms
rc-update -u
# Drop database and user
[ ! -e /run/openrc/started/postgres ] && service postgres start && STOP_POSTGRES=1
echo 'DROP DATABASE IF EXISTS seeddms; DROP ROLE IF EXISTS seeddms;' | lxc-attach -u 5432 -g 5432 postgres -- psql
[ ! -z ${STOP_POSTGRES} ] && service postgres stop
# Unregister application # Unregister application
vmmgr unregister-app seeddms vmmgr unregister-app seeddms