#!/bin/sh set -ev # Create Postgres instance mkdir -p /srv/decidim/postgres_data chown -R 105432:105432 /srv/decidim/postgres_data chmod 700 /srv/decidim/postgres_data lxc-execute -n decidim-postgres -- initdb -D /var/lib/postgresql # Configure Postgres cp postgres_data/postgresql.conf /srv/decidim/postgres_data/postgresql.conf cp postgres_data/pg_hba.conf /srv/decidim/postgres_data/pg_hba.conf # Create database export DECIDIM_PWD=$(head -c 18 /dev/urandom | base64 | tr -d '+/=') service decidim-postgres start envsubst /srv/decidim/decidim_conf/application.yml # Populate database lxc-execute decidim -- RAILS_ENV=production bin/rails db:create db:migrate # Create admin account export DECIDIM_ADMIN_EMAIL=admin@example.com export DECIDIM_ADMIN_PWD=$(head -c 12 /dev/urandom | base64 | tr -d '+/=') #lxc-execute decidim -- bin/rails console -e production #user = Decidim::System::Admin.new(email: "admin@example.org", password: "P8vDKAc3FdEte9Hw", password_confirmation: "P8vDKAc3FdEte9Hw") #user.save! # Install config update script cp update-conf.sh /srv/decidim/update-conf.sh # Stop services required for setup service decidim-postgres stop # Register application vmmgr register-app decidim decidim "${DECIDIM_ADMIN_EMAIL}" "${DECIDIM_ADMIN_PWD}"