Spotter-VM/lxc-apps/decidim/install.sh

63 lines
3.9 KiB
Bash
Raw Normal View History

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"
DECIDIM_LAYER="${LAYERS_DIR}/decidim_0.23.1-210118"
2020-03-17 09:18:13 +01:00
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
# Copy existing config files into persistent storage
cp -rp ${DECIDIM_LAYER}/srv/decidim-app/config ${DECIDIM_CONF}
2019-11-15 18:00:26 +01:00
# Configure Decidim
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
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
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'
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'
# spoc-container exec -u 8080 -g 8080 decidim -- sh -c 'cd /srv/decidim-app; bin/rails decidim_templates:install:migrations'
spoc-container exec -u 8080 -g 8080 decidim -- sh -c 'cd /srv/decidim-app; bin/rails decidim_calendar:install:migrations'
spoc-container exec -u 8080 -g 8080 decidim -- sh -c 'cd /srv/decidim-app; bin/rails decidim_comparative_stats:install:migrations'
spoc-container exec -u 8080 -g 8080 decidim -- sh -c 'cd /srv/decidim-app; bin/rails decidim_decidim_awesome:install:migrations'
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'
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
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}"