Commit 3193aa69 authored by maximilianhuber's avatar maximilianhuber

fix(Docker): only wait for postgresql if not on localhost

the command `docker run -p 8081:80 fossology/fossology` did not work,
since postgresql was not startet
parent e3ebe46a
......@@ -27,15 +27,6 @@ if [ "$FOSSOLOGY_DB_PASSWORD" ]; then
db_password="$FOSSOLOGY_DB_PASSWORD"
fi
testForPostgres(){
PGPASSWORD=$db_password psql -h "$db_host" "$db_name" "$db_user" -c '\l' >/dev/null
return $?
}
until testForPostgres; do
>&2 echo "Postgres is unavailable - sleeping"
sleep 1
done
# Write configuration
cat <<EOM > /usr/local/etc/fossology/Db.conf
dbname=$db_name;
......@@ -44,7 +35,7 @@ user=$db_user;
password=$db_password;
EOM
# Startup DB if needed
# Startup DB if needed or wait for external DB
if [ "$db_host" = 'localhost' ]; then
echo '*****************************************************'
echo 'WARNING: No database host was set and therefore the'
......@@ -52,6 +43,15 @@ if [ "$db_host" = 'localhost' ]; then
echo 'THIS IS NOT RECOMENDED FOR PRODUCTIVE USE!'
echo '*****************************************************'
/etc/init.d/postgresql start
else
testForPostgres(){
PGPASSWORD=$db_password psql -h "$db_host" "$db_name" "$db_user" -c '\l' >/dev/null
return $?
}
until testForPostgres; do
>&2 echo "Postgres is unavailable - sleeping"
sleep 1
done
fi
# Setup environment
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment