Make Sahana-Demo SPOC-compatible
This commit is contained in:
parent
9f8571f622
commit
caf30e9958
29
lxc-apps/sahana-demo/app
Normal file
29
lxc-apps/sahana-demo/app
Normal file
@ -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"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -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 <createdb.sql | spoc-container exec sahana-demo-postgres -- psql
|
||||
|
||||
# Prepare persistent directory structure
|
||||
mkdir -p ${VOLUME_DIR}/sahana_data/databases ${VOLUME_DIR}/sahana_data/uploads
|
||||
chown -R ${SAHANA_NSUID}:${SAHANA_NSGID} ${VOLUME_DIR}/sahana_data
|
||||
cp -rp ${LAYER_DIR}/sahana_0.0.1-200207/srv/web2py/applications/eden/models ${VOLUME_DIR}/sahana_conf
|
||||
cp -rp ${LAYER_DIR}/sahana_0.0.1-200207/srv/web2py/applications/eden/modules/templates/default ${VOLUME_DIR}/sahana_data/default
|
||||
install -o 108080 -g 108080 -m 750 -d ${SAHANA_DATA}/databases
|
||||
install -o 108080 -g 108080 -m 750 -d ${SAHANA_DATA}/uploads
|
||||
cp -rp ${LAYERS_DIR}/sahana_0.0.1-200313/srv/web2py/applications/eden/models ${SAHANA_CONF}
|
||||
cp -rp ${LAYERS_DIR}/sahana_0.0.1-200313/srv/web2py/applications/eden/modules/templates/default ${SAHANA_DATA}/default
|
||||
|
||||
# Configure Sahana
|
||||
export SAHANADEMO_HMAC=$(head -c 18 /dev/urandom | base64 | tr -d '+/=')
|
||||
export SAHANADEMO_ADMIN_USER=admin@example.com
|
||||
export SAHANADEMO_ADMIN_PWD=$(head -c 12 /dev/urandom | base64 | tr -d '+/=')
|
||||
envsubst <sahana_conf/000_config.py >${VOLUME_DIR}/sahana_conf/000_config.py
|
||||
envsubst <masterUsers.csv >${VOLUME_DIR}/sahana_data/default/users/masterUsers.csv
|
||||
chown -R ${SAHANA_NSUID}:${SAHANA_NSGID} ${VOLUME_DIR}/sahana_conf ${VOLUME_DIR}/sahana_data
|
||||
envsubst <sahana_conf/000_config.py | install -o 108080 -g 108080 -m 640 /dev/stdin ${SAHANA_CONF}/000_config.py
|
||||
envsubst <masterUsers.csv | install -o 108080 -g 108080 -m 640 /dev/stdin ${SAHANA_DATA}/default/users/masterUsers.csv
|
||||
|
||||
# Populate database
|
||||
spoc-container exec -u sahana sahana-demo -- sh -c 'cd /srv/web2py; ./web2py.py -S eden -M -R applications/eden/static/scripts/tools/noop.py'
|
||||
|
||||
# Install config update script
|
||||
cp update-conf.sh ${VOLUME_DIR}/update-conf.sh
|
||||
|
||||
# Stop services required for setup
|
||||
spoc-container stop sahana-demo-postgres
|
||||
|
||||
# Register application
|
||||
#vmmgr register-app sahana-demo sahana-demo "${SAHANADEMO_ADMIN_USER}" "${SAHANADEMO_ADMIN_PWD}"
|
||||
vmmgr register-app sahana-demo sahana-demo "${SAHANADEMO_ADMIN_USER}" "${SAHANADEMO_ADMIN_PWD}"
|
||||
|
@ -1,29 +0,0 @@
|
||||
{
|
||||
"version": "0.0.1-190620",
|
||||
"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-190620",
|
||||
"depends": [
|
||||
"sahana-demo-postgres"
|
||||
],
|
||||
"mounts": [
|
||||
["DIR", "/srv/sahana-demo/sahana_conf", "/srv/web2py/applications/eden/models"],
|
||||
["DIR", "/srv/sahana-demo/sahana_data/default", "/srv/web2py/applications/eden/modules/templates/default"],
|
||||
["DIR", "/srv/sahana-demo/sahana_data/databases", "/srv/web2py/applications/eden/databases"],
|
||||
["DIR", "/srv/sahana-demo/sahana_data/uploads", "/srv/web2py/applications/eden/uploads"]
|
||||
]
|
||||
},
|
||||
"sahana-demo-postgres": {
|
||||
"image": "postgis_2.5.1-190620",
|
||||
"mounts": [
|
||||
["DIR", "/srv/sahana-demo/postgres_data", "/var/lib/postgresql"]
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
@ -2,7 +2,7 @@
|
||||
set -ev
|
||||
|
||||
# Remove persistent data
|
||||
rm -rf /srv/sahana-demo
|
||||
rm -rf "${VOLUMES_DIR}/sahana-demo"
|
||||
|
||||
# Unregister application
|
||||
vmmgr unregister-app sahana-demo
|
||||
|
Loading…
Reference in New Issue
Block a user