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

29 lines
936 B
Bash
Executable File

#!/bin/sh
set -ev
# 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 lxc-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 <ecogis_conf/config.php >/srv/ecogis/ecogis_conf/config.php
chown -R 108080:108080 /srv/ecogis/ecogis_conf /srv/ecogis/ecogis_data
# Stop services required for setup
service lxc-ecogis-postgres stop
# Register application
vmmgr register-app ecogis ecogis