From ed3aeb60d8e5f554ad07ebfe57d241b7bdaa32f4 Mon Sep 17 00:00:00 2001 From: Disassembler Date: Sat, 5 Oct 2019 15:07:53 +0200 Subject: [PATCH] Rework OpenMapKit --- lxc-apps/openmapkit/install.sh | 12 ++++-------- .../openmapkit/install/etc/init.d/openmapkit | 19 ------------------- .../openmapkit/conf => omk_conf}/settings.js | 0 lxc-apps/openmapkit/meta | 18 ++++++++++++++++++ lxc-apps/openmapkit/uninstall.sh | 10 ++-------- 5 files changed, 24 insertions(+), 35 deletions(-) delete mode 100755 lxc-apps/openmapkit/install/etc/init.d/openmapkit rename lxc-apps/openmapkit/install/{srv/openmapkit/conf => omk_conf}/settings.js (100%) create mode 100644 lxc-apps/openmapkit/meta diff --git a/lxc-apps/openmapkit/install.sh b/lxc-apps/openmapkit/install.sh index a8151cb..1b0900e 100755 --- a/lxc-apps/openmapkit/install.sh +++ b/lxc-apps/openmapkit/install.sh @@ -6,14 +6,10 @@ cd $(realpath $(dirname "${0}"))/install # Configure OpenMapKit export OPENMAPKIT_ADMIN_USER="admin" export OPENMAPKIT_ADMIN_PWD=$(head -c 12 /dev/urandom | base64 | tr -d '+/=') -mkdir -p /srv/openmapkit/conf /srv/openmapkit/data -chown -R 8007:8007 /srv/openmapkit/data -cp -rp /var/lib/lxc/openmapkit/openmapkit/srv/openmapkit/data/. /srv/openmapkit/data -envsubst /srv/openmapkit/conf/settings.js - -# Install service -cp etc/init.d/openmapkit /etc/init.d/openmapkit -rc-update -u +mkdir -p /srv/openmapkit/omk_conf /srv/openmapkit/omk_data +chown -R 108007:108007 /srv/openmapkit/omk_data +lxc-execute openmapkit -- tar -cC /srv/openmapkit/data . | tar -xC /srv/openmapkit/omk_data +envsubst /srv/openmapkit/omk_conf/settings.js # Register application vmmgr register-app openmapkit omk "${OPENMAPKIT_ADMIN_USER}" "${OPENMAPKIT_ADMIN_PWD}" diff --git a/lxc-apps/openmapkit/install/etc/init.d/openmapkit b/lxc-apps/openmapkit/install/etc/init.d/openmapkit deleted file mode 100755 index 7fe3243..0000000 --- a/lxc-apps/openmapkit/install/etc/init.d/openmapkit +++ /dev/null @@ -1,19 +0,0 @@ -#!/sbin/openrc-run - -description="OpenMapKit container" - -start() { - lxc-start openmapkit -} - -start_post() { - vmmgr register-proxy openmapkit -} - -stop_pre() { - vmmgr unregister-proxy openmapkit -} - -stop() { - lxc-stop openmapkit -} diff --git a/lxc-apps/openmapkit/install/srv/openmapkit/conf/settings.js b/lxc-apps/openmapkit/install/omk_conf/settings.js similarity index 100% rename from lxc-apps/openmapkit/install/srv/openmapkit/conf/settings.js rename to lxc-apps/openmapkit/install/omk_conf/settings.js diff --git a/lxc-apps/openmapkit/meta b/lxc-apps/openmapkit/meta new file mode 100644 index 0000000..dc7adba --- /dev/null +++ b/lxc-apps/openmapkit/meta @@ -0,0 +1,18 @@ +{ + "version": "0.12.0-190620", + "meta": { + "title": "OpenMapKit", + "desc-cs": "Sběr mapových dat", + "desc-en": "Map data collection", + "license": "GPL", + }, + "containers": { + "openmapkit": { + "image": "openmapkit_0.12.0-190620", + "mounts": [ + ["FILE", "/srv/openmapkit/omk_conf/settings.js", "/srv/openmapkit/settings.js"], + ["DIR", "/srv/openmapkit/omk_data", "/srv/openmapkit/data"] + ] + } + } +} diff --git a/lxc-apps/openmapkit/uninstall.sh b/lxc-apps/openmapkit/uninstall.sh index 0e5d4c0..dffba05 100755 --- a/lxc-apps/openmapkit/uninstall.sh +++ b/lxc-apps/openmapkit/uninstall.sh @@ -1,14 +1,8 @@ #!/bin/sh set -ev -# Remove service -rm -f /etc/init.d/openmapkit -rc-update -u - -# Drop database and user -[ ! -e /run/openrc/started/postgres ] && service postgres start && STOP_POSTGRES=1 -echo 'DROP DATABASE IF EXISTS openmapkit; DROP ROLE IF EXISTS openmapkit;' | lxc-attach -u 5432 -g 5432 postgres -- psql -[ ! -z ${STOP_POSTGRES} ] && service postgres stop +# Remove persistent data +rm -rf /srv/openmapkit # Unregister application vmmgr unregister-app openmapkit