24 lines
902 B
Bash
Executable File
24 lines
902 B
Bash
Executable File
#!/bin/sh
|
|
|
|
SOURCE_DIR=$(realpath $(dirname "${0}"))/odkbuild
|
|
|
|
# Check prerequisites
|
|
docker image ls | grep -q postgres || $(realpath $(dirname "${0}"))/postgres.sh
|
|
docker image ls | grep -q ruby || $(realpath $(dirname "${0}"))/ruby.sh
|
|
service postgres start
|
|
|
|
# Build Docker container
|
|
docker build -t odkbuild ${SOURCE_DIR}
|
|
cp ${SOURCE_DIR}/etc/init.d/odkbuild /etc/init.d/odkbuild
|
|
rc-update -u
|
|
|
|
# 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/odkbuild/conf
|
|
envsubst <${SOURCE_DIR}/srv/odkbuild/conf/config.yml >/srv/odkbuild/conf/config.yml
|
|
docker run --rm -h odkbuild --link postgres -v /srv/odkbuild/conf/config.yml:/srv/odkbuild/config.yml -w /srv/odkbuild odkbuild rake db:migrate
|