#!/bin/sh
# Wait until libpq is in the dynamic linker cache, where psycopg looks it up.
# ExecStartPre= of linux-manager-setup.service, linux-manager-web.service, linux-manager-metrics.service and
# linux-manager-ui.service; TimeoutStartSec= of the unit bounds the wait.

reported=
until ldconfig -p | grep -q '^[[:space:]]*libpq\.so\.5 '; do
    if [ -z "$reported" ]; then
        echo 'waiting for libpq.so.5 in the linker cache'
        reported=yes
    fi
    sleep 2
done
