summaryrefslogtreecommitdiff
path: root/docker-run.sh
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2022-02-19 16:32:34 +0100
committerDaniel Friesel <derf@finalrewind.org>2022-02-19 16:32:34 +0100
commit8ec78343e72d4a5d86de94ff7bf747ccf67ef2fc (patch)
tree6419b1d8881a9f71a9b0f28a8afd0d698847175e /docker-run.sh
parent4233dd1d73638738a34392ba1312e6979f3c8340 (diff)
Update docker setup. It's simple, and it works, but it's not best practice
Closes #4
Diffstat (limited to 'docker-run.sh')
-rwxr-xr-xdocker-run.sh62
1 files changed, 11 insertions, 51 deletions
diff --git a/docker-run.sh b/docker-run.sh
index c6746c3..a75d5a0 100755
--- a/docker-run.sh
+++ b/docker-run.sh
@@ -1,62 +1,22 @@
-#!/bin/bash
+#!/bin/sh
#
# Copyright (C) Markus Witt
+# Copyright (C) Daniel Friesel
#
# SPDX-License-Identifier: CC0-1.0
-set -eu
-WAIT_DB_HOST=${TRAVELYNX_DB_HOST}
-WAIT_DB_PORT=5432
+set -e
-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
+if ! [ -r travelynx.conf ]; then
+ echo "Configuration file (travelynx.conf) is missing. Did you set up the '/local' mountpoint?"
+ exit 1
+fi
- exec /usr/local/bin/hypnotoad -f index.pl
-}
+. local/email-transport.sh
-run_cron() {
+if [ "$1" = worker ]; then
exec perl index.pl worker
-}
-
-check_config
-wait_for_db
-
-if [ "${CRON:-0}" -ne "0" ]
-then
- run_cron
fi
-run_app
+perl index.pl database migrate
+exec hypnotoad -f index.pl