2018-01-08 15:06:11 +01:00
|
|
|
#!/bin/sh
|
2018-10-28 16:04:11 +01:00
|
|
|
set -ev
|
2017-06-29 21:12:51 +02:00
|
|
|
|
2019-10-05 15:27:14 +02:00
|
|
|
# Create Postgres instance
|
|
|
|
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
|
2017-10-07 22:30:39 +02:00
|
|
|
|
2017-06-30 18:17:07 +02:00
|
|
|
# Populate database
|
2019-06-05 18:55:15 +02:00
|
|
|
export SEEDDMS_PWD=$(head -c 18 /dev/urandom | base64 | tr -d '+/=')
|
2019-11-30 22:11:38 +01:00
|
|
|
service lxc-seeddms-postgres start
|
2019-10-05 15:27:14 +02:00
|
|
|
envsubst <createdb.sql | lxc-attach -u 5432 -g 5432 seeddms-postgres -- psql
|
|
|
|
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
|
2018-01-08 15:06:11 +01:00
|
|
|
|
|
|
|
# Copy existing files into persistent storage
|
2019-12-07 15:52:09 +01:00
|
|
|
lxchelper extract seeddms /srv/seeddms/conf /srv/seeddms/seeddms_conf
|
|
|
|
lxchelper extract seeddms /srv/seeddms/data /srv/seeddms/seeddms_data
|
2017-06-30 18:17:07 +02:00
|
|
|
|
|
|
|
# Configure SeedDMS
|
2019-10-05 15:27:14 +02:00
|
|
|
envsubst <seeddms_conf/settings.xml >/srv/seeddms/seeddms_conf/settings.xml
|
2017-09-16 21:35:44 +02:00
|
|
|
export SEEDDMS_ADMIN_USER=admin
|
2019-06-05 18:55:15 +02:00
|
|
|
export SEEDDMS_ADMIN_PWD=$(head -c 12 /dev/urandom | base64 | tr -d '+/=')
|
2017-09-16 21:35:44 +02:00
|
|
|
export SEEDDMS_ADMIN_EMAIL=admin@example.com
|
2019-10-05 15:27:14 +02:00
|
|
|
envsubst <adminpwd.sql | lxc-attach -u 5432 -g 5432 seeddms-postgres -- psql seeddms
|
2019-10-14 07:59:06 +02:00
|
|
|
chown -R 108080:108080 /srv/seeddms/seeddms_conf
|
2018-09-14 09:02:16 +02:00
|
|
|
|
2018-09-20 15:45:00 +02:00
|
|
|
# Install config update script
|
2019-10-05 15:27:14 +02:00
|
|
|
cp update-conf.sh /srv/seeddms/update-conf.sh
|
2018-07-15 21:55:35 +02:00
|
|
|
|
2019-10-05 15:27:14 +02:00
|
|
|
# Stop services required for setup
|
2019-11-30 22:11:38 +01:00
|
|
|
service lxc-seeddms-postgres stop
|
2018-10-28 19:50:35 +01:00
|
|
|
|
2018-11-03 15:53:51 +01:00
|
|
|
# Register application
|
2019-02-26 21:12:41 +01:00
|
|
|
vmmgr register-app seeddms dms "${SEEDDMS_ADMIN_USER}" "${SEEDDMS_ADMIN_PWD}"
|