#!/bin/sh set -ev # Create Postgres instance mkdir -p /srv/pandora/postgres_data chown -R 105432:105432 /srv/pandora/postgres_data chmod 700 /srv/pandora/postgres_data lxc-execute -n pandora-postgres -- initdb -D /var/lib/postgresql # Configure Postgres cp postgres_data/postgresql.conf /srv/pandora/postgres_data/postgresql.conf cp postgres_data/pg_hba.conf /srv/pandora/postgres_data/pg_hba.conf # Create PostgreSQL user and database export PANDORA_PWD=$(head -c 18 /dev/urandom | base64 | tr -d '+/=') service lxc-pandora-postgres start envsubst /srv/pandora/pandora_conf/local_settings.py chown -R 108080:108080 /srv/pandora/pandora_conf # Populate database lxc-execute pandora -- /srv/pandora/pandora/manage.py migrate --noinput lxc-execute pandora -- /srv/pandora/pandora/manage.py sqlfindindex lxc-execute pandora -- /srv/pandora/pandora/manage.py sync_itemsort lxc-execute pandora -- /srv/pandora/pandora/manage.py sync_documentsort # Create admin account export PANDORA_ADMIN_USER=admin export PANDORA_ADMIN_EMAIL=admin@example.com export PANDORA_ADMIN_PWD=$(head -c 12 /dev/urandom | base64 | tr -d '+/=') export PANDORA_ADMIN_HASH=$(lxc-execute pandora -- sh -c "DJANGO_SETTINGS_MODULE=srv.pandora.pandora.settings python3 -c \"from django.contrib.auth.hashers import make_password; print(make_password('${PANDORA_ADMIN_PWD}'))\"") envsubst