2018-01-26 21:25:03 +01:00
|
|
|
#!/bin/sh
|
2018-10-28 16:04:11 +01:00
|
|
|
set -ev
|
2017-12-04 21:08:04 +01:00
|
|
|
|
2020-03-23 13:43:53 +01:00
|
|
|
# Volumes
|
|
|
|
POSTGRES_DATA="${VOLUMES_DIR}/sigmah/postgres_data"
|
|
|
|
SIGMAH_DATA="${VOLUMES_DIR}/sigmah/sigmah_data"
|
|
|
|
SIGMAH_CONF="${VOLUMES_DIR}/sigmah/sigmah_conf"
|
2020-04-04 00:17:24 +02:00
|
|
|
SIGMAH_LAYER="${LAYERS_DIR}/sigmah_2.0.2-200403"
|
2020-03-23 13:43:53 +01:00
|
|
|
|
2019-10-05 15:34:42 +02:00
|
|
|
# Create Postgres instance
|
2020-03-23 13:43:53 +01:00
|
|
|
install -o 105432 -g 105432 -m 700 -d ${POSTGRES_DATA}
|
|
|
|
spoc-container exec sigmah-postgres -- initdb -D /var/lib/postgresql
|
2019-10-05 15:34:42 +02:00
|
|
|
|
|
|
|
# Configure Postgres
|
2020-03-23 13:43:53 +01:00
|
|
|
install -o 105432 -g 105432 -m 600 postgres_data/postgresql.conf ${POSTGRES_DATA}/postgresql.conf
|
|
|
|
install -o 105432 -g 105432 -m 600 postgres_data/pg_hba.conf ${POSTGRES_DATA}/pg_hba.conf
|
2017-12-08 09:39:02 +01:00
|
|
|
|
2017-12-04 21:08:04 +01:00
|
|
|
# Create database
|
2019-06-05 18:55:15 +02:00
|
|
|
export SIGMAH_PWD=$(head -c 18 /dev/urandom | base64 | tr -d '+/=')
|
2020-03-23 13:43:53 +01:00
|
|
|
spoc-container start sigmah-postgres
|
|
|
|
envsubst <createdb.sql | spoc-container exec sigmah-postgres -- psql
|
2017-12-04 21:08:04 +01:00
|
|
|
|
|
|
|
# Configure Sigmah
|
2020-03-23 13:43:53 +01:00
|
|
|
install -o 108080 -g 108080 -m 750 -d ${SIGMAH_CONF}
|
2020-03-23 16:08:21 +01:00
|
|
|
install -o 108080 -g 108080 -m 750 -d ${SIGMAH_DATA}
|
2020-03-23 13:43:53 +01:00
|
|
|
install -o 108080 -g 108080 -m 750 -d ${SIGMAH_DATA}/files
|
|
|
|
install -o 108080 -g 108080 -m 750 -d ${SIGMAH_DATA}/archives
|
|
|
|
envsubst <sigmah_conf/persistence.xml | install -o 108080 -g 108080 -m 640 /dev/stdin ${SIGMAH_CONF}/persistence.xml
|
|
|
|
install -o 108080 -g 108080 -m 640 sigmah_conf/sigmah.properties ${SIGMAH_CONF}/sigmah.properties
|
|
|
|
cp -p ${SIGMAH_LAYER}/srv/tomcat/webapps/sigmah/sigmah/images/header/org-default-logo.png ${SIGMAH_DATA}/files/logo.png
|
2017-12-04 21:08:04 +01:00
|
|
|
|
|
|
|
# Populate database
|
2020-04-10 11:21:39 +02:00
|
|
|
export SIGMAH_ADMIN_USER="Admin"
|
|
|
|
export SIGMAH_ADMIN_EMAIL="admin@example.com"
|
2019-06-05 18:55:15 +02:00
|
|
|
export SIGMAH_ADMIN_PWD=$(head -c 12 /dev/urandom | base64 | tr -d '+/=')
|
2018-09-16 17:19:13 +02:00
|
|
|
export SIGMAH_ADMIN_HASH=$(python3 -c "import bcrypt; print(bcrypt.hashpw('${SIGMAH_ADMIN_PWD}'.encode(), bcrypt.gensalt(prefix=b'2a')).decode())")
|
2020-03-23 16:08:21 +01:00
|
|
|
cat ${SIGMAH_LAYER}/srv/sigmah-MinimumDataKit.sql | spoc-container exec sigmah-postgres -- sh -c "PGPASSWORD=${SIGMAH_PWD} psql -U sigmah sigmah"
|
|
|
|
sed -e "s|§OrganizationName§|Demo organization|g" \
|
|
|
|
-e "s|§OrganizationLogoFilename§|logo.png|g" \
|
|
|
|
-e "s|§HeadquartersCountryCode§|CZ|g" \
|
|
|
|
-e "s|§UserEmail§|${SIGMAH_ADMIN_EMAIL}|g" \
|
|
|
|
-e "s|§UserName§|${SIGMAH_ADMIN_USER}|g" \
|
|
|
|
-e "s|§UserFirstName§|${SIGMAH_ADMIN_USER}|g" \
|
|
|
|
-e "s|§UserLocale§|en|g" \
|
|
|
|
-e "s|\$2a\$10\$pMcTA1p9fefR8U9NoOPei.H0eq/TbbdSF27M0tn9iDWBrA4JHeCDC|${SIGMAH_ADMIN_HASH}|" \
|
|
|
|
${SIGMAH_LAYER}/srv/sigmah-newOrganizationLaunchScript.sql | spoc-container exec sigmah-postgres -- sh -c "PGPASSWORD=${SIGMAH_PWD} psql -U sigmah sigmah"
|
2018-09-20 15:45:00 +02:00
|
|
|
|
2019-10-05 15:34:42 +02:00
|
|
|
# Stop services required for setup
|
2020-03-23 13:43:53 +01:00
|
|
|
spoc-container stop sigmah-postgres
|
2018-10-28 19:50:35 +01:00
|
|
|
|
2018-11-03 15:53:51 +01:00
|
|
|
# Register application
|
2019-02-26 21:12:41 +01:00
|
|
|
vmmgr register-app sigmah sigmah "${SIGMAH_ADMIN_EMAIL}" "${SIGMAH_ADMIN_PWD}"
|