Spotter-VM/lxc-apps/seeddms/install.sh

44 lines
1.8 KiB
Bash
Raw Normal View History

2018-01-08 15:06:11 +01:00
#!/bin/sh
2018-10-28 16:04:11 +01:00
set -ev
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-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-10-05 15:27:14 +02:00
mkdir -p /srv/seeddms/seeddms_conf /srv/seeddms/seeddms)data
chown 108080:108080 /srv/seeddms/conf
chown 108080:108080 /srv/seeddms/data
2019-10-05 15:27:14 +02:00
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
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
chown -R 108080:108080 /srv/seeddms/seeddms_conf
2018-09-14 09:02:16 +02:00
# Install config update script
2019-10-05 15:27:14 +02:00
cp update-conf.sh /srv/seeddms/update-conf.sh
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
# Register application
2019-02-26 21:12:41 +01:00
vmmgr register-app seeddms dms "${SEEDDMS_ADMIN_USER}" "${SEEDDMS_ADMIN_PWD}"