2018-03-16 18:31:34 +01:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
SOURCE_DIR=$(realpath $(dirname "${0}"))/opendatakit-build
|
|
|
|
|
|
|
|
# Check prerequisites
|
|
|
|
docker image ls | grep -q postgres || $(realpath $(dirname "${0}"))/postgres.sh
|
|
|
|
docker image ls | grep -q ruby || $(realpath $(dirname "${0}"))/ruby.sh
|
|
|
|
|
|
|
|
# Build Docker container
|
|
|
|
docker build -t opendatakit-build ${SOURCE_DIR}
|
|
|
|
|
|
|
|
# Create databases
|
|
|
|
export ODKBUILD_PWD=$(head -c 18 /dev/urandom | base64)
|
|
|
|
envsubst <${SOURCE_DIR}/createdb.sql | docker exec -i postgres psql
|
|
|
|
|
|
|
|
# Configure OpenDataKit Build
|
|
|
|
export ODKBUILD_COOKIE_SECRET=$(head -c 8 /dev/urandom | hexdump -e '"%x"')
|
|
|
|
mkdir -p /srv/opendatakit-build/conf
|
|
|
|
envsubst <${SOURCE_DIR}/srv/opendatakit-build/conf/config.yml >/srv/opendatakit-build/conf/config.yml
|
|
|
|
docker run --rm -h opendatakit-build --link postgres -v /srv/opendatakit-build/conf/config.yml:/srv/odkbuild/config.yml opendatakit-build rake db:migrate
|
|
|
|
|
|
|
|
# Create OpenDataKit service
|
|
|
|
cp ${SOURCE_DIR}/etc/init.d/opendatakit-build /etc/init.d/opendatakit-build
|
|
|
|
rc-update add opendatakit-build
|
|
|
|
service opendatakit-build start
|
|
|
|
|
2018-03-25 23:16:06 +02:00
|
|
|
# Add application definition
|
|
|
|
spotter-appmgr add-app opendatakit-build "https://opendatakit-build.{host}/"
|