#!/bin/sh
# Wait until libpq is in the dynamic linker cache, where psycopg looks it up.
# ExecStartPre= of vpn-router-web.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
