2018-01-08 15:06:11 +01:00
|
|
|
#!/bin/sh
|
2018-07-15 21:55:35 +02:00
|
|
|
set -e
|
2017-06-29 21:12:51 +02:00
|
|
|
|
2017-12-04 17:48:37 +01:00
|
|
|
SOURCE_DIR=$(realpath $(dirname "${0}"))/seeddms
|
2017-06-29 21:12:51 +02:00
|
|
|
|
2018-01-23 21:27:18 +01:00
|
|
|
# Check prerequisites
|
2018-02-02 17:10:32 +01:00
|
|
|
docker image ls | grep -q postfix || $(realpath $(dirname "${0}"))/postfix.sh
|
2018-01-23 21:27:18 +01:00
|
|
|
docker image ls | grep -q postgres || $(realpath $(dirname "${0}"))/postgres.sh
|
2018-04-29 20:48:57 +02:00
|
|
|
service postgres start
|
2018-01-23 21:27:18 +01:00
|
|
|
|
2018-01-08 15:06:11 +01:00
|
|
|
# Build Docker container
|
|
|
|
docker build -t seeddms ${SOURCE_DIR}
|
2018-04-29 20:48:57 +02:00
|
|
|
cp ${SOURCE_DIR}/etc/init.d/seeddms /etc/init.d/seeddms
|
|
|
|
rc-update -u
|
2017-10-07 22:30:39 +02:00
|
|
|
|
2017-06-30 18:17:07 +02:00
|
|
|
# Populate database
|
2017-09-16 14:38:50 +02:00
|
|
|
export SEEDDMS_PWD=$(head -c 18 /dev/urandom | base64)
|
2018-01-08 15:06:11 +01:00
|
|
|
envsubst <${SOURCE_DIR}/createdb.sql | docker exec -i postgres psql
|
2018-01-24 15:55:47 +01:00
|
|
|
docker run --rm seeddms cat /srv/seeddms/create_tables-postgres.sql | docker exec -i -e PGPASSWORD=${SEEDDMS_PWD} postgres psql seeddms seeddms
|
2018-08-05 08:29:56 +02:00
|
|
|
cat ${SOURCE_DIR}/custom.sql | docker exec -i -e PGPASSWORD=${SEEDDMS_PWD} postgres psql seeddms 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-05-05 22:53:42 +02:00
|
|
|
docker run --rm -v /srv/seeddms/conf:/mnt/conf seeddms cp -rp /srv/seeddms/conf/. /mnt/conf
|
|
|
|
docker run --rm -v /srv/seeddms/data:/mnt/data seeddms cp -rp /srv/seeddms/data/. /mnt/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-01-08 15:06:11 +01:00
|
|
|
envsubst <${SOURCE_DIR}/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-01-08 15:06:11 +01:00
|
|
|
envsubst <${SOURCE_DIR}/adminpwd.sql | docker exec -i postgres psql seeddms
|
2018-02-08 09:39:58 +01:00
|
|
|
chown -R 8010:8010 /srv/seeddms/conf
|
2018-09-03 17:24:48 +02:00
|
|
|
vm-appmgr update-login seeddms "${SEEDDMS_ADMIN_USER}" "${SEEDDMS_ADMIN_PWD}"
|
2017-06-29 21:12:51 +02:00
|
|
|
|
2017-10-07 23:09:08 +02:00
|
|
|
# Install cron job
|
2018-01-08 15:06:11 +01:00
|
|
|
cp ${SOURCE_DIR}/etc/periodic/hourly/seeddms /etc/periodic/hourly/seeddms
|
2018-07-15 21:55:35 +02:00
|
|
|
|
|
|
|
# Stop services required for build
|
|
|
|
service postgres stop
|