#!/bin/sh

test "$1" = renew || exit 0

postgres_domain="{{ inventory_hostname }}"

for domain in $RENEWED_DOMAINS; do
    case "$domain" in
        $postgres_domain)
            for pem in /etc/letsencrypt/live/$postgres_domain/{privkey,fullchain,chain}.pem; do
                install -o postgres -g postgres -m 400 $pem /var/lib/postgres/data/$pem
            done
            ;;
    esac
done
