Rework SAMBRO
This commit is contained in:
parent
985dd2998a
commit
9b18c94ddd
@ -2,8 +2,8 @@
|
||||
"version": "0.0.1-190620",
|
||||
"meta": {
|
||||
"title": "Sahana Eden - Demo",
|
||||
"desc-cs": "Řízení humanítární činnosti",
|
||||
"desc-en": "Management of humanitarian activities",
|
||||
"desc-cs": "Řízení humanítární činnosti - Demo instance",
|
||||
"desc-en": "Management of humanitarian activities - Demo instance",
|
||||
"license": "GPL",
|
||||
},
|
||||
"containers": {
|
||||
@ -13,8 +13,10 @@
|
||||
"sahana-demo-postgres"
|
||||
],
|
||||
"mounts": [
|
||||
["DIR", "/srv/sahana-demo/sahana_conf", "/srv/sahana/conf"],
|
||||
["DIR", "/srv/sahana-demo/sahana_data", "/srv/sahana/data"]
|
||||
["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": {
|
||||
|
@ -13,8 +13,10 @@
|
||||
"sahana-postgres"
|
||||
],
|
||||
"mounts": [
|
||||
["DIR", "/srv/sahana/sahana_conf", "/srv/sahana/conf"],
|
||||
["DIR", "/srv/sahana/sahana_data", "/srv/sahana/data"]
|
||||
["DIR", "/srv/sahana/sahana_conf", "/srv/web2py/applications/eden/models"],
|
||||
["DIR", "/srv/sahana/sahana_data/Spotter", "/srv/web2py/applications/eden/modules/templates/Spotter"],
|
||||
["DIR", "/srv/sahana/sahana_data/databases", "/srv/web2py/applications/eden/databases"],
|
||||
["DIR", "/srv/sahana/sahana_data/uploads", "/srv/web2py/applications/eden/uploads"]
|
||||
]
|
||||
},
|
||||
"sahana-postgres": {
|
||||
|
@ -3,29 +3,39 @@ set -ev
|
||||
|
||||
cd $(realpath $(dirname "${0}"))/install
|
||||
|
||||
# Check prerequisites
|
||||
[ ! -e /run/openrc/started/postgres ] && service postgres start && STOP_POSTGRES=1
|
||||
# Create Postgres instance
|
||||
mkdir -p /srv/sambro/postgres_data
|
||||
chown -R 105432:105432 /srv/sambro/postgres_data
|
||||
chmod 700 /srv/sambro/postgres_data
|
||||
lxc-execute -n sambro-postgres -- initdb -D /var/lib/postgresql
|
||||
|
||||
# Configure Postgres
|
||||
cp postgres_data/postgresql.conf /srv/sambro/postgres_data/postgresql.conf
|
||||
cp postgres_data/pg_hba.conf /srv/sambro/postgres_data/pg_hba.conf
|
||||
|
||||
# Create PostgreSQL user and database
|
||||
export SAMBRO_PWD=$(head -c 18 /dev/urandom | base64 | tr -d '+/=')
|
||||
envsubst <createdb.sql | lxc-attach -u 5432 -g 5432 postgres -- psql
|
||||
service sambro-postgres start
|
||||
envsubst <createdb.sql | lxc-attach -u 5432 -g 5432 sambro-postgres -- psql
|
||||
|
||||
# Prepare persistent directory structure
|
||||
mkdir -p /srv/sambro/conf /srv/sambro/data/databases /srv/sambro/data/uploads /srv/sambro/data/SAMBRO
|
||||
chown -R 8001:8001 /srv/sambro/conf /srv/sambro/data
|
||||
cp -rp /var/lib/lxc/shared/sahana/srv/web2py/applications/eden/models/. /srv/sambro/conf
|
||||
cp -rp /var/lib/lxc/shared/sahana/srv/web2py/applications/eden/modules/templates/SAMBRO/. /srv/sambro/data/SAMBRO
|
||||
mkdir -p /srv/sambro/sahana_conf /srv/sambro/sahana_data/databases /srv/sambro/sahana_data/uploads /srv/sambro/sahana_data/SAMBRO
|
||||
chown -R 108001:108001 /srv/sambro/sahana_conf /srv/sambro/sahana_data
|
||||
lxc-execute sambro -- tar -cC /srv/web2py/applications/eden/models . | tar -xC /srv/sambro/sahana_conf
|
||||
lxc-execute sambro -- tar -cC /srv/web2py/applications/eden/modules/templates/SAMBRO . | tar -xC /srv/sambro/sahana_data/SAMBRO
|
||||
|
||||
# Configure SAMBRO
|
||||
export SAMBRO_HMAC=$(head -c 18 /dev/urandom | base64 | tr -d '+/=')
|
||||
export SAMBRO_ADMIN_USER=admin@example.com
|
||||
export SAMBRO_ADMIN_PWD=$(head -c 12 /dev/urandom | base64 | tr -d '+/=')
|
||||
envsubst <srv/sambro/conf/000_config.py >/srv/sambro/conf/000_config.py
|
||||
mkdir -p /var/lib/lxc/sambro/sambro/srv/web2py/applications/eden/modules/templates/default/users
|
||||
envsubst <masterUsers.csv >/var/lib/lxc/sambro/sambro/srv/web2py/applications/eden/modules/templates/default/users/masterUsers.csv
|
||||
chown -R 8001:8001 /var/lib/lxc/sambro/sambro/srv/web2py
|
||||
cp srv/sambro/conf/00_settings.py /srv/sambro/conf/00_settings.py
|
||||
cp srv/sambro/data/SAMBRO/config.py /srv/sambro/data/SAMBRO/config.py
|
||||
envsubst <sahana_conf/000_config.py >/srv/sambro/sahana_conf/000_config.py
|
||||
# TODO:
|
||||
#mkdir -p /var/lib/lxc/sambro/sambro/srv/web2py/applications/eden/modules/templates/default/users
|
||||
#envsubst <masterUsers.csv >/var/lib/lxc/sambro/sambro/srv/web2py/applications/eden/modules/templates/default/users/masterUsers.csv
|
||||
#chown -R 8001:8001 /var/lib/lxc/sambro/sambro/srv/web2py
|
||||
cp sahana_conf/00_settings.py /srv/sambro/sahana_conf/00_settings.py
|
||||
cp sahana_data/SAMBRO/config.py /srv/sambro/sahana_data/SAMBRO/config.py
|
||||
chown -R 108001:108001 /srv/sambro/sahana_conf /srv/sambro/sahana_data
|
||||
|
||||
# Populate database
|
||||
lxc-execute -u 8001 -g 8001 sambro -- sh -c 'cd /srv/web2py; ./web2py.py -S eden -M -R applications/eden/static/scripts/tools/noop.py'
|
||||
@ -37,15 +47,11 @@ if [ ${DEBUG:-0} -eq 0 ]; then
|
||||
sed -i 's/#settings.base.prepopulate = 0/settings.base.prepopulate = 0/' /srv/sambro/conf/000_config.py
|
||||
fi
|
||||
|
||||
# Install service
|
||||
cp etc/init.d/sambro /etc/init.d/sambro
|
||||
rc-update -u
|
||||
|
||||
# Install config update script
|
||||
cp srv/sambro/update-conf.sh /srv/sambro/update-conf.sh
|
||||
cp update-conf.sh /srv/sambro/update-conf.sh
|
||||
|
||||
# Stop services required for build
|
||||
[ ! -z ${STOP_POSTGRES} ] && service postgres stop
|
||||
# Stop services required for setup
|
||||
service sambro-postgres stop
|
||||
|
||||
# Register application
|
||||
vmmgr register-app sambro sambro "${SAMBRO_ADMIN_USER}" "${SAMBRO_ADMIN_PWD}"
|
||||
|
@ -1,23 +0,0 @@
|
||||
#!/sbin/openrc-run
|
||||
|
||||
description="SAMBRO container"
|
||||
|
||||
depend() {
|
||||
need postgres
|
||||
}
|
||||
|
||||
start() {
|
||||
lxc-start sambro
|
||||
}
|
||||
|
||||
start_post() {
|
||||
vmmgr register-proxy sambro
|
||||
}
|
||||
|
||||
stop_pre() {
|
||||
vmmgr unregister-proxy sambro
|
||||
}
|
||||
|
||||
stop() {
|
||||
lxc-stop sambro
|
||||
}
|
0
lxc-apps/sambro/install/srv/sambro/update-conf.sh → lxc-apps/sambro/install/update-conf.sh
Executable file → Normal file
0
lxc-apps/sambro/install/srv/sambro/update-conf.sh → lxc-apps/sambro/install/update-conf.sh
Executable file → Normal file
@ -1,12 +0,0 @@
|
||||
IMAGE sambro_0.0.1-190620
|
||||
|
||||
LAYER alpine3.9_3.9.4-190620
|
||||
LAYER alpine3.9-python2.7_2.7.16-190620
|
||||
LAYER sahana-shared_0.0.1-190620
|
||||
|
||||
MOUNT DIR /srv/sambro/conf srv/web2py/applications/eden/models
|
||||
MOUNT DIR /srv/sambro/data/SAMBRO srv/web2py/applications/eden/modules/templates/SAMBRO
|
||||
MOUNT DIR /srv/sambro/data/databases srv/web2py/applications/eden/databases
|
||||
MOUNT DIR /srv/sambro/data/uploads srv/web2py/applications/eden/uploads
|
||||
|
||||
CMD s6-svscan /etc/services.d
|
29
lxc-apps/sambro/meta
Normal file
29
lxc-apps/sambro/meta
Normal file
@ -0,0 +1,29 @@
|
||||
{
|
||||
"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_11.3.0-190620",
|
||||
"mounts": [
|
||||
["DIR", "/srv/sambro/postgres_data", "/var/lib/postgresql"]
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
@ -1,14 +1,8 @@
|
||||
#!/bin/sh
|
||||
set -ev
|
||||
|
||||
# Remove service
|
||||
rm -f /etc/init.d/sambro
|
||||
rc-update -u
|
||||
|
||||
# Drop database and user
|
||||
[ ! -e /run/openrc/started/postgres ] && service postgres start && STOP_POSTGRES=1
|
||||
echo 'DROP DATABASE IF EXISTS sambro; DROP ROLE IF EXISTS sambro;' | lxc-attach -u 5432 -g 5432 postgres -- psql
|
||||
[ ! -z ${STOP_POSTGRES} ] && service postgres stop
|
||||
# Remove persistent data
|
||||
rm -rf /srv/sambro
|
||||
|
||||
# Unregister application
|
||||
vmmgr unregister-app sambro
|
||||
|
Loading…
Reference in New Issue
Block a user