Spotter-VM/lxc-apps/ecogis/install.sh
2019-10-03 20:09:58 +02:00

31 lines
967 B
Bash
Executable File

#!/bin/sh
set -ev
cd $(realpath $(dirname "${0}"))/install
# Create Postgres instance
mkdir -p /srv/ecogis/postgres_data
chown -R 105432:105432 /srv/ecogis/postgres_data
chmod 700 /srv/ecogis/postgres_data
lxc-execute -n ecogis-postgres -- initdb -D /var/lib/postgresql
# Configure Postgres
cp postgres_data/postgresql.conf /srv/ecogis/postgres_data/postgresql.conf
cp postgres_data/pg_hba.conf /srv/ecogis/postgres_data/pg_hba.conf
# Populate database
export ECOGIS_PWD=$(head -c 18 /dev/urandom | base64 | tr -d '+/=')
service ecogis-postgres start
envsubst <createdb.sql | lxc-attach -u 5432 -g 5432 ecogis-postgres -- psql
# Configure EcoGIS
mkdir -p /srv/ecogis/ecogis_conf /srv/ecogis/ecogis_data
envsubst <srv/ecogis/conf/config.php >/srv/ecogis/conf/config.php
chown -R 108020:108020 /srv/ecogis/ecogis_conf /srv/ecogis/ecogis_data
# Stop services required for build
service ecogis-postgres stop
# Register application
vmmgr register-app ecogis ecogis