forked from foodcoops/foodsoft
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdocker-entrypoint.sh
executable file
·36 lines (28 loc) · 962 Bytes
/
docker-entrypoint.sh
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
#!/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
FOODSOFT_FOODCOOPS_REGEX=`echo $FOODSOFT_FOODCOOPS | sed 's/ /|/g'`
sed -i "s/__FOODCOOPS__/$FOODSOFT_FOODCOOPS_REGEX/g" config/routes.rb
for plugin in $(ls plugins); do
if [ -f "plugins/$plugin/config/routes.rb" ]; then
sed -i "s/__FOODCOOPS__/$FOODSOFT_FOODCOOPS_REGEX/g" plugins/$plugin/config/routes.rb
fi
done
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 gosu nobody:nogroup "$@"