#!/bin/sh set -ev cd $(realpath $(dirname "${0}"))/install # 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/crisiscleanup_conf/database.yml cp crisiscleanup_conf/boot.rb /srv/crisiscleanup/crisiscleanup_conf/boot.rb cp crisiscleanup_conf/initializers/devise.rb /srv/crisiscleanup/crisiscleanup_conf/initializers/devise.rb cp crisiscleanup_conf/environments/production.rb /srv/crisiscleanup/crisiscleanup_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}"