summaryrefslogtreecommitdiff
path: root/docker-run.sh
blob: 29ffa7b7625eed903314fbb3680735649ed6f1f2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#!/bin/bash
set -eu

WAIT_DB_HOST=${TRAVELYNX_DB_HOST}
WAIT_DB_PORT=5432

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
		fi
		sleep 1
	done
	set -e
}

if [ ! -f travelynx.conf ]
then
	echo "The configuration file is missing"
	exit 1
fi

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

wait_for_db

perl index.pl database migrate

exec /usr/local/bin/hypnotoad -f index.pl