LXCize ODK setup
This commit is contained in:
parent
365f983c2d
commit
57ecc71ebe
@ -1,21 +1,14 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
SOURCE_DIR=$(realpath $(dirname "${0}"))/opendatakit
|
SOURCE_DIR=$(realpath $(dirname "${0}"))/setup
|
||||||
|
|
||||||
# Check prerequisites
|
# Check prerequisites
|
||||||
lxc-ls | grep -q postgres || $(realpath $(dirname "${0}"))/postgres.sh
|
[ ! -e /run/openrc/started/postgres ] && service postgres start && STOP_POSTGRES=1
|
||||||
lxc-ls | grep -q postfix || $(realpath $(dirname "${0}"))/postfix.sh
|
|
||||||
service postgres start
|
|
||||||
|
|
||||||
# Build Docker container
|
|
||||||
docker build -t opendatakit ${SOURCE_DIR}
|
|
||||||
cp ${SOURCE_DIR}/etc/init.d/opendatakit /etc/init.d/opendatakit
|
|
||||||
rc-update -u
|
|
||||||
|
|
||||||
# Create databases
|
# Create databases
|
||||||
export OPENDATAKIT_PWD=$(head -c 18 /dev/urandom | base64)
|
export OPENDATAKIT_PWD=$(head -c 18 /dev/urandom | base64)
|
||||||
envsubst <${SOURCE_DIR}/createdb.sql | docker exec -i postgres psql
|
envsubst <${SOURCE_DIR}/createdb.sql | lxc-attach -u 5432 -g 5432 postgres -- psql
|
||||||
|
|
||||||
# Configure OpenDataKit
|
# Configure OpenDataKit
|
||||||
export OPENDATAKIT_ADMIN_USER=admin
|
export OPENDATAKIT_ADMIN_USER=admin
|
||||||
@ -26,9 +19,13 @@ envsubst <${SOURCE_DIR}/srv/opendatakit/conf/security.properties >/srv/opendatak
|
|||||||
cp ${SOURCE_DIR}/srv/opendatakit/conf/server.xml /srv/opendatakit/conf/server.xml
|
cp ${SOURCE_DIR}/srv/opendatakit/conf/server.xml /srv/opendatakit/conf/server.xml
|
||||||
chown -R 8015:8015 /srv/opendatakit/conf
|
chown -R 8015:8015 /srv/opendatakit/conf
|
||||||
|
|
||||||
|
# Install service
|
||||||
|
cp ${SOURCE_DIR}/etc/init.d/opendatakit /etc/init.d/opendatakit
|
||||||
|
rc-update -u
|
||||||
|
|
||||||
# Populate database
|
# Populate database
|
||||||
service opendatakit start
|
service opendatakit start
|
||||||
until docker logs opendatakit 2>&1 | grep -q 'org.apache.catalina.startup.Catalina.start'; do
|
until grep -q 'org.apache.catalina.startup.Catalina.start' /var/log/lxc/opendatakit.log; do
|
||||||
sleep 1
|
sleep 1
|
||||||
done
|
done
|
||||||
service opendatakit stop
|
service opendatakit stop
|
||||||
@ -38,9 +35,8 @@ 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_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_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 " -")
|
export OPENDATAKIT_ADMIN_DIGEST_HASH=$(echo -n "${OPENDATAKIT_ADMIN_USER}:${OPENDATAKIT_ADMIN_REALM}:${OPENDATAKIT_ADMIN_PWD}" | md5sum | tr -d " -")
|
||||||
envsubst <${SOURCE_DIR}/adminpwd.sql | docker exec -i postgres psql opendatakit
|
envsubst <${SOURCE_DIR}/adminpwd.sql | lxc-attach -u 5432 -g 5432 postgres -- psql opendatakit
|
||||||
vmmgr update-login opendatakit "${OPENDATAKIT_ADMIN_USER}" "${OPENDATAKIT_ADMIN_PWD}"
|
vmmgr update-login opendatakit "${OPENDATAKIT_ADMIN_USER}" "${OPENDATAKIT_ADMIN_PWD}"
|
||||||
|
|
||||||
# Stop services required for build
|
# Stop services required for build
|
||||||
service postgres stop
|
[ ! -z ${STOP_POSTGRES} ] && service postgres stop
|
||||||
service postfix stop
|
|
||||||
|
@ -1,21 +1,13 @@
|
|||||||
#!/sbin/openrc-run
|
#!/sbin/openrc-run
|
||||||
|
|
||||||
description="OpenDataKit Aggregate docker container"
|
description="OpenDataKit Aggregate container"
|
||||||
|
|
||||||
depend() {
|
depend() {
|
||||||
need docker postfix postgres
|
need cgroups postgres
|
||||||
}
|
}
|
||||||
|
|
||||||
start() {
|
start() {
|
||||||
/usr/bin/docker run -d --rm \
|
lxc-start opendatakit
|
||||||
--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/ROOT/WEB-INF/classes/jdbc.properties \
|
|
||||||
-v /srv/opendatakit/conf/security.properties:/srv/tomcat/webapps/ROOT/WEB-INF/classes/security.properties \
|
|
||||||
opendatakit
|
|
||||||
}
|
}
|
||||||
|
|
||||||
start_post() {
|
start_post() {
|
||||||
@ -27,5 +19,5 @@ stop_pre() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
stop() {
|
stop() {
|
||||||
/usr/bin/docker stop opendatakit
|
lxc-stop opendatakit
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user