2019-04-21 21:13:03 +00:00
|
|
|
#!/bin/bash
|
2021-01-29 17:32:13 +00:00
|
|
|
#
|
|
|
|
# Copyright (C) Markus Witt
|
|
|
|
#
|
|
|
|
# SPDX-License-Identifier: CC0-1.0
|
2019-04-13 21:49:49 +00:00
|
|
|
set -eu
|
|
|
|
|
2019-04-21 21:13:03 +00:00
|
|
|
WAIT_DB_HOST=${TRAVELYNX_DB_HOST}
|
|
|
|
WAIT_DB_PORT=5432
|
|
|
|
|
2019-05-03 20:50:59 +00:00
|
|
|
check_config() {
|
|
|
|
if [ ! -f travelynx.conf ]
|
|
|
|
then
|
|
|
|
echo "The configuration file is missing"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2019-04-21 21:13:03 +00:00
|
|
|
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
|
2019-05-03 20:50:59 +00:00
|
|
|
else
|
|
|
|
echo "Can't reach DB @ ${WAIT_DB_HOST}:${WAIT_DB_PORT}"
|
2019-04-21 21:13:03 +00:00
|
|
|
fi
|
|
|
|
sleep 1
|
|
|
|
done
|
|
|
|
set -e
|
|
|
|
}
|
|
|
|
|
2019-05-03 20:50:59 +00:00
|
|
|
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
|
2019-04-13 21:49:49 +00:00
|
|
|
|
2019-05-03 20:50:59 +00:00
|
|
|
perl index.pl database migrate
|
2019-04-16 16:48:32 +00:00
|
|
|
|
2019-05-03 20:50:59 +00:00
|
|
|
exec /usr/local/bin/hypnotoad -f index.pl
|
|
|
|
}
|
|
|
|
|
|
|
|
run_cron() {
|
|
|
|
exec perl index.pl worker
|
|
|
|
}
|
|
|
|
|
|
|
|
check_config
|
2019-04-21 21:13:03 +00:00
|
|
|
wait_for_db
|
|
|
|
|
2019-05-03 20:50:59 +00:00
|
|
|
if [ "${CRON:-0}" -ne "0" ]
|
|
|
|
then
|
|
|
|
run_cron
|
|
|
|
fi
|
2019-04-13 21:49:49 +00:00
|
|
|
|
2021-01-29 17:32:13 +00:00
|
|
|
run_app
|