diff options
author | Daniel Friesel <derf@finalrewind.org> | 2019-05-05 11:22:38 +0200 |
---|---|---|
committer | Daniel Friesel <derf@finalrewind.org> | 2019-05-05 11:22:38 +0200 |
commit | 8c23c960426bad133484bf127f5fc5b56af8e8c7 (patch) | |
tree | d96d4ef00707088913fed0b97fb03eb56a2064c0 /docker-run.sh | |
parent | 4696f8d68e130632cbcdb14c2bb1dfe71355e9f6 (diff) | |
parent | a1a0f33cab731eb60051af6bd5ae78cd6660b76f (diff) |
Merge branch 'feuerrot-dockerize'
Addresses #4
Diffstat (limited to 'docker-run.sh')
-rwxr-xr-x | docker-run.sh | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/docker-run.sh b/docker-run.sh new file mode 100755 index 0000000..696aa35 --- /dev/null +++ b/docker-run.sh @@ -0,0 +1,58 @@ +#!/bin/bash +set -eu + +WAIT_DB_HOST=${TRAVELYNX_DB_HOST} +WAIT_DB_PORT=5432 + +check_config() { + if [ ! -f travelynx.conf ] + then + echo "The configuration file is missing" + exit 1 + fi +} + +wait_for_db() { + set +e + for i in $(seq 1 ${WAIT_DB_TIMEOUT:-5}) + do + (echo >/dev/tcp/${WAIT_DB_HOST}/${WAIT_DB_PORT}) &>/dev/null + if [ $? -eq 0 ]; then + break + else + echo "Can't reach DB @ ${WAIT_DB_HOST}:${WAIT_DB_PORT}" + fi + sleep 1 + done + set -e +} + +run_app() { + if [ \ + "${TRAVELYNX_MAIL_DISABLE:-0}" -eq 0 \ + -a "${TRAVELYNX_MAIL_HOST:-unset}" != "unset" \ + ] + then + export EMAIL_SENDER_TRANSPORT=SMTP + export EMAIL_SENDER_TRANSPORT_HOST=${TRAVELYNX_MAIL_HOST} + export EMAIL_SENDER_TRANSPORT_PORT=${TRAVELYNX_MAIL_PORT:-25} + fi + + perl index.pl database migrate + + exec /usr/local/bin/hypnotoad -f index.pl +} + +run_cron() { + exec perl index.pl worker +} + +check_config +wait_for_db + +if [ "${CRON:-0}" -ne "0" ] +then + run_cron +fi + +run_app
\ No newline at end of file |