#!/usr/local/bin/bash

shopt -u nullglob

# Certificates path and names
DIR="/mnt/certs"
CERTS="${DIR}/*haproxy.pem.ocsp"

for CERT in $CERTS; do

[[ $? -eq 0 ]] && [[ $(pidof haproxy) ]] && [[ -s $CERT ]] && echo "set ssl ocsp-response $(base64 $CERT | tr -d '\n')" | socat tcp-connect:127.0.0.1:9999 -

done

exit 0
