Aller au contenu

[TUTO] [Zone publique sur DNS Server] Renouvellement automatisé de certificat wildcard


.Shad.

Messages recommandés

  • 9 mois après...

Hello,

Here is a really big huge thanks for this script. I have a proposal to extends its capabilities:
 - init method: add bool variable saying whereas the ZONE_NAME is an alias domain or not

ZONE_ALIAS=true # Zone is alias

- certificate_issue method: replace the acme.sh line to handle challenge-alias when the previous variable is set to true

certificate_issue() {
    echo -e "Issueing certificate...\n"
    if [ "$ZONE_ALIAS" = true ];
    then
        ${ACME_DIR}/acme.sh --issue -d ${CERT_DOMAIN} -d ${CERT_WDOMAIN} --challenge-alias ${ZONE_NAME} --dns --yes-I-know-dns-manual-mode-enough-go-ahead-please --server letsencrypt | tee ${CERT_HOME}/${CERT_DOMAIN}/${LOG}
    else
        ${ACME_DIR}/acme.sh --issue -d ${CERT_DOMAIN} -d ${CERT_WDOMAIN}  --dns --yes-I-know-dns-manual-mode-enough-go-ahead-please --server letsencrypt | tee ${CERT_HOME}/${CERT_DOMAIN}/${LOG}
    fi
    mapfile -t array < <(grep -A1 "Domain: '" ${CERT_HOME}/${CERT_DOMAIN}/${LOG} | cut -d"'" -f2 | sed 's/--//g' | sed '/^$/d')
    echo "${array[0]}. 1 IN TXT \"${array[1]}"\" >> ${ZONE}
    echo "${array[2]}. 1 IN TXT \"${array[3]}"\" >> ${ZONE}
    echo -e "\nTXT records are :\n"
    tail -n 2 ${ZONE}
}

- saved_syno_values_removing method: replace prevent a crash by adding some conditions (file does not exists uh?)

saved_syno_values_removing() {
    CERT_CONF=${CERT_HOME}/${CERT_DOMAIN}/${CERT_DOMAIN}.conf
    if [ -f "${CERT_CONF}" ]; then
        sed -E '/^SAVED_SYNO|Le_DeployHook/d' ${CERT_CONF} > ${CERT_CONF}.bkp
    fi
    if [ -f "${CERT_CONF}.bkp" ]; then
        mv ${CERT_CONF}.bkp ${CERT_CONF}
    fi
}

- dns_spread: add a sleep after the changes (30 seconds may be way too much but oh well, the Txt fields would not spread to slave dns zones without this, uh?...). 

dns_spread() {
    echo -e "\nSpreading zone changes to slave DNS servers, please wait 30 seconds...\n"
    SERIAL=$(sed -n '/SOA/{n;p}' $ZONE)
    INCR_SERIAL=$((SERIAL+1))
    sed "s/${SERIAL}/\t${INCR_SERIAL}/" ${ZONE} > ${ZONE_TEMP}
    mv ${ZONE_TEMP} ${ZONE}
    sleep 30
}


WIth theses changes i only expose online a slave synology dns zone from a syno router and i removed all encountered bugs. 🙂

Lien vers le commentaire
Partager sur d’autres sites

Le 24/11/2022 à 04:07, aozorashinyuu a dit :

WIth theses changes i only expose online a slave synology dns zone from a syno router and i removed all encountered bugs.

Brillant ! I will test the new script as soon as @.Shad. implement the changes 😉. Next review is mid january.

Modifié par Jeff777
Lien vers le commentaire
Partager sur d’autres sites

  • 1 an après...

Rejoindre la conversation

Vous pouvez publier maintenant et vous inscrire plus tard. Si vous avez un compte, connectez-vous maintenant pour publier avec votre compte.

Invité
Répondre à ce sujet…

×   Collé en tant que texte enrichi.   Coller en tant que texte brut à la place

  Seulement 75 émoticônes maximum sont autorisées.

×   Votre lien a été automatiquement intégré.   Afficher plutôt comme un lien

×   Votre contenu précédent a été rétabli.   Vider l’éditeur

×   Vous ne pouvez pas directement coller des images. Envoyez-les depuis votre ordinateur ou insérez-les depuis une URL.

×
×
  • Créer...

Information importante

Nous avons placé des cookies sur votre appareil pour aider à améliorer ce site. Vous pouvez choisir d’ajuster vos paramètres de cookie, sinon nous supposerons que vous êtes d’accord pour continuer.