mirror of
https://github.com/Telecominfraproject/wlan-cloud-ucentralsec.git
synced 2025-10-29 09:52:29 +00:00
* Add wait-for-postgres.sh wrapper script Signed-off-by: Johann Hoffmann <johann.hoffmann@mailbox.org> * Copy wait-for-postgres.sh into Docker image Signed-off-by: Johann Hoffmann <johann.hoffmann@mailbox.org>
27 lines
659 B
Bash
Executable File
27 lines
659 B
Bash
Executable File
#!/bin/sh
|
|
# wait-for-postgres.sh
|
|
|
|
set -e
|
|
|
|
host="$1"
|
|
shift
|
|
|
|
export PGUSER=$(grep 'storage.type.postgresql.username' $OWSEC_CONFIG/owsec.properties | awk -F '= ' '{print $2}')
|
|
export PGPASSWORD=$(grep 'storage.type.postgresql.password' $OWSEC_CONFIG/owsec.properties | awk -F '= ' '{print $2}')
|
|
|
|
until psql -h "$host" -c '\q'; do
|
|
>&2 echo "Postgres is unavailable - sleeping"
|
|
sleep 1
|
|
done
|
|
|
|
>&2 echo "Postgres is up - executing command"
|
|
|
|
if [ "$1" = '/openwifi/owsec' -a "$(id -u)" = '0' ]; then
|
|
if [ "$RUN_CHOWN" = 'true' ]; then
|
|
chown -R "$OWSEC_USER": "$OWSEC_ROOT" "$OWSEC_CONFIG"
|
|
fi
|
|
exec su-exec "$OWSEC_USER" "$@"
|
|
fi
|
|
|
|
exec "$@"
|