2019-11-15 18:00:26 +01:00
|
|
|
#!/bin/sh
|
|
|
|
set -ev
|
|
|
|
|
2020-03-17 09:18:13 +01:00
|
|
|
# Volumes
|
|
|
|
POSTGRES_DATA="${VOLUMES_DIR}/decidim/postgres_data"
|
|
|
|
DECIDIM_CONF="${VOLUMES_DIR}/decidim/decidim_conf"
|
|
|
|
DECIDIM_DATA="${VOLUMES_DIR}/decidim/decidim_data"
|
|
|
|
|
2019-11-15 18:00:26 +01:00
|
|
|
# Create Postgres instance
|
2020-03-17 09:18:13 +01:00
|
|
|
install -o 105432 -g 105432 -m 700 -d ${POSTGRES_DATA}
|
|
|
|
spoc-container exec decidim-postgres -- initdb -D /var/lib/postgresql
|
2019-11-15 18:00:26 +01:00
|
|
|
|
|
|
|
# Configure Postgres
|
2020-03-17 09:18:13 +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
|
2019-11-15 18:00:26 +01:00
|
|
|
|
|
|
|
# Create database
|
|
|
|
export DECIDIM_PWD=$(head -c 18 /dev/urandom | base64 | tr -d '+/=')
|
2020-03-17 09:18:13 +01:00
|
|
|
spoc-container start decidim-postgres
|
|
|
|
envsubst <createdb.sql | spoc-container exec decidim-postgres -- psql
|
2019-11-15 18:00:26 +01:00
|
|
|
|
|
|
|
# Configure Decidim
|
2021-02-06 13:49:55 +01:00
|
|
|
install -o 108080 -g 108080 -m 700 -d ${DECIDIM_CONF}
|
|
|
|
install -o 108080 -g 108080 -m 700 -d ${DECIDIM_CONF}/initializers
|
2020-11-21 09:25:40 +01:00
|
|
|
install -o 108080 -g 108080 -m 700 -d ${DECIDIM_DATA}/migrate
|
2020-03-17 09:44:39 +01:00
|
|
|
install -o 108080 -g 108080 -m 700 -d ${DECIDIM_DATA}/storage
|
|
|
|
install -o 108080 -g 108080 -m 700 -d ${DECIDIM_DATA}/uploads
|
2020-11-21 09:25:40 +01:00
|
|
|
export DECIDIM_SECRET=$(spoc-container exec -u 8080 -g 8080 decidim -- sh -c 'cd /srv/decidim-app; bin/rake secret')
|
2020-03-17 09:18:13 +01:00
|
|
|
install -o 108080 -g 108080 -m 640 decidim_conf/initializers/decidim.rb ${DECIDIM_CONF}/initializers/decidim.rb
|
|
|
|
envsubst <decidim_conf/application.yml | install -o 108080 -g 108080 -m 640 /dev/stdin ${DECIDIM_CONF}/application.yml
|
2019-11-15 18:00:26 +01:00
|
|
|
|
|
|
|
# Populate database
|
2020-11-21 09:25:40 +01:00
|
|
|
spoc-container exec -u 8080 -g 8080 decidim -- sh -c 'cd /srv/decidim-app; bin/rails decidim:upgrade'
|
|
|
|
spoc-container exec -u 8080 -g 8080 decidim -- sh -c 'cd /srv/decidim-app; bin/rails generate delayed_job:active_record'
|
2021-01-16 20:32:12 +01:00
|
|
|
spoc-container exec -u 8080 -g 8080 decidim -- sh -c 'cd /srv/decidim-app; bin/rails decidim_conferences:install:migrations'
|
|
|
|
spoc-container exec -u 8080 -g 8080 decidim -- sh -c 'cd /srv/decidim-app; bin/rails decidim_consultations:install:migrations'
|
|
|
|
spoc-container exec -u 8080 -g 8080 decidim -- sh -c 'cd /srv/decidim-app; bin/rails decidim_initiatives:install:migrations'
|
2021-01-18 18:42:00 +01:00
|
|
|
# spoc-container exec -u 8080 -g 8080 decidim -- sh -c 'cd /srv/decidim-app; bin/rails decidim_templates:install:migrations'
|
2021-01-11 12:37:44 +01:00
|
|
|
spoc-container exec -u 8080 -g 8080 decidim -- sh -c 'cd /srv/decidim-app; bin/rails decidim_calendar:install:migrations'
|
2021-01-18 17:58:14 +01:00
|
|
|
spoc-container exec -u 8080 -g 8080 decidim -- sh -c 'cd /srv/decidim-app; bin/rails decidim_comparative_stats:install:migrations'
|
2021-01-11 12:37:44 +01:00
|
|
|
spoc-container exec -u 8080 -g 8080 decidim -- sh -c 'cd /srv/decidim-app; bin/rails decidim_decidim_awesome:install:migrations'
|
2021-01-30 13:21:37 +01:00
|
|
|
# spoc-container exec -u 8080 -g 8080 decidim -- sh -c 'cd /srv/decidim-app; bin/rails decidim_favorites:install:migrations'
|
|
|
|
# spoc-container exec -u 8080 -g 8080 decidim -- sh -c 'cd /srv/decidim-app; bin/rails decidim_feedback:install:migrations'
|
|
|
|
# spoc-container exec -u 8080 -g 8080 decidim -- sh -c 'cd /srv/decidim-app; bin/rails decidim_ideas:install:migrations'
|
2021-01-11 12:37:44 +01:00
|
|
|
spoc-container exec -u 8080 -g 8080 decidim -- sh -c 'cd /srv/decidim-app; bin/rails decidim_ldap:install:migrations'
|
|
|
|
spoc-container exec -u 8080 -g 8080 decidim -- sh -c 'cd /srv/decidim-app; bin/rails decidim_navbar_links:install:migrations'
|
|
|
|
spoc-container exec -u 8080 -g 8080 decidim -- sh -c 'cd /srv/decidim-app; bin/rails decidim_navigation_maps:install:migrations'
|
|
|
|
spoc-container exec -u 8080 -g 8080 decidim -- sh -c 'cd /srv/decidim-app; bin/rails decidim_time_tracker:install:migrations'
|
|
|
|
spoc-container exec -u 8080 -g 8080 decidim -- sh -c 'cd /srv/decidim-app; bin/rails redirector_engine:install:migrations'
|
|
|
|
spoc-container exec -u 8080 -g 8080 decidim -- sh -c 'cd /srv/decidim-app; bin/rails decidim_url_aliases:install:migrations'
|
2020-03-17 09:18:13 +01:00
|
|
|
spoc-container exec -u 8080 -g 8080 decidim -- sh -c 'cd /srv/decidim-app; bin/rails db:migrate'
|
2021-01-11 12:37:44 +01:00
|
|
|
spoc-container exec -u 8080 -g 8080 decidim -- sh -c 'cd /srv/decidim-app; bin/rails url_aliases:generate:reserved_paths'
|
2019-11-15 18:00:26 +01:00
|
|
|
|
|
|
|
# Create admin account
|
2020-04-10 11:21:39 +02:00
|
|
|
export DECIDIM_ADMIN_EMAIL="admin@example.com"
|
2019-11-15 18:00:26 +01:00
|
|
|
export DECIDIM_ADMIN_PWD=$(head -c 12 /dev/urandom | base64 | tr -d '+/=')
|
2020-03-17 09:18:13 +01:00
|
|
|
envsubst <adminpwd.rb | spoc-container exec -u 8080 -g 8080 decidim -- sh -c 'cd /srv/decidim-app; bin/rails console -e production'
|
2019-11-15 18:00:26 +01:00
|
|
|
|
|
|
|
# Stop services required for setup
|
2020-03-17 09:44:39 +01:00
|
|
|
spoc-container stop decidim-postgres
|
2019-11-15 18:00:26 +01:00
|
|
|
|
|
|
|
# Register application
|
|
|
|
vmmgr register-app decidim decidim "${DECIDIM_ADMIN_EMAIL}" "${DECIDIM_ADMIN_PWD}"
|