Spotter-VM/omk.sh

28 lines
923 B
Bash
Executable File

#!/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}
# 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
# 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}/" "${OMK_ADMIN_USER}" "${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}"