Make SAMBRO SPOC-compatible
This commit is contained in:
parent
caf30e9958
commit
102761efac
@ -34,6 +34,13 @@ envsubst <masterUsers.csv | install -o 108080 -g 108080 -m 640 /dev/stdin ${SAHA
|
|||||||
# Populate database
|
# 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'
|
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'
|
||||||
|
|
||||||
|
# Set "production values" (increases performance) only if the DEBUG environment variable is not set
|
||||||
|
if [ ${DEBUG:-0} -eq 0 ]; then
|
||||||
|
sed -i 's/settings.base.migrate = True/settings.base.migrate = False/' ${SAHANA_CONF}/000_config.py
|
||||||
|
sed -i 's/settings.base.debug = True/settings.base.debug = False/' ${SAHANA_CONF}/000_config.py
|
||||||
|
sed -i 's/#settings.base.prepopulate = 0/settings.base.prepopulate = 0/' ${SAHANA_CONF}/000_config.py
|
||||||
|
fi
|
||||||
|
|
||||||
# Stop services required for setup
|
# Stop services required for setup
|
||||||
spoc-container stop sahana-demo-postgres
|
spoc-container stop sahana-demo-postgres
|
||||||
|
|
||||||
|
30
lxc-apps/sambro/app
Normal file
30
lxc-apps/sambro/app
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
{
|
||||||
|
"version": "0.0.1-200313",
|
||||||
|
"meta": {
|
||||||
|
"title": "Sahana Eden - SAMBRO",
|
||||||
|
"desc-cs": "Řízení humanítární činnosti - Centrum hlášení a výstrah",
|
||||||
|
"desc-en": "Management of humanitarian activities - Reporting and alerting center",
|
||||||
|
"license": "GPL"
|
||||||
|
},
|
||||||
|
"containers": {
|
||||||
|
"sambro": {
|
||||||
|
"image": "sahana_0.0.1-200313",
|
||||||
|
"depends": [
|
||||||
|
"sambro-postgres"
|
||||||
|
],
|
||||||
|
"mounts": {
|
||||||
|
"sambro/sahana_conf": "srv/web2py/applications/eden/models",
|
||||||
|
"sambro/sahana_data/SAMBRO": "srv/web2py/applications/eden/modules/templates/SAMBRO",
|
||||||
|
"sambro/sahana_data/databases": "srv/web2py/applications/eden/databases",
|
||||||
|
"sambro/sahana_data/uploads": "srv/web2py/applications/eden/uploads",
|
||||||
|
"sambro/sahana_data/masterUsers.csv": "srv/web2py/applications/eden/modules/templates/default/users/masterUsers.csv:file"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"sambro-postgres": {
|
||||||
|
"image": "postgis_3.0.0-200313",
|
||||||
|
"mounts": {
|
||||||
|
"sambro/postgres_data": "var/lib/postgresql"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,52 +1,51 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
set -ev
|
set -ev
|
||||||
|
|
||||||
|
# Volumes
|
||||||
|
POSTGRES_DATA="${VOLUMES_DIR}/sambro/postgres_data"
|
||||||
|
SAHANA_DATA="${VOLUMES_DIR}/sambro/sahana_data"
|
||||||
|
SAHANA_CONF="${VOLUMES_DIR}/sambro/sahana_conf"
|
||||||
|
|
||||||
# Create Postgres instance
|
# Create Postgres instance
|
||||||
mkdir -p /srv/sambro/postgres_data
|
install -o 105432 -g 105432 -m 700 -d ${POSTGRES_DATA}
|
||||||
chown -R 105432:105432 /srv/sambro/postgres_data
|
spoc-container exec sambro-postgres -- initdb -D /var/lib/postgresql
|
||||||
chmod 700 /srv/sambro/postgres_data
|
|
||||||
lxc-execute -n sambro-postgres -- initdb -D /var/lib/postgresql
|
|
||||||
|
|
||||||
# Configure Postgres
|
# Configure Postgres
|
||||||
cp postgres_data/postgresql.conf /srv/sambro/postgres_data/postgresql.conf
|
install -o 105432 -g 105432 -m 600 postgres_data/postgresql.conf ${POSTGRES_DATA}/postgresql.conf
|
||||||
cp postgres_data/pg_hba.conf /srv/sambro/postgres_data/pg_hba.conf
|
install -o 105432 -g 105432 -m 600 postgres_data/pg_hba.conf ${POSTGRES_DATA}/pg_hba.conf
|
||||||
|
|
||||||
# Create PostgreSQL user and database
|
# Create PostgreSQL user and database
|
||||||
export SAMBRO_PWD=$(head -c 18 /dev/urandom | base64 | tr -d '+/=')
|
export SAMBRO_PWD=$(head -c 18 /dev/urandom | base64 | tr -d '+/=')
|
||||||
service lxc-sambro-postgres start
|
spoc-container start sambro-postgres
|
||||||
envsubst <createdb.sql | lxc-attach -u 5432 -g 5432 sambro-postgres -- psql
|
envsubst <createdb.sql | spoc-container exec sambro-postgres -- psql
|
||||||
|
|
||||||
# Prepare persistent directory structure
|
# Prepare persistent directory structure
|
||||||
mkdir -p /srv/sambro/sahana_data/databases /srv/sambro/sahana_data/uploads
|
install -o 108080 -g 108080 -m 750 -d ${SAHANA_DATA}/databases
|
||||||
chown -R 108080:108080 /srv/sambro/sahana_data
|
install -o 108080 -g 108080 -m 750 -d ${SAHANA_DATA}/uploads
|
||||||
lxchelper extract sambro /srv/web2py/applications/eden/models /srv/sambro/sahana_conf
|
cp -rp ${LAYERS_DIR}/sahana_0.0.1-200313/srv/web2py/applications/eden/models ${SAHANA_CONF}
|
||||||
lxchelper extract sambro /srv/web2py/applications/eden/modules/templates/SAMBRO /srv/sambro/sahana_data/SAMBRO
|
cp -rp ${LAYERS_DIR}/sahana_0.0.1-200313/srv/web2py/applications/eden/modules/templates/SAMBRO ${SAHANA_DATA}/SAMBRO
|
||||||
|
|
||||||
# Configure SAMBRO
|
# Configure SAMBRO
|
||||||
export SAMBRO_HMAC=$(head -c 18 /dev/urandom | base64 | tr -d '+/=')
|
export SAMBRO_HMAC=$(head -c 18 /dev/urandom | base64 | tr -d '+/=')
|
||||||
export SAMBRO_ADMIN_USER=admin@example.com
|
export SAMBRO_ADMIN_USER=admin@example.com
|
||||||
export SAMBRO_ADMIN_PWD=$(head -c 12 /dev/urandom | base64 | tr -d '+/=')
|
export SAMBRO_ADMIN_PWD=$(head -c 12 /dev/urandom | base64 | tr -d '+/=')
|
||||||
envsubst <sahana_conf/000_config.py >/srv/sambro/sahana_conf/000_config.py
|
envsubst <sahana_conf/000_config.py | install -o 108080 -g 108080 -m 640 /dev/stdin ${SAHANA_CONF}/000_config.py
|
||||||
envsubst <masterUsers.csv >/srv/sambro/sahana_data/masterUsers.csv
|
envsubst <sahana_data/masterUsers.csv | install -o 108080 -g 108080 -m 640 /dev/stdin ${SAHANA_DATA}/masterUsers.csv
|
||||||
cp sahana_conf/00_settings.py /srv/sambro/sahana_conf/00_settings.py
|
install -o 108080 -g 108080 -m 640 sahana_conf/00_settings.py ${SAHANA_CONF}/00_settings.py
|
||||||
cp sahana_data/SAMBRO/config.py /srv/sambro/sahana_data/SAMBRO/config.py
|
install -o 108080 -g 108080 -m 640 sahana_data/SAMBRO/config.py ${SAHANA_DATA}/SAMBRO/config.py
|
||||||
chown -R 108080:108080 /srv/sambro/sahana_conf /srv/sambro/sahana_data
|
|
||||||
|
|
||||||
# Populate database
|
# Populate database
|
||||||
lxc-execute -u 8080 -g 8080 sambro -- sh -c 'cd /srv/web2py; ./web2py.py -S eden -M -R applications/eden/static/scripts/tools/noop.py'
|
spoc-container exec -u sahana sambro -- sh -c 'cd /srv/web2py; ./web2py.py -S eden -M -R applications/eden/static/scripts/tools/noop.py'
|
||||||
|
|
||||||
# Set "production values" (increases performance) only if the DEBUG environment variable is not set
|
# Set "production values" (increases performance) only if the DEBUG environment variable is not set
|
||||||
if [ ${DEBUG:-0} -eq 0 ]; then
|
if [ ${DEBUG:-0} -eq 0 ]; then
|
||||||
sed -i 's/settings.base.migrate = True/settings.base.migrate = False/' /srv/sambro/conf/000_config.py
|
sed -i 's/settings.base.migrate = True/settings.base.migrate = False/' ${SAHANA_CONF}/000_config.py
|
||||||
sed -i 's/settings.base.debug = True/settings.base.debug = False/' /srv/sambro/conf/000_config.py
|
sed -i 's/settings.base.debug = True/settings.base.debug = False/' ${SAHANA_CONF}/000_config.py
|
||||||
sed -i 's/#settings.base.prepopulate = 0/settings.base.prepopulate = 0/' /srv/sambro/conf/000_config.py
|
sed -i 's/#settings.base.prepopulate = 0/settings.base.prepopulate = 0/' ${SAHANA_CONF}/000_config.py
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Install config update script
|
|
||||||
cp update-conf.sh /srv/sambro/update-conf.sh
|
|
||||||
|
|
||||||
# Stop services required for setup
|
# Stop services required for setup
|
||||||
service lxc-sambro-postgres stop
|
spoc-container stop sambro-postgres
|
||||||
|
|
||||||
# Register application
|
# Register application
|
||||||
vmmgr register-app sambro sambro "${SAMBRO_ADMIN_USER}" "${SAMBRO_ADMIN_PWD}"
|
vmmgr register-app sambro sambro "${SAMBRO_ADMIN_USER}" "${SAMBRO_ADMIN_PWD}"
|
||||||
|
@ -1,29 +0,0 @@
|
|||||||
{
|
|
||||||
"version": "0.0.1-190620",
|
|
||||||
"meta": {
|
|
||||||
"title": "Sahana Eden - SAMBRO",
|
|
||||||
"desc-cs": "Řízení humanítární činnosti - Centrum hlášení a výstrah",
|
|
||||||
"desc-en": "Management of humanitarian activities - Reporting and alerting center",
|
|
||||||
"license": "GPL"
|
|
||||||
},
|
|
||||||
"containers": {
|
|
||||||
"sambro": {
|
|
||||||
"image": "sahana_0.0.1-190620",
|
|
||||||
"depends": [
|
|
||||||
"sambro-postgres"
|
|
||||||
],
|
|
||||||
"mounts": [
|
|
||||||
["DIR", "/srv/sambro/sahana_conf", "/srv/web2py/applications/eden/models"],
|
|
||||||
["DIR", "/srv/sambro/sahana_data/SAMBRO", "/srv/web2py/applications/eden/modules/templates/SAMBRO"],
|
|
||||||
["DIR", "/srv/sambro/sahana_data/databases", "/srv/web2py/applications/eden/databases"],
|
|
||||||
["DIR", "/srv/sambro/sahana_data/uploads", "/srv/web2py/applications/eden/uploads"]
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"sambro-postgres": {
|
|
||||||
"image": "postgis_2.5.1-190620",
|
|
||||||
"mounts": [
|
|
||||||
["DIR", "/srv/sambro/postgres_data", "/var/lib/postgresql"]
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -2,7 +2,7 @@
|
|||||||
set -ev
|
set -ev
|
||||||
|
|
||||||
# Remove persistent data
|
# Remove persistent data
|
||||||
rm -rf /srv/sambro
|
rm -rf "${VOLUMES_DIR}/sambro"
|
||||||
|
|
||||||
# Unregister application
|
# Unregister application
|
||||||
vmmgr unregister-app sambro
|
vmmgr unregister-app sambro
|
||||||
|
Loading…
Reference in New Issue
Block a user