diff --git a/lxc-apps/sahana-demo/meta b/lxc-apps/sahana-demo/meta index ca691cc..1be2cdc 100644 --- a/lxc-apps/sahana-demo/meta +++ b/lxc-apps/sahana-demo/meta @@ -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": { diff --git a/lxc-apps/sahana/meta b/lxc-apps/sahana/meta index 285deca..0272165 100644 --- a/lxc-apps/sahana/meta +++ b/lxc-apps/sahana/meta @@ -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": { diff --git a/lxc-apps/sambro/install.sh b/lxc-apps/sambro/install.sh index b884f6e..42520ad 100755 --- a/lxc-apps/sambro/install.sh +++ b/lxc-apps/sambro/install.sh @@ -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 /srv/sambro/conf/000_config.py -mkdir -p /var/lib/lxc/sambro/sambro/srv/web2py/applications/eden/modules/templates/default/users -envsubst /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 /srv/sambro/sahana_conf/000_config.py +# TODO: +#mkdir -p /var/lib/lxc/sambro/sambro/srv/web2py/applications/eden/modules/templates/default/users +#envsubst /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}" diff --git a/lxc-apps/sambro/install/etc/init.d/sambro b/lxc-apps/sambro/install/etc/init.d/sambro deleted file mode 100755 index d1aa284..0000000 --- a/lxc-apps/sambro/install/etc/init.d/sambro +++ /dev/null @@ -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 -} diff --git a/lxc-apps/sambro/install/srv/sambro/conf/000_config.py b/lxc-apps/sambro/install/sahana_conf/000_config.py similarity index 100% rename from lxc-apps/sambro/install/srv/sambro/conf/000_config.py rename to lxc-apps/sambro/install/sahana_conf/000_config.py diff --git a/lxc-apps/sambro/install/srv/sambro/conf/00_settings.py b/lxc-apps/sambro/install/sahana_conf/00_settings.py similarity index 100% rename from lxc-apps/sambro/install/srv/sambro/conf/00_settings.py rename to lxc-apps/sambro/install/sahana_conf/00_settings.py diff --git a/lxc-apps/sambro/install/srv/sambro/data/SAMBRO/config.py b/lxc-apps/sambro/install/sahana_data/SAMBRO/config.py similarity index 100% rename from lxc-apps/sambro/install/srv/sambro/data/SAMBRO/config.py rename to lxc-apps/sambro/install/sahana_data/SAMBRO/config.py diff --git a/lxc-apps/sambro/install/srv/sambro/update-conf.sh b/lxc-apps/sambro/install/update-conf.sh old mode 100755 new mode 100644 similarity index 100% rename from lxc-apps/sambro/install/srv/sambro/update-conf.sh rename to lxc-apps/sambro/install/update-conf.sh diff --git a/lxc-apps/sambro/lxcfile b/lxc-apps/sambro/lxcfile deleted file mode 100644 index 85823fd..0000000 --- a/lxc-apps/sambro/lxcfile +++ /dev/null @@ -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 diff --git a/lxc-apps/sambro/meta b/lxc-apps/sambro/meta new file mode 100644 index 0000000..dc75bc8 --- /dev/null +++ b/lxc-apps/sambro/meta @@ -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"] + ] + } + } +} diff --git a/lxc-apps/sambro/uninstall.sh b/lxc-apps/sambro/uninstall.sh index 4fd1cf6..1e0465c 100755 --- a/lxc-apps/sambro/uninstall.sh +++ b/lxc-apps/sambro/uninstall.sh @@ -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