From fea0a7911a129609b989f612a557ce29483f57dc Mon Sep 17 00:00:00 2001 From: Disassembler Date: Sat, 21 Mar 2020 22:42:35 +0100 Subject: [PATCH] Make ODK SPOC-compatible --- lxc-apps/opendatakit/app | 37 ++++++++++++++ lxc-apps/opendatakit/install.sh | 48 +++++++++---------- lxc-apps/opendatakit/meta | 38 --------------- ...-build.lxcfile => opendatakit-build.image} | 8 ++-- .../opendatakit-build.image.d/bin/add-ca-cert | 4 ++ .../etc/services.d/.s6-svscan/finish | 2 +- .../etc/services.d/build2xlsform/run | 0 .../etc/services.d/odkbuild/down-signal | 0 .../etc/services.d/odkbuild/run | 2 +- ...{opendatakit.lxcfile => opendatakit.image} | 8 ++-- lxc-apps/opendatakit/uninstall.sh | 2 +- 11 files changed, 75 insertions(+), 74 deletions(-) create mode 100644 lxc-apps/opendatakit/app delete mode 100644 lxc-apps/opendatakit/meta rename lxc-apps/opendatakit/{opendatakit-build.lxcfile => opendatakit-build.image} (87%) create mode 100755 lxc-apps/opendatakit/opendatakit-build.image.d/bin/add-ca-cert rename lxc-apps/opendatakit/{opendatakit-build.lxc => opendatakit-build.image.d}/etc/services.d/.s6-svscan/finish (56%) rename lxc-apps/opendatakit/{opendatakit-build.lxc => opendatakit-build.image.d}/etc/services.d/build2xlsform/run (100%) rename lxc-apps/opendatakit/{opendatakit-build.lxc => opendatakit-build.image.d}/etc/services.d/odkbuild/down-signal (100%) rename lxc-apps/opendatakit/{opendatakit-build.lxc => opendatakit-build.image.d}/etc/services.d/odkbuild/run (77%) rename lxc-apps/opendatakit/{opendatakit.lxcfile => opendatakit.image} (81%) diff --git a/lxc-apps/opendatakit/app b/lxc-apps/opendatakit/app new file mode 100644 index 0000000..0d9e6c1 --- /dev/null +++ b/lxc-apps/opendatakit/app @@ -0,0 +1,37 @@ +{ + "version": "2.0.5-200313", + "meta": { + "title": "OpenDataKit", + "desc-cs": "Sběr formulářových dat", + "desc-en": "Form data collection", + "license": "GPL" + }, + "containers": { + "opendatakit": { + "image": "opendatakit_2.0.5-200313", + "depends": [ + "opendatakit-postgres" + ], + "mounts": { + "opendatakit/odk_conf/server.xml": "srv/tomcat/conf/server.xml:file", + "opendatakit/odk_conf/jdbc.properties": "srv/tomcat/webapps/ROOT/WEB-INF/classes/jdbc.properties:file", + "opendatakit/odk_conf/security.properties": "srv/tomcat/webapps/ROOT/WEB-INF/classes/security.properties:file" + } + }, + "opendatakit-build": { + "image": "opendatakit-build_0.3.5-200313", + "depends": [ + "opendatakit-postgres" + ], + "mounts": { + "opendatakit/odkbuild_conf/config.yml": "srv/opendatakit-build/config.yml:file" + } + }, + "opendatakit-postgres": { + "image": "postgres_12.2.0-200313", + "mounts": { + "opendatakit/postgres_data": "var/lib/postgresql" + } + } + } +} diff --git a/lxc-apps/opendatakit/install.sh b/lxc-apps/opendatakit/install.sh index 1f2e46b..96fa595 100755 --- a/lxc-apps/opendatakit/install.sh +++ b/lxc-apps/opendatakit/install.sh @@ -1,57 +1,55 @@ #!/bin/sh set -ev +# Volumes +POSTGRES_DATA="${VOLUMES_DIR}/opendatakit/postgres_data" +ODK_CONF="${VOLUMES_DIR}/opendatakit/odk_conf" +ODKBUILD_CONF="${VOLUMES_DIR}/opendatakit/odkbuild_conf" + # Create Postgres instance -mkdir -p /srv/opendatakit/postgres_data -chown -R 105432:105432 /srv/opendatakit/postgres_data -chmod 700 /srv/opendatakit/postgres_data -lxc-execute -n opendatakit-postgres -- initdb -D /var/lib/postgresql +install -o 105432 -g 105432 -m 700 -d ${POSTGRES_DATA} +spoc-container exec opendatakit-postgres -- initdb -D /var/lib/postgresql # Configure Postgres -cp postgres_data/postgresql.conf /srv/opendatakit/postgres_data/postgresql.conf -cp postgres_data/pg_hba.conf /srv/opendatakit/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 databases export OPENDATAKIT_PWD=$(head -c 18 /dev/urandom | base64 | tr -d '+/=') export OPENDATAKITBUILD_PWD=$(head -c 18 /dev/urandom | base64 | tr -d '+/=') -service lxc-opendatakit-postgres start -envsubst /srv/opendatakit/odk_conf/jdbc.properties -envsubst /srv/opendatakit/odk_conf/security.properties -cp odk_conf/server.xml /srv/opendatakit/odk_conf/server.xml -chown -R 108080:108080 /srv/opendatakit/odk_conf +install -o 108080 -g 108080 -m 750 -d ${ODK_CONF} +envsubst /srv/opendatakit/odkbuild_conf/config.yml -lxc-execute opendatakit-build -- sh -c 'cd /srv/opendatakit-build; rake db:migrate' -chown -R 100000:100000 /srv/opendatakit/odkbuild_conf +install -o 108080 -g 108080 -m 750 -d ${ODKBUILD_CONF} +envsubst