#!/bin/sh set -ev cd $(realpath $(dirname "${0}"))/install # Check prerequisites [ ! -e /run/openrc/started/postgres ] && service postgres start && STOP_POSTGRES=1 # Create database export CRISISCLEANUP_PWD=$(head -c 18 /dev/urandom | base64) envsubst /srv/crisiscleanup/conf/database.yml cp srv/crisiscleanup/conf/boot.rb /srv/crisiscleanup/conf/boot.rb cp srv/crisiscleanup/conf/initializers/devise.rb /srv/crisiscleanup/conf/initializers/devise.rb cp srv/crisiscleanup/conf/environments/production.rb /srv/crisiscleanup/conf/environments/production.rb vmmgr update-login crisiscleanup "${CRISISCLEANUP_ADMIN_EMAIL}" "${CRISISCLEANUP_ADMIN_PWD}" # Populate database envsubst /var/lib/lxc/crisiscleanup/crisiscleanup/srv/crisiscleanup/db/seeds.rb lxc-execute crisiscleanup -- rake db:schema:load lxc-execute crisiscleanup -- rake db:seed # Install service cp etc/init.d/crisiscleanup /etc/init.d/crisiscleanup rc-update -u # Install config update script cp srv/crisiscleanup/update-conf.sh /srv/crisiscleanup/update-conf.sh # Stop services required for setup [ ! -z ${STOP_POSTGRES} ] && service postgres stop