diff --git a/lxc-apps/pandora/install.sh b/lxc-apps/pandora/install.sh index d91c628..4d20831 100755 --- a/lxc-apps/pandora/install.sh +++ b/lxc-apps/pandora/install.sh @@ -3,37 +3,44 @@ set -ev cd $(realpath $(dirname "${0}"))/install -# Check prerequisites -[ ! -e /run/openrc/started/postgres ] && service postgres start && STOP_POSTGRES=1 -[ ! -e /run/openrc/started/rabbitmq ] && service rabbitmq start && STOP_RABBITMQ=1 +# 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 '+/=') -envsubst /srv/pandora/conf/local_settings.py - -# Set "production values" (increases performance) only if the DEBUG environment variable is not set -if [ ${DEBUG:-0} -eq 0 ]; then - sed -i 's/DEBUG = True/DEBUG = False/' /srv/pandora/conf/local_settings.py + lxc-execute pandora -- cat /srv/pandora/pandora/config.pandora.jsonc >/srv/pandora/pandora_conf/config.jsonc fi +cp pandora_conf/gunicorn_config.py /srv/pandora/pandora_conf/gunicorn_config.py +envsubst /srv/pandora/pandora_conf/local_settings.py +chown -R 108002:108002 /srv/pandora/pandora_conf # Populate database lxc-execute pandora -- /srv/pandora/pandora/manage.py migrate --noinput @@ -46,18 +53,14 @@ 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