Spotter-VM/seeddms/install.sh

46 lines
1.6 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
2018-10-26 15:02:11 +02:00
cd $(realpath $(dirname "${0}"))/install
# Check prerequisites
2018-09-14 09:02:16 +02:00
[ ! -e /run/openrc/started/postgres ] && service postgres start && STOP_POSTGRES=1
2017-06-30 18:17:07 +02:00
# Populate database
export SEEDDMS_PWD=$(head -c 18 /dev/urandom | base64)
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
export SEEDDMS_ADMIN_PWD=$(head -c 12 /dev/urandom | base64)
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
chown -R 8010:8010 /srv/seeddms/conf
# Install cron job
2018-10-25 22:22:36 +02:00
cp etc/periodic/hourly/seeddms /etc/periodic/hourly/seeddms
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
# Install config update script
2018-10-25 22:22:36 +02:00
cp srv/seeddms/update-conf.sh /srv/seeddms/update-conf.sh
# 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
# Register application
vmmgr register-app seeddms "${SEEDDMS_ADMIN_USER}" "${SEEDDMS_ADMIN_PWD}"
2018-10-28 19:50:35 +01:00
exit 0