Shorten OpenMapKit handle

This commit is contained in:
Disassembler 2018-03-25 14:42:23 +02:00
parent 459d0f711e
commit 70bb77e11e
Signed by: Disassembler
GPG Key ID: 524BD33A0EE29499
8 changed files with 58 additions and 58 deletions

View File

@ -18,7 +18,7 @@ ${SOURCE_DIR}/mifosx.sh
${SOURCE_DIR}/motech.sh
${SOURCE_DIR}/odkbuild.sh
${SOURCE_DIR}/odk.sh
${SOURCE_DIR}/openmapkit.sh
${SOURCE_DIR}/omk.sh
${SOURCE_DIR}/pandora.sh
${SOURCE_DIR}/sahana.sh
${SOURCE_DIR}/sambro.sh

View File

@ -102,7 +102,7 @@
</ul>
</div>
<div class="c" id="openmapkit">
<div class="c" id="omk">
<h2><a href="#"><img src="img/OMK.png" alt="Open Map Kit" title="Open Map Kit">OpenMapKit Server</a></h2>
<p><strong>Sběr dat s pomocí smartphone</strong>.<br>
<ul>
@ -121,7 +121,7 @@
</ul>
</div>
<div class="c" id="openmapkit-clients">
<div class="c" id="omk-clients">
<h2><a href="#"><img src="img/OMK.png" alt="Open Map Kit" title="Open Map Kit">OpenMapKit</a></h2>
<p>Mobilní aplikace<br>
<a href="https://play.google.com/store/apps/details?id=org.odk.collect.android"><img src="img/android.png" class="ico" alt="ODK Collect">ODK Collect pro Android</a><br>

23
omk.sh Executable file
View File

@ -0,0 +1,23 @@
#!/bin/sh
SOURCE_DIR=$(realpath $(dirname "${0}"))/omk
# Build Docker container
docker build -t omk ${SOURCE_DIR}
# Configure OpenMapKit
export OMK_ADMIN_USER="admin"
export OMK_ADMIN_PWD=$(head -c 12 /dev/urandom | base64)
mkdir -p /srv/omk/conf /srv/omk/data/deployments /srv/omk/data/forms /srv/omk/data/submissions
chown -R 8007:8007 /srv/omk/data
envsubst <${SOURCE_DIR}/srv/omk/conf/settings.js >/srv/omk/conf/settings.js
# Configure OpenMapKit service
cp ${SOURCE_DIR}/etc/init.d/omk /etc/init.d/omk
rc-update add omk
service omk start
# Add application definition
spotter-appmgr add-app omk "https://omk.{host}/" admin "${OMK_ADMIN_PWD}"
spotter-appmgr add-app omk-clients -p clienturl "https://omk.{host}"
spotter-appmgr add-app geoodk-clients -p clienturl "https://omk.{host}"

View File

@ -26,8 +26,8 @@ RUN \
# Install build dependencies
apk --no-cache add --virtual .deps build-base git py2-pip yarn \
# Clone OpenMapKit
&& git clone --depth 1 https://github.com/AmericanRedCross/OpenMapKitServer /srv/openmapkit \
&& cd /srv/openmapkit \
&& git clone --depth 1 https://github.com/AmericanRedCross/OpenMapKitServer /srv/omk \
&& cd /srv/omk \
&& git submodule update --init \
# Install OpenMapKit dependencies
&& pip install -r requirements.txt \
@ -35,17 +35,17 @@ RUN \
&& yarn \
# Create OS user
&& addgroup -S -g 8007 omk \
&& adduser -S -u 8007 -h /srv/openmapkit -s /bin/false -g omk -G omk omk \
&& chown -R omk:omk /srv/openmapkit \
&& adduser -S -u 8007 -h /srv/omk -s /bin/false -g omk -G omk omk \
&& chown -R omk:omk /srv/omk \
# Cleanup
&& apk --no-cache del .deps \
&& find /srv/openmapkit -name '.git*' -exec rm -rf {} + \
&& find /srv/omk -name '.git*' -exec rm -rf {} + \
&& rm -rf /usr/local/share/.cache \
&& rm -rf /root/.cache /root/.config /root/.node-gyp /root/.npm
VOLUME ["/srv/openmapkit/data"]
VOLUME ["/srv/omk/data"]
EXPOSE 8080
USER omk
ENV NODE_ENV production
CMD ["node", "/srv/openmapkit/server.js"]
CMD ["node", "/srv/omk/server.js"]

25
omk/etc/init.d/omk Executable file
View File

@ -0,0 +1,25 @@
#!/sbin/openrc-run
description="OpenMapKit docker container"
depend() {
need docker net
use dns logger netmount
}
start() {
/usr/bin/docker run -d --rm \
--name omk \
-h omk \
-v /srv/omk/conf/settings.js:/srv/omk/settings.js \
-v /srv/omk/data:/srv/omk/data \
omk
}
start_post() {
/usr/local/bin/spotter-appmgr update-hosts omk
}
stop() {
/usr/bin/docker stop omk
}

View File

@ -1,23 +0,0 @@
#!/bin/sh
SOURCE_DIR=$(realpath $(dirname "${0}"))/openmapkit
# Build Docker container
docker build -t openmapkit ${SOURCE_DIR}
# Configure OpenMapKit
export OMK_ADMIN_USER="admin"
export OMK_ADMIN_PWD=$(head -c 12 /dev/urandom | base64)
mkdir -p /srv/openmapkit/conf /srv/openmapkit/data/deployments /srv/openmapkit/data/forms /srv/openmapkit/data/submissions
chown -R 8007:8007 /srv/openmapkit/data
envsubst <${SOURCE_DIR}/srv/openmapkit/conf/settings.js >/srv/openmapkit/conf/settings.js
# Configure OpenMapKit service
cp ${SOURCE_DIR}/etc/init.d/openmapkit /etc/init.d/openmapkit
rc-update add openmapkit
service openmapkit start
# Add application definition
spotter-appmgr add-app openmapkit "https://openmapkit.{host}/" admin "${OMK_ADMIN_PWD}"
spotter-appmgr add-app openmapkit-clients -p clienturl "https://openmapkit.{host}"
spotter-appmgr add-app geoodk-clients -p clienturl "https://openmapkit.{host}"

View File

@ -1,25 +0,0 @@
#!/sbin/openrc-run
description="OpenMapKit docker container"
depend() {
need docker net
use dns logger netmount
}
start() {
/usr/bin/docker run -d --rm \
--name openmapkit \
-h openmapkit \
-v /srv/openmapkit/conf/settings.js:/srv/openmapkit/settings.js \
-v /srv/openmapkit/data:/srv/openmapkit/data \
openmapkit
}
start_post() {
/usr/local/bin/spotter-appmgr update-hosts openmapkit
}
stop() {
/usr/bin/docker stop openmapkit
}