foodsoft/docker-entrypoint.sh
Patrick Gansterer 22fd814193 Add a script to read all databases with a prefix from the database server
When passing a value via the FOODSOFT_DB_PREFIX environment variable the
FOODSOFT_FOODCOOPS environment variable will be overwritten with a list
of databases starting with the given prefix.

This can be used to dynamically generate the app_config.yml in a multicoop
installation and avoid listing all instances manually.
2022-05-27 23:10:07 +02:00

26 lines
608 B
Bash
Executable file

#!/bin/sh
set -e
# allow re-using the instance - https://stackoverflow.com/a/38732187/2866660
if [ -f tmp/pids/server.pid ]; then
rm tmp/pids/server.pid
fi
if [ ! -z "${FOODSOFT_DB_PREFIX}" ] || [ ! -z "${FOODSOFT_DB_PREFIX_FILE}" ]; then
FOODSOFT_FOODCOOPS=`BUNDLE_CONFIG=/dev/null bundle exec ruby script/list_databases`
fi
if [ -e app_config.defaults.yml ] ; then
cat app_config.defaults.yml > config/app_config.yml
for FOODCOOP in $FOODSOFT_FOODCOOPS; do
cat << EOF >> config/app_config.yml
$FOODCOOP:
<<: *defaults
database:
database: foodsoft_$FOODCOOP
EOF
done
fi
exec "$@"