#!/bin/bash # Hook Certbot : copie les certificats $VOTRE_NDD vers dnsdist et Unbound. # Ne s'exécute que pour ce certificat précis. CERT_DIR="${RENEWED_LINEAGE:-}" # Ne rien faire si le certificat renouvelé n'est pas $VOTRE_NDD if [[ "$CERT_DIR" != *"/live/$VOTRE_NDD" ]]; then exit 0 fi if [ ! -f "$CERT_DIR/fullchain.pem" ] || [ ! -f "$CERT_DIR/privkey.pem" ]; then echo "[dns-certs] ERREUR : certificat introuvable dans $CERT_DIR" >&2 exit 0 fi # --- Copie pour dnsdist --- if [ -d "/etc/dnsdist/certs" ]; then echo "[dns-certs] Copie vers dnsdist..." cp "$CERT_DIR/fullchain.pem" /etc/dnsdist/certs/$VOTRE_NDD-fullchain.pem cp "$CERT_DIR/privkey.pem" /etc/dnsdist/certs/$VOTRE_NDD-privkey.pem chown _dnsdist:_dnsdist /etc/dnsdist/certs/$VOTRE_NDD-*.pem chmod 600 /etc/dnsdist/certs/$VOTRE_NDD-*.pem systemctl restart dnsdist fi # --- Copie pour Unbound (DoT) --- if [ -d "/etc/unbound/certs" ]; then echo "[dns-certs] Copie vers Unbound..." cp "$CERT_DIR/fullchain.pem" /etc/unbound/certs/$VOTRE_NDD-fullchain.pem cp "$CERT_DIR/privkey.pem" /etc/unbound/certs/$VOTRE_NDD-privkey.pem chown unbound:unbound /etc/unbound/certs/$VOTRE_NDD-*.pem chmod 600 /etc/unbound/certs/$VOTRE_NDD-*.pem systemctl restart unbound fi # --- Recharger Apache --- systemctl reload apache2