2018-01-18 13:39:39 +01:00
|
|
|
#!/bin/sh
|
2018-10-28 16:04:11 +01:00
|
|
|
set -ev
|
2017-09-11 17:06:40 +02:00
|
|
|
|
2020-03-22 13:44:46 +01:00
|
|
|
# Volumes
|
|
|
|
POSTGRES_DATA="${VOLUMES_DIR}/pandora/postgres_data"
|
|
|
|
RABBITMQ_DATA="${VOLUMES_DIR}/pandora/rabbitmq_data"
|
|
|
|
PANDORA_CONF="${VOLUMES_DIR}/pandora/pandora_conf"
|
|
|
|
PANDORA_DATA="${VOLUMES_DIR}/pandora/pandora_data"
|
|
|
|
|
2019-10-05 15:18:36 +02:00
|
|
|
# Create Postgres instance
|
2020-03-22 13:44:46 +01:00
|
|
|
install -o 105432 -g 105432 -m 700 -d ${POSTGRES_DATA}
|
|
|
|
spoc-container exec pandora-postgres -- initdb -D /var/lib/postgresql
|
2019-10-05 15:18:36 +02:00
|
|
|
|
|
|
|
# Configure Postgres
|
2020-03-22 13:44:46 +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
|
2017-09-11 17:06:40 +02:00
|
|
|
|
|
|
|
# Create PostgreSQL user and database
|
2019-06-05 18:55:15 +02:00
|
|
|
export PANDORA_PWD=$(head -c 18 /dev/urandom | base64 | tr -d '+/=')
|
2020-03-22 13:44:46 +01:00
|
|
|
spoc-container start pandora-postgres
|
|
|
|
envsubst <createdb.sql | spoc-container exec pandora-postgres -- psql
|
2019-10-05 15:18:36 +02:00
|
|
|
|
|
|
|
# Create RabbitMQ directory structure
|
2020-03-22 13:44:46 +01:00
|
|
|
install -o 105672 -g 105672 -m 750 -d ${RABBITMQ_DATA}
|
2017-09-11 17:06:40 +02:00
|
|
|
|
2020-03-22 13:44:46 +01:00
|
|
|
# Configure RabbitMQ virtualhost
|
2019-06-05 18:55:15 +02:00
|
|
|
export PANDORA_RABBIT_PWD=$(head -c 18 /dev/urandom | base64 | tr -d '+/=')
|
2020-03-22 13:44:46 +01:00
|
|
|
spoc-container start pandora-rabbitmq
|
|
|
|
spoc-container exec pandora-rabbitmq -- rabbitmqctl add_user pandora ${PANDORA_RABBIT_PWD}
|
|
|
|
spoc-container exec pandora-rabbitmq -- rabbitmqctl add_vhost /pandora
|
|
|
|
spoc-container exec pandora-rabbitmq -- rabbitmqctl set_permissions -p /pandora pandora ".*" ".*" ".*"
|
2017-09-11 17:06:40 +02:00
|
|
|
|
|
|
|
# Configure Pandora
|
2020-03-22 13:44:46 +01:00
|
|
|
install -o 108080 -g 108080 -m 750 -d ${PANDORA_CONF}
|
2020-03-22 14:54:16 +01:00
|
|
|
install -o 108080 -g 108080 -m 755 -d ${PANDORA_DATA}
|
2020-03-22 13:44:46 +01:00
|
|
|
install -o 108080 -g 108080 -m 640 pandora_conf/config.jsonc ${PANDORA_CONF}/config.jsonc
|
|
|
|
install -o 108080 -g 108080 -m 640 pandora_conf/gunicorn_config.py ${PANDORA_CONF}/gunicorn_config.py
|
|
|
|
envsubst <pandora_conf/local_settings.py | install -o 108080 -g 108080 -m 640 /dev/stdin ${PANDORA_CONF}/local_settings.py
|
2017-11-29 21:27:11 +01:00
|
|
|
|
2017-09-11 17:06:40 +02:00
|
|
|
# Populate database
|
2020-03-22 13:44:46 +01:00
|
|
|
spoc-container exec pandora -- /srv/pandora/pandora/manage.py migrate --noinput
|
|
|
|
spoc-container exec pandora -- /srv/pandora/pandora/manage.py sqlfindindex
|
|
|
|
spoc-container exec pandora -- /srv/pandora/pandora/manage.py sync_itemsort
|
|
|
|
spoc-container exec pandora -- /srv/pandora/pandora/manage.py sync_documentsort
|
2017-09-11 17:06:40 +02:00
|
|
|
|
2017-09-17 22:09:56 +02:00
|
|
|
# Create admin account
|
2020-04-10 11:21:39 +02:00
|
|
|
export PANDORA_ADMIN_USER="admin"
|
|
|
|
export PANDORA_ADMIN_EMAIL="admin@example.com"
|
2019-06-05 18:55:15 +02:00
|
|
|
export PANDORA_ADMIN_PWD=$(head -c 12 /dev/urandom | base64 | tr -d '+/=')
|
2020-03-22 13:44:46 +01:00
|
|
|
export PANDORA_ADMIN_HASH=$(spoc-container exec pandora -- sh -c "cd /srv/pandora && DJANGO_SETTINGS_MODULE=pandora.settings python3 -c \"from django.contrib.auth.hashers import make_password; print(make_password('${PANDORA_ADMIN_PWD}'))\"")
|
|
|
|
envsubst <adminpwd.sql | spoc-container exec pandora-postgres -- psql pandora
|
2018-09-20 15:45:00 +02:00
|
|
|
|
2019-10-05 15:18:36 +02:00
|
|
|
# Stop services required for setup
|
2020-03-22 13:44:46 +01:00
|
|
|
spoc-container stop pandora-postgres
|
|
|
|
spoc-container stop pandora-rabbitmq
|
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 pandora pandora "${PANDORA_ADMIN_USER}" "${PANDORA_ADMIN_PWD}"
|
2020-04-10 11:21:39 +02:00
|
|
|
vmmgr register-prop pandora gmaps-api-key ""
|