From caf30e9958de4c998633e313bcbdc71c0bf42d6d Mon Sep 17 00:00:00 2001 From: Disassembler Date: Sun, 22 Mar 2020 20:45:07 +0100 Subject: [PATCH] Make Sahana-Demo SPOC-compatible --- lxc-apps/sahana-demo/app | 29 +++++++++++++++++ lxc-apps/sahana-demo/install.sh | 54 ++++++++----------------------- lxc-apps/sahana-demo/meta | 29 ----------------- lxc-apps/sahana-demo/uninstall.sh | 2 +- 4 files changed, 44 insertions(+), 70 deletions(-) create mode 100644 lxc-apps/sahana-demo/app delete mode 100644 lxc-apps/sahana-demo/meta diff --git a/lxc-apps/sahana-demo/app b/lxc-apps/sahana-demo/app new file mode 100644 index 0000000..7250d33 --- /dev/null +++ b/lxc-apps/sahana-demo/app @@ -0,0 +1,29 @@ +{ + "version": "0.0.1-200313", + "meta": { + "title": "Sahana Eden - Demo", + "desc-cs": "Řízení humanítární činnosti - Demo instance", + "desc-en": "Management of humanitarian activities - Demo instance", + "license": "GPL" + }, + "containers": { + "sahana-demo": { + "image": "sahana_0.0.1-200313", + "depends": [ + "sahana-demo-postgres" + ], + "mounts": { + "sahana-demo/sahana_conf": "srv/web2py/applications/eden/models", + "sahana-demo/sahana_data/default": "srv/web2py/applications/eden/modules/templates/default", + "sahana-demo/sahana_data/databases": "srv/web2py/applications/eden/databases", + "sahana-demo/sahana_data/uploads": "srv/web2py/applications/eden/uploads" + } + }, + "sahana-demo-postgres": { + "image": "postgis_3.0.0-200313", + "mounts": { + "sahana-demo/postgres_data": "var/lib/postgresql" + } + } + } +} diff --git a/lxc-apps/sahana-demo/install.sh b/lxc-apps/sahana-demo/install.sh index 8c710c6..d6a54a7 100755 --- a/lxc-apps/sahana-demo/install.sh +++ b/lxc-apps/sahana-demo/install.sh @@ -1,67 +1,41 @@ #!/bin/sh set -ev -# Create containers -spoc-container create \ - -m sahana-demo/postgres_data:var/lib/postgresql \ - sahana-demo-postgres postgis_3.0.0-200207 -spoc-container create \ - -d sahana-demo-postgres \ - -m sahana-demo/sahana_conf:srv/web2py/applications/eden/models \ - -m sahana-demo/sahana_data/default:srv/web2py/applications/eden/modules/templates/default \ - -m sahana-demo/sahana_data/databases:srv/web2py/applications/eden/databases \ - -m sahana-demo/sahana_data/uploads:srv/web2py/applications/eden/uploads \ - sahana-demo sahana_0.0.1-200207 - -# TODO: Populate from spoc -LAYER_DIR="/var/lib/spoc/layers" -VOLUME_DIR="/var/lib/spoc/volumes/sahana-demo" -POSTGRES_UID=70 -POSTGRES_GID=70 -POSTGRES_NSUID=100070 -POSTGRES_NSGID=100070 -SAHANA_UID=103 -SAHANA_GID=104 -SAHANA_NSUID=100103 -SAHANA_NSGID=100104 +# Volumes +POSTGRES_DATA="${VOLUMES_DIR}/sahana-demo/postgres_data" +SAHANA_DATA="${VOLUMES_DIR}/sahana-demo/sahana_data" +SAHANA_CONF="${VOLUMES_DIR}/sahana-demo/sahana_conf" # Create Postgres instance -mkdir -p ${VOLUME_DIR}/postgres_data -chown -R ${POSTGRES_NSUID}:${POSTGRES_NSGID} ${VOLUME_DIR}/postgres_data -chmod 700 ${VOLUME_DIR}/postgres_data +install -o 105432 -g 105432 -m 700 -d ${POSTGRES_DATA} spoc-container exec sahana-demo-postgres -- initdb -D /var/lib/postgresql # Configure Postgres -cp postgres_data/postgresql.conf ${VOLUME_DIR}/postgres_data/postgresql.conf -cp postgres_data/pg_hba.conf ${VOLUME_DIR}/postgres_data/pg_hba.conf - +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 # Create PostgreSQL user and database export SAHANADEMO_PWD=$(head -c 18 /dev/urandom | base64 | tr -d '+/=') spoc-container start sahana-demo-postgres envsubst ${VOLUME_DIR}/sahana_conf/000_config.py -envsubst ${VOLUME_DIR}/sahana_data/default/users/masterUsers.csv -chown -R ${SAHANA_NSUID}:${SAHANA_NSGID} ${VOLUME_DIR}/sahana_conf ${VOLUME_DIR}/sahana_data +envsubst