diff --git a/00-install.sh b/00-install.sh index 8c9bba4..9a0fa50 100755 --- a/00-install.sh +++ b/00-install.sh @@ -19,7 +19,7 @@ ${SOURCE_DIR}/mifosx.sh ${SOURCE_DIR}/motech.sh ${SOURCE_DIR}/opendatakit-build.sh ${SOURCE_DIR}/opendatakit.sh -${SOURCE_DIR}/omk.sh +${SOURCE_DIR}/openmapkit.sh ${SOURCE_DIR}/pandora.sh ${SOURCE_DIR}/sahana.sh ${SOURCE_DIR}/sambro.sh diff --git a/omk.sh b/omk.sh deleted file mode 100755 index e090563..0000000 --- a/omk.sh +++ /dev/null @@ -1,20 +0,0 @@ -#!/bin/sh - -SOURCE_DIR=$(realpath $(dirname "${0}"))/omk - -# Check prerequisites -docker image ls | grep -q java || $(realpath $(dirname "${0}"))/java.sh - -# Build Docker container -docker build -t omk ${SOURCE_DIR} -cp ${SOURCE_DIR}/etc/init.d/omk /etc/init.d/omk -rc-update -u - -# 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 -chown -R 8007:8007 /srv/omk/data -docker run --rm -v /srv/omk/data:/mnt/data omk cp -rp /srv/omk/data/. /mnt/data -envsubst <${SOURCE_DIR}/srv/omk/conf/settings.js >/srv/omk/conf/settings.js -spotter-appmgr update-login omk "${OMK_ADMIN_USER}" "${OMK_ADMIN_PWD}" diff --git a/omk/etc/init.d/omk b/omk/etc/init.d/omk deleted file mode 100755 index 98c2a28..0000000 --- a/omk/etc/init.d/omk +++ /dev/null @@ -1,28 +0,0 @@ -#!/sbin/openrc-run - -description="OpenMapKit docker container" - -depend() { - need docker -} - -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/bin/spotter-appmgr register-proxy omk -} - -stop_pre() { - /usr/bin/spotter-appmgr unregister-proxy omk -} - -stop() { - /usr/bin/docker stop omk -} diff --git a/openmapkit.sh b/openmapkit.sh new file mode 100755 index 0000000..a4ff4ec --- /dev/null +++ b/openmapkit.sh @@ -0,0 +1,20 @@ +#!/bin/sh + +SOURCE_DIR=$(realpath $(dirname "${0}"))/openmapkit + +# Check prerequisites +docker image ls | grep -q java || $(realpath $(dirname "${0}"))/java.sh + +# Build Docker container +docker build -t openmapkit ${SOURCE_DIR} +cp ${SOURCE_DIR}/etc/init.d/openmapkit /etc/init.d/openmapkit +rc-update -u + +# Configure OpenMapKit +export OPENMAPKIT_ADMIN_USER="admin" +export OPENMAPKIT_ADMIN_PWD=$(head -c 12 /dev/urandom | base64) +mkdir -p /srv/openmapkit/conf /srv/openmapkit/data +chown -R 8007:8007 /srv/openmapkit/data +docker run --rm -v /srv/openmapkit/data:/mnt/data openmapkit cp -rp /srv/openmapkit/data/. /mnt/data +envsubst <${SOURCE_DIR}/srv/openmapkit/conf/settings.js >/srv/openmapkit/conf/settings.js +spotter-appmgr update-login openmapkit "${OPENMAPKIT_ADMIN_USER}" "${OPENMAPKIT_ADMIN_PWD}" diff --git a/omk/Dockerfile b/openmapkit/Dockerfile similarity index 72% rename from omk/Dockerfile rename to openmapkit/Dockerfile index abef4a1..4a38173 100644 --- a/omk/Dockerfile +++ b/openmapkit/Dockerfile @@ -17,8 +17,8 @@ RUN \ # Install build dependencies apk --no-cache add --virtual .deps build-base git py2-pip \ # Clone OpenMapKit - && git clone --depth 1 https://github.com/posm/OpenMapKitServer /srv/omk \ - && cd /srv/omk \ + && git clone --depth 1 https://github.com/posm/OpenMapKitServer /srv/openmapkit \ + && cd /srv/openmapkit \ && git submodule update --init \ # Install OpenMapKit dependencies && pip install -r requirements.txt \ @@ -26,17 +26,17 @@ RUN \ && npm install \ # Create OS user && addgroup -S -g 8007 omk \ - && adduser -S -u 8007 -h /srv/omk -s /bin/false -g omk -G omk omk \ - && chown -R omk:omk /srv/omk \ + && adduser -S -u 8007 -h /srv/openmapkit -s /bin/false -g omk -G omk omk \ + && chown -R omk:omk /srv/openmapkit \ # Cleanup && apk --no-cache del .deps \ - && find /srv/omk -name '.git*' -exec rm -rf {} + \ + && find /srv/openmapkit -name '.git*' -exec rm -rf {} + \ && rm -rf /usr/local/share/.cache \ && rm -rf /root/.cache /root/.config /root/.node-gyp /root/.npm -VOLUME ["/srv/omk/data"] +VOLUME ["/srv/openmapkit/data"] EXPOSE 8080 USER omk ENV NODE_ENV production -CMD ["node", "/srv/omk/server.js"] +CMD ["node", "/srv/openmapkit/server.js"] diff --git a/openmapkit/etc/init.d/openmapkit b/openmapkit/etc/init.d/openmapkit new file mode 100755 index 0000000..9a07ca3 --- /dev/null +++ b/openmapkit/etc/init.d/openmapkit @@ -0,0 +1,28 @@ +#!/sbin/openrc-run + +description="OpenMapKit docker container" + +depend() { + need docker +} + +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/bin/spotter-appmgr register-proxy openmapkit +} + +stop_pre() { + /usr/bin/spotter-appmgr unregister-proxy openmapkit +} + +stop() { + /usr/bin/docker stop openmapkit +} diff --git a/omk/srv/omk/conf/settings.js b/openmapkit/srv/openmapkit/conf/settings.js similarity index 86% rename from omk/srv/omk/conf/settings.js rename to openmapkit/srv/openmapkit/conf/settings.js index 6320c77..e9bbea9 100644 --- a/omk/srv/omk/conf/settings.js +++ b/openmapkit/srv/openmapkit/conf/settings.js @@ -13,8 +13,8 @@ module.exports = { // To do simple authentication, you can have an object like so: auth: { - user: '${OMK_ADMIN_USER}', - pass: '${OMK_ADMIN_PWD}' + user: '${OPENMAPKIT_ADMIN_USER}', + pass: '${OPENMAPKIT_ADMIN_PWD}' } };