#!/bin/sh set -ev # Create Postgres instance mkdir -p /srv/crisiscleanup/postgres_data chown -R 105432:105432 /srv/crisiscleanup/postgres_data chmod 700 /srv/crisiscleanup/postgres_data lxc-execute -n crisiscleanup-postgres -- initdb -D /var/lib/postgresql # Configure Postgres cp postgres_data/postgresql.conf /srv/crisiscleanup/postgres_data/postgresql.conf cp postgres_data/pg_hba.conf /srv/crisiscleanup/postgres_data/pg_hba.conf # Create database export CRISISCLEANUP_PWD=$(head -c 18 /dev/urandom | base64 | tr -d '+/=') service crisiscleanup-postgres start envsubst /srv/crisiscleanup/cc_conf/database.yml cp cc_conf/boot.rb /srv/crisiscleanup/cc_conf/boot.rb cp cc_conf/initializers/devise.rb /srv/crisiscleanup/cc_conf/initializers/devise.rb cp cc_conf/environments/production.rb /srv/crisiscleanup/cc_conf/environments/production.rb # Populate database #envsubst /var/lib/lxc/crisiscleanup/crisiscleanup/srv/crisiscleanup/db/seeds.rb # TODO bud volat User.create! zvlast nebo vyresit jinak lxc-execute crisiscleanup -- rake db:schema:load lxc-execute crisiscleanup -- rake db:seed # Install config update script cp update-conf.sh /srv/crisiscleanup/update-conf.sh # Stop services required for setup service crisiscleanup-postgres stop # Register application vmmgr register-app crisiscleanup cc "${CRISISCLEANUP_ADMIN_EMAIL}" "${CRISISCLEANUP_ADMIN_PWD}"