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

41 lines
1.7 KiB
Bash
Raw Permalink Normal View History

2018-01-08 15:06:11 +01:00
#!/bin/sh
2018-10-28 16:04:11 +01:00
set -ev
2020-03-23 10:11:16 +01:00
# Volumes
POSTGRES_DATA="${VOLUMES_DIR}/seeddms/postgres_data"
SEEDDMS_DATA="${VOLUMES_DIR}/seeddms/seeddms_data"
SEEDDMS_CONF="${VOLUMES_DIR}/seeddms/seeddms_conf"
SEEDDMS_LAYER="${LAYERS_DIR}/seeddms_6.0.14-210106"
2020-03-23 10:11:16 +01:00
2019-10-05 15:27:14 +02:00
# Create Postgres instance
2020-03-23 10:11:16 +01:00
install -o 105432 -g 105432 -m 700 -d ${POSTGRES_DATA}
spoc-container exec seeddms-postgres -- initdb -D /var/lib/postgresql
2019-10-05 15:27:14 +02:00
# Configure Postgres
2020-03-23 10:11:16 +01:00
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
2019-12-10 18:56:15 +01:00
# Copy existing files into persistent storage
2020-03-23 10:11:16 +01:00
cp -rp ${SEEDDMS_LAYER}/srv/seeddms/conf ${SEEDDMS_CONF}
cp -rp ${SEEDDMS_LAYER}/srv/seeddms/data ${SEEDDMS_DATA}
2019-12-10 18:56:15 +01: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 '+/=')
2020-03-23 10:11:16 +01:00
spoc-container start seeddms-postgres
envsubst <createdb.sql | spoc-container exec seeddms-postgres -- psql
2020-03-23 11:32:11 +01:00
cat ${SEEDDMS_LAYER}/srv/seeddms/seeddms/install/create_tables-postgres.sql | spoc-container exec seeddms-postgres -- sh -c "PGPASSWORD=${SEEDDMS_PWD} psql seeddms seeddms"
2020-03-23 10:11:16 +01:00
cat custom.sql | spoc-container exec seeddms-postgres -- psql seeddms
2018-01-08 15:06:11 +01:00
2017-06-30 18:17:07 +02:00
# Configure SeedDMS
2020-03-23 10:11:16 +01:00
envsubst <seeddms_conf/settings.xml | install -o 108080 -g 108080 -m 640 /dev/stdin ${SEEDDMS_CONF}/settings.xml
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 '+/=')
export SEEDDMS_ADMIN_EMAIL="admin@example.com"
2020-03-23 10:11:16 +01:00
envsubst <adminpwd.sql | spoc-container exec seeddms-postgres -- psql seeddms
2019-10-05 15:27:14 +02:00
# Stop services required for setup
2020-03-23 10:11:16 +01:00
spoc-container stop seeddms-postgres
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}"