From 459d0f711ed7dd07ad7536efeca21a96e7c97355 Mon Sep 17 00:00:00 2001
From: Disassembler
Mobilní aplikace
ODK Collect pro Android
@@ -91,7 +91,7 @@
Sběr dat s pomocí smartphone.
GeoODK Collect - náhrada papírových dotazníků smartphonem.
diff --git a/odk.sh b/odk.sh
new file mode 100755
index 0000000..daf1864
--- /dev/null
+++ b/odk.sh
@@ -0,0 +1,44 @@
+#!/bin/sh
+
+SOURCE_DIR=$(realpath $(dirname "${0}"))/odk
+
+# Check prerequisites
+docker image ls | grep -q postgres || $(realpath $(dirname "${0}"))/postgres.sh
+docker image ls | grep -q postfix || $(realpath $(dirname "${0}"))/postfix.sh
+docker image ls | grep -q tomcat || $(realpath $(dirname "${0}"))/tomcat.sh
+
+# Build Docker container
+docker build -t odk ${SOURCE_DIR}
+
+# Create databases
+export ODK_PWD=$(head -c 18 /dev/urandom | base64)
+envsubst <${SOURCE_DIR}/createdb.sql | docker exec -i postgres psql
+
+# Configure OpenDataKit
+export ODK_ADMIN_USER=admin
+export ODK_ADMIN_REALM=spotter
+mkdir -p /srv/odk/conf
+envsubst <${SOURCE_DIR}/srv/odk/conf/jdbc.properties >/srv/odk/conf/jdbc.properties
+envsubst <${SOURCE_DIR}/srv/odk/conf/security.properties >/srv/odk/conf/security.properties
+cp ${SOURCE_DIR}/srv/odk/conf/server.xml /srv/odk/conf/server.xml
+cp ${SOURCE_DIR}/srv/odk/update-url.sh /srv/odk/update-url.sh
+chown -R 8015:8015 /srv/odk/conf
+
+# Create OpenDataKit service
+cp ${SOURCE_DIR}/etc/init.d/odk /etc/init.d/odk
+rc-update add odk
+service odk start
+
+# Update admin account
+export ODK_ADMIN_PWD=$(head -c 12 /dev/urandom | base64)
+export ODK_ADMIN_SALT=$(head -c 4 /dev/urandom | hexdump -e '"%x"') # Must be 8 characters
+export ODK_ADMIN_BASIC_HASH=$(echo -n "${ODK_ADMIN_PWD}{${ODK_ADMIN_SALT}}" | sha1sum | tr -d " -")
+export ODK_ADMIN_DIGEST_HASH=$(echo -n "${ODK_ADMIN_USER}:${ODK_ADMIN_REALM}:${ODK_ADMIN_PWD}" | md5sum | tr -d " -")
+until docker logs odk 2>&1 | grep -q 'org.apache.catalina.startup.Catalina.start'; do
+ sleep 1
+done
+envsubst <${SOURCE_DIR}/adminpwd.sql | docker exec -i postgres psql odk
+
+# Add application definition
+spotter-appmgr add-app odk "https://odk.{host}/aggregate/" "${ODK_ADMIN_USER}" "${ODK_ADMIN_PWD}"
+spotter-appmgr add-app odk-clients -p clienturl "https://odk.{host}/aggregate"
diff --git a/opendatakit/Dockerfile b/odk/Dockerfile
similarity index 100%
rename from opendatakit/Dockerfile
rename to odk/Dockerfile
diff --git a/odk/adminpwd.sql b/odk/adminpwd.sql
new file mode 100644
index 0000000..9424cfb
--- /dev/null
+++ b/odk/adminpwd.sql
@@ -0,0 +1 @@
+UPDATE _registered_users SET "BASIC_AUTH_PASSWORD" = '${ODK_ADMIN_BASIC_HASH}', "BASIC_AUTH_SALT" = '${ODK_ADMIN_SALT}', "DIGEST_AUTH_PASSWORD" = '${ODK_ADMIN_DIGEST_HASH}' WHERE "LOCAL_USERNAME" = '${ODK_ADMIN_USER}';
diff --git a/odk/createdb.sql b/odk/createdb.sql
new file mode 100644
index 0000000..e2cc678
--- /dev/null
+++ b/odk/createdb.sql
@@ -0,0 +1,4 @@
+CREATE ROLE odk NOSUPERUSER NOCREATEDB NOCREATEROLE NOINHERIT LOGIN ENCRYPTED PASSWORD '${ODK_PWD}';
+CREATE DATABASE odk;
+REVOKE ALL ON DATABASE odk FROM public;
+ALTER DATABASE odk OWNER TO odk;
diff --git a/odk/etc/init.d/odk b/odk/etc/init.d/odk
new file mode 100755
index 0000000..2ec2925
--- /dev/null
+++ b/odk/etc/init.d/odk
@@ -0,0 +1,28 @@
+#!/sbin/openrc-run
+
+description="OpenDataKit Aggregate docker container"
+
+depend() {
+ need docker net postgres
+ use dns logger netmount postfix
+}
+
+start() {
+ /usr/bin/docker run -d --rm \
+ --name odk \
+ -h odk \
+ --link postfix \
+ --link postgres \
+ -v /srv/odk/conf/server.xml:/srv/tomcat/conf/server.xml \
+ -v /srv/odk/conf/jdbc.properties:/srv/tomcat/webapps/aggregate/WEB-INF/classes/jdbc.properties \
+ -v /srv/odk/conf/security.properties:/srv/tomcat/webapps/aggregate/WEB-INF/classes/security.properties \
+ odk
+}
+
+start_post() {
+ /usr/local/bin/spotter-appmgr update-hosts odk
+}
+
+stop() {
+ /usr/bin/docker stop odk
+}
diff --git a/odk/srv/odk/conf/jdbc.properties b/odk/srv/odk/conf/jdbc.properties
new file mode 100644
index 0000000..4f464ac
--- /dev/null
+++ b/odk/srv/odk/conf/jdbc.properties
@@ -0,0 +1,6 @@
+jdbc.driverClassName=org.postgresql.Driver
+jdbc.resourceName=jdbc/odk_aggregate
+jdbc.url=jdbc:postgresql://postgres/odk?autoDeserialize=true
+jdbc.username=odk
+jdbc.password=${ODK_PWD}
+jdbc.schema=public
diff --git a/opendatakit/srv/opendatakit/conf/security.properties b/odk/srv/odk/conf/security.properties
similarity index 93%
rename from opendatakit/srv/opendatakit/conf/security.properties
rename to odk/srv/odk/conf/security.properties
index 948da2f..dc914c1 100644
--- a/opendatakit/srv/opendatakit/conf/security.properties
+++ b/odk/srv/odk/conf/security.properties
@@ -38,8 +38,8 @@ security.server.superUser=
# Define a superUserUsername to insert an ODK Aggregate username that can
# access the server. The initial password for this username is 'aggregate'
-security.server.superUserUsername=${OPENDATAKIT_ADMIN_USER}
+security.server.superUserUsername=${ODK_ADMIN_USER}
# realm definition
# realmString -- what should be sent to users when BasicAuth or DigestAuth is done
-security.server.realm.realmString=${OPENDATAKIT_ADMIN_REALM}
+security.server.realm.realmString=${ODK_ADMIN_REALM}
diff --git a/opendatakit/srv/opendatakit/conf/server.xml b/odk/srv/odk/conf/server.xml
similarity index 100%
rename from opendatakit/srv/opendatakit/conf/server.xml
rename to odk/srv/odk/conf/server.xml
diff --git a/odk/srv/odk/update-url.sh b/odk/srv/odk/update-url.sh
new file mode 100755
index 0000000..1be8cc7
--- /dev/null
+++ b/odk/srv/odk/update-url.sh
@@ -0,0 +1,5 @@
+#!/bin/sh
+
+sed -i "s|\(^\s\+proxyName\).*|\1=\"${1}\"|g" /srv/odk/conf/server.xml
+sed -i "s|\(^\s\+proxyPort\).*|\1=\"${2}\"|g" /srv/odk/conf/server.xml
+sed -i "s|^security\.server\.securePort.*|security.server.securePort=${2}|" /srv/odk/conf/security.properties
diff --git a/opendatakit.sh b/opendatakit.sh
deleted file mode 100755
index cb375be..0000000
--- a/opendatakit.sh
+++ /dev/null
@@ -1,44 +0,0 @@
-#!/bin/sh
-
-SOURCE_DIR=$(realpath $(dirname "${0}"))/opendatakit
-
-# Check prerequisites
-docker image ls | grep -q postgres || $(realpath $(dirname "${0}"))/postgres.sh
-docker image ls | grep -q postfix || $(realpath $(dirname "${0}"))/postfix.sh
-docker image ls | grep -q tomcat || $(realpath $(dirname "${0}"))/tomcat.sh
-
-# Build Docker container
-docker build -t opendatakit ${SOURCE_DIR}
-
-# Create databases
-export OPENDATAKIT_PWD=$(head -c 18 /dev/urandom | base64)
-envsubst <${SOURCE_DIR}/createdb.sql | docker exec -i postgres psql
-
-# Configure OpenDataKit
-export OPENDATAKIT_ADMIN_USER=admin
-export OPENDATAKIT_ADMIN_REALM=spotter
-mkdir -p /srv/opendatakit/conf
-envsubst <${SOURCE_DIR}/srv/opendatakit/conf/jdbc.properties >/srv/opendatakit/conf/jdbc.properties
-envsubst <${SOURCE_DIR}/srv/opendatakit/conf/security.properties >/srv/opendatakit/conf/security.properties
-cp ${SOURCE_DIR}/srv/opendatakit/conf/server.xml /srv/opendatakit/conf/server.xml
-cp ${SOURCE_DIR}/srv/opendatakit/update-url.sh /srv/opendatakit/update-url.sh
-chown -R 8015:8015 /srv/opendatakit/conf
-
-# Create OpenDataKit service
-cp ${SOURCE_DIR}/etc/init.d/opendatakit /etc/init.d/opendatakit
-rc-update add opendatakit
-service opendatakit start
-
-# Update admin account
-export OPENDATAKIT_ADMIN_PWD=$(head -c 12 /dev/urandom | base64)
-export OPENDATAKIT_ADMIN_SALT=$(head -c 4 /dev/urandom | hexdump -e '"%x"') # Must be 8 characters
-export OPENDATAKIT_ADMIN_BASIC_HASH=$(echo -n "${OPENDATAKIT_ADMIN_PWD}{${OPENDATAKIT_ADMIN_SALT}}" | sha1sum | tr -d " -")
-export OPENDATAKIT_ADMIN_DIGEST_HASH=$(echo -n "${OPENDATAKIT_ADMIN_USER}:${OPENDATAKIT_ADMIN_REALM}:${OPENDATAKIT_ADMIN_PWD}" | md5sum | tr -d " -")
-until docker logs opendatakit 2>&1 | grep -q 'org.apache.catalina.startup.Catalina.start'; do
- sleep 1
-done
-envsubst <${SOURCE_DIR}/adminpwd.sql | docker exec -i postgres psql opendatakit
-
-# Add application definition
-spotter-appmgr add-app opendatakit "https://opendatakit.{host}/aggregate/" "${OPENDATAKIT_ADMIN_USER}" "${OPENDATAKIT_ADMIN_PWD}"
-spotter-appmgr add-app opendatakit-clients -p clienturl "https://opendatakit.{host}/aggregate"
diff --git a/opendatakit/adminpwd.sql b/opendatakit/adminpwd.sql
deleted file mode 100644
index f5393c0..0000000
--- a/opendatakit/adminpwd.sql
+++ /dev/null
@@ -1 +0,0 @@
-UPDATE _registered_users SET "BASIC_AUTH_PASSWORD" = '${OPENDATAKIT_ADMIN_BASIC_HASH}', "BASIC_AUTH_SALT" = '${OPENDATAKIT_ADMIN_SALT}', "DIGEST_AUTH_PASSWORD" = '${OPENDATAKIT_ADMIN_DIGEST_HASH}' WHERE "LOCAL_USERNAME" = '${OPENDATAKIT_ADMIN_USER}';
diff --git a/opendatakit/createdb.sql b/opendatakit/createdb.sql
deleted file mode 100644
index 897f489..0000000
--- a/opendatakit/createdb.sql
+++ /dev/null
@@ -1,4 +0,0 @@
-CREATE ROLE opendatakit NOSUPERUSER NOCREATEDB NOCREATEROLE NOINHERIT LOGIN ENCRYPTED PASSWORD '${OPENDATAKIT_PWD}';
-CREATE DATABASE opendatakit;
-REVOKE ALL ON DATABASE opendatakit FROM public;
-ALTER DATABASE opendatakit OWNER TO opendatakit;
diff --git a/opendatakit/etc/init.d/opendatakit b/opendatakit/etc/init.d/opendatakit
deleted file mode 100755
index fa33ca6..0000000
--- a/opendatakit/etc/init.d/opendatakit
+++ /dev/null
@@ -1,28 +0,0 @@
-#!/sbin/openrc-run
-
-description="OpenDataKit Aggregate docker container"
-
-depend() {
- need docker net postgres
- use dns logger netmount postfix
-}
-
-start() {
- /usr/bin/docker run -d --rm \
- --name opendatakit \
- -h opendatakit \
- --link postfix \
- --link postgres \
- -v /srv/opendatakit/conf/server.xml:/srv/tomcat/conf/server.xml \
- -v /srv/opendatakit/conf/jdbc.properties:/srv/tomcat/webapps/aggregate/WEB-INF/classes/jdbc.properties \
- -v /srv/opendatakit/conf/security.properties:/srv/tomcat/webapps/aggregate/WEB-INF/classes/security.properties \
- opendatakit
-}
-
-start_post() {
- /usr/local/bin/spotter-appmgr update-hosts opendatakit
-}
-
-stop() {
- /usr/bin/docker stop opendatakit
-}
diff --git a/opendatakit/srv/opendatakit/conf/jdbc.properties b/opendatakit/srv/opendatakit/conf/jdbc.properties
deleted file mode 100644
index 43d8134..0000000
--- a/opendatakit/srv/opendatakit/conf/jdbc.properties
+++ /dev/null
@@ -1,6 +0,0 @@
-jdbc.driverClassName=org.postgresql.Driver
-jdbc.resourceName=jdbc/odk_aggregate
-jdbc.url=jdbc:postgresql://postgres/opendatakit?autoDeserialize=true
-jdbc.username=opendatakit
-jdbc.password=${OPENDATAKIT_PWD}
-jdbc.schema=public
diff --git a/opendatakit/srv/opendatakit/update-url.sh b/opendatakit/srv/opendatakit/update-url.sh
deleted file mode 100644
index 76e59e9..0000000
--- a/opendatakit/srv/opendatakit/update-url.sh
+++ /dev/null
@@ -1,5 +0,0 @@
-#!/bin/sh
-
-sed -i "s|\(^\s\+proxyName\).*|\1=\"${1}\"|g" /srv/opendatakit/conf/server.xml
-sed -i "s|\(^\s\+proxyPort\).*|\1=\"${2}\"|g" /srv/opendatakit/conf/server.xml
-sed -i "s|^security\.server\.securePort.*|security.server.securePort=${2}|" /srv/opendatakit/conf/security.properties