From 0d8a9634e33c4da2aac1b898d2b1cdefea0edad5 Mon Sep 17 00:00:00 2001 From: Disassembler Date: Sun, 25 Mar 2018 14:21:11 +0200 Subject: [PATCH] Shorten ODK Build handle --- 00-install.sh | 2 +- basic/srv/portal/index.html | 2 +- odkbuild.sh | 28 +++++++++++++++++++ {opendatakit-build => odkbuild}/Dockerfile | 0 {opendatakit-build => odkbuild}/createdb.sql | 0 .../docker/etc/services.d/.s6-svscan/finish | 0 .../docker/etc/services.d/build2xlsform/run | 0 .../docker/etc/services.d/odkbuild/run | 0 odkbuild/etc/init.d/odkbuild | 25 +++++++++++++++++ .../srv/odkbuild}/conf/config.yml | 0 opendatakit-build.sh | 28 ------------------- .../etc/init.d/opendatakit-build | 25 ----------------- 12 files changed, 55 insertions(+), 55 deletions(-) create mode 100755 odkbuild.sh rename {opendatakit-build => odkbuild}/Dockerfile (100%) rename {opendatakit-build => odkbuild}/createdb.sql (100%) rename {opendatakit-build => odkbuild}/docker/etc/services.d/.s6-svscan/finish (100%) rename {opendatakit-build => odkbuild}/docker/etc/services.d/build2xlsform/run (100%) rename {opendatakit-build => odkbuild}/docker/etc/services.d/odkbuild/run (100%) create mode 100755 odkbuild/etc/init.d/odkbuild rename {opendatakit-build/srv/opendatakit-build => odkbuild/srv/odkbuild}/conf/config.yml (100%) delete mode 100755 opendatakit-build.sh delete mode 100755 opendatakit-build/etc/init.d/opendatakit-build diff --git a/00-install.sh b/00-install.sh index 7b16063..1d2a332 100755 --- a/00-install.sh +++ b/00-install.sh @@ -16,7 +16,7 @@ ${SOURCE_DIR}/gnuhealth.sh ${SOURCE_DIR}/kanboard.sh ${SOURCE_DIR}/mifosx.sh ${SOURCE_DIR}/motech.sh -${SOURCE_DIR}/opendatakit-build.sh +${SOURCE_DIR}/odkbuild.sh ${SOURCE_DIR}/opendatakit.sh ${SOURCE_DIR}/openmapkit.sh ${SOURCE_DIR}/pandora.sh diff --git a/basic/srv/portal/index.html b/basic/srv/portal/index.html index 4ecc494..3c19433 100644 --- a/basic/srv/portal/index.html +++ b/basic/srv/portal/index.html @@ -74,7 +74,7 @@ -
+

Open Data KitODK Build

Sběr dat s pomocí smartphone.
Aplikace pro návrh formulářů
XLSForm - online konverter XLS. diff --git a/odkbuild.sh b/odkbuild.sh new file mode 100755 index 0000000..355a026 --- /dev/null +++ b/odkbuild.sh @@ -0,0 +1,28 @@ +#!/bin/sh + +SOURCE_DIR=$(realpath $(dirname "${0}"))/odkbuild + +# Check prerequisites +docker image ls | grep -q postgres || $(realpath $(dirname "${0}"))/postgres.sh +docker image ls | grep -q ruby || $(realpath $(dirname "${0}"))/ruby.sh + +# Build Docker container +docker build -t odkbuild ${SOURCE_DIR} + +# Create databases +export ODKBUILD_PWD=$(head -c 18 /dev/urandom | base64) +envsubst <${SOURCE_DIR}/createdb.sql | docker exec -i postgres psql + +# Configure OpenDataKit Build +export ODKBUILD_COOKIE_SECRET=$(head -c 8 /dev/urandom | hexdump -e '"%x"') +mkdir -p /srv/odkbuild/conf +envsubst <${SOURCE_DIR}/srv/odkbuild/conf/config.yml >/srv/odkbuild/conf/config.yml +docker run --rm -h odkbuild --link postgres -v /srv/odkbuild/conf/config.yml:/srv/odkbuild/config.yml -w /srv/odkbuild odkbuild rake db:migrate + +# Create OpenDataKit service +cp ${SOURCE_DIR}/etc/init.d/odkbuild /etc/init.d/odkbuild +rc-update add odkbuild +service odkbuild start + +# Add application definition +spotter-appmgr add-app odkbuild "https://odkbuild.{host}/" diff --git a/opendatakit-build/Dockerfile b/odkbuild/Dockerfile similarity index 100% rename from opendatakit-build/Dockerfile rename to odkbuild/Dockerfile diff --git a/opendatakit-build/createdb.sql b/odkbuild/createdb.sql similarity index 100% rename from opendatakit-build/createdb.sql rename to odkbuild/createdb.sql diff --git a/opendatakit-build/docker/etc/services.d/.s6-svscan/finish b/odkbuild/docker/etc/services.d/.s6-svscan/finish similarity index 100% rename from opendatakit-build/docker/etc/services.d/.s6-svscan/finish rename to odkbuild/docker/etc/services.d/.s6-svscan/finish diff --git a/opendatakit-build/docker/etc/services.d/build2xlsform/run b/odkbuild/docker/etc/services.d/build2xlsform/run similarity index 100% rename from opendatakit-build/docker/etc/services.d/build2xlsform/run rename to odkbuild/docker/etc/services.d/build2xlsform/run diff --git a/opendatakit-build/docker/etc/services.d/odkbuild/run b/odkbuild/docker/etc/services.d/odkbuild/run similarity index 100% rename from opendatakit-build/docker/etc/services.d/odkbuild/run rename to odkbuild/docker/etc/services.d/odkbuild/run diff --git a/odkbuild/etc/init.d/odkbuild b/odkbuild/etc/init.d/odkbuild new file mode 100755 index 0000000..067d5bf --- /dev/null +++ b/odkbuild/etc/init.d/odkbuild @@ -0,0 +1,25 @@ +#!/sbin/openrc-run + +description="OpenDataKit Build docker container" + +depend() { + need docker net postgres + use dns logger netmount +} + +start() { + /usr/bin/docker run -d --rm \ + --name odkbuild \ + -h odkbuild \ + --link postgres \ + -v /srv/odkbuild/conf/config.yml:/srv/odkbuild/config.yml \ + odkbuild +} + +start_post() { + /usr/local/bin/spotter-appmgr update-hosts odkbuild +} + +stop() { + /usr/bin/docker stop odkbuild +} diff --git a/opendatakit-build/srv/opendatakit-build/conf/config.yml b/odkbuild/srv/odkbuild/conf/config.yml similarity index 100% rename from opendatakit-build/srv/opendatakit-build/conf/config.yml rename to odkbuild/srv/odkbuild/conf/config.yml diff --git a/opendatakit-build.sh b/opendatakit-build.sh deleted file mode 100755 index f267a54..0000000 --- a/opendatakit-build.sh +++ /dev/null @@ -1,28 +0,0 @@ -#!/bin/sh - -SOURCE_DIR=$(realpath $(dirname "${0}"))/opendatakit-build - -# Check prerequisites -docker image ls | grep -q postgres || $(realpath $(dirname "${0}"))/postgres.sh -docker image ls | grep -q ruby || $(realpath $(dirname "${0}"))/ruby.sh - -# Build Docker container -docker build -t opendatakit-build ${SOURCE_DIR} - -# Create databases -export ODKBUILD_PWD=$(head -c 18 /dev/urandom | base64) -envsubst <${SOURCE_DIR}/createdb.sql | docker exec -i postgres psql - -# Configure OpenDataKit Build -export ODKBUILD_COOKIE_SECRET=$(head -c 8 /dev/urandom | hexdump -e '"%x"') -mkdir -p /srv/opendatakit-build/conf -envsubst <${SOURCE_DIR}/srv/opendatakit-build/conf/config.yml >/srv/opendatakit-build/conf/config.yml -docker run --rm -h opendatakit-build --link postgres -v /srv/opendatakit-build/conf/config.yml:/srv/odkbuild/config.yml -w /srv/odkbuild opendatakit-build rake db:migrate - -# Create OpenDataKit service -cp ${SOURCE_DIR}/etc/init.d/opendatakit-build /etc/init.d/opendatakit-build -rc-update add opendatakit-build -service opendatakit-build start - -# Add application definition -spotter-appmgr add-app opendatakit-build "https://opendatakit-build.{host}/" diff --git a/opendatakit-build/etc/init.d/opendatakit-build b/opendatakit-build/etc/init.d/opendatakit-build deleted file mode 100755 index 5a2828c..0000000 --- a/opendatakit-build/etc/init.d/opendatakit-build +++ /dev/null @@ -1,25 +0,0 @@ -#!/sbin/openrc-run - -description="OpenDataKit Build docker container" - -depend() { - need docker net postgres - use dns logger netmount -} - -start() { - /usr/bin/docker run -d --rm \ - --name opendatakit-build \ - -h opendatakit-build \ - --link postgres \ - -v /srv/opendatakit-build/conf/config.yml:/srv/odkbuild/config.yml \ - opendatakit-build -} - -start_post() { - /usr/local/bin/spotter-appmgr update-hosts opendatakit-build -} - -stop() { - /usr/bin/docker stop opendatakit-build -}