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
|
|
|
|
2018-10-26 15:02:11 +02:00
|
|
|
cd $(realpath $(dirname "${0}"))/install
|
2017-06-29 21:12:51 +02:00
|
|
|
|
2018-01-23 21:27:18 +01:00
|
|
|
# Check prerequisites
|
2018-09-14 09:02:16 +02:00
|
|
|
[ ! -e /run/openrc/started/postgres ] && service postgres start && STOP_POSTGRES=1
|
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 '+/=')
|
2018-10-25 22:22:36 +02:00
|
|
|
envsubst <createdb.sql | lxc-attach -u 5432 -g 5432 postgres -- psql
|
2018-09-14 09:02:16 +02:00
|
|
|
cat /var/lib/lxc/seeddms/seeddms/srv/seeddms/create_tables-postgres.sql | lxc-attach postgres -- sh -c "PGPASSWORD=${SEEDDMS_PWD} psql seeddms seeddms"
|
2018-10-25 22:22:36 +02:00
|
|
|
cat custom.sql | lxc-attach -u 5432 -g 5432 postgres -- psql seeddms
|
2018-01-08 15:06:11 +01:00
|
|
|
|
|
|
|
# Copy existing files into persistent storage
|
2018-01-15 20:06:06 +01:00
|
|
|
mkdir -p /srv/seeddms/conf /srv/seeddms/data
|
2018-09-14 18:13:11 +02:00
|
|
|
cp -rp /var/lib/lxc/seeddms/seeddms/srv/seeddms/conf/. /srv/seeddms/conf
|
|
|
|
cp -rp /var/lib/lxc/seeddms/seeddms/srv/seeddms/data/. /srv/seeddms/data
|
2018-01-08 15:06:11 +01:00
|
|
|
chown -R 8010:8010 /srv/seeddms/data
|
2017-06-30 18:17:07 +02:00
|
|
|
|
|
|
|
# Configure SeedDMS
|
2018-10-25 22:22:36 +02:00
|
|
|
envsubst <srv/seeddms/conf/settings.xml >/srv/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
|
2018-10-25 22:22:36 +02:00
|
|
|
envsubst <adminpwd.sql | lxc-attach -u 5432 -g 5432 postgres -- psql seeddms
|
2018-02-08 09:39:58 +01:00
|
|
|
chown -R 8010:8010 /srv/seeddms/conf
|
2017-06-29 21:12:51 +02:00
|
|
|
|
2018-09-20 15:45:00 +02:00
|
|
|
# Install cron job
|
2019-06-05 18:15:34 +02:00
|
|
|
cp etc/periodic/15min/seeddms /etc/periodic/15min/seeddms
|
2018-09-20 15:45:00 +02:00
|
|
|
|
2018-09-14 09:02:16 +02:00
|
|
|
# Install service
|
2018-10-25 22:22:36 +02:00
|
|
|
cp etc/init.d/seeddms /etc/init.d/seeddms
|
2018-09-14 09:02:16 +02:00
|
|
|
rc-update -u
|
|
|
|
|
2018-09-20 15:45:00 +02:00
|
|
|
# Install config update script
|
2018-10-25 22:22:36 +02:00
|
|
|
cp srv/seeddms/update-conf.sh /srv/seeddms/update-conf.sh
|
2018-07-15 21:55:35 +02:00
|
|
|
|
|
|
|
# Stop services required for build
|
2018-09-14 09:02:16 +02:00
|
|
|
[ ! -z ${STOP_POSTGRES} ] && service 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}"
|