ansible-roles/library/roles/ipa-server/templates/ipa-letsencrypt-acmetool.sh

24 lines
685 B
Bash

#!/bin/bash
LE_LOG_DIR=/var/log/acme
LOG_FILE="$LE_LOG_DIR/ipa-server.log"
DATE=$( date )
LE_CERTS_DIR="{{ letsencrypt_acme_sh_certificates_install_path }}"
[ ! -d $LE_LOG_DIR ] && mkdir $LE_LOG_DIR
echo "$DATE" >> $LOG_FILE
krb_realm=$( grep realm /etc/ipa/default.conf | awk '{ print $3 }' )
/bin/cp -f "$LE_CERTS_DIR/fullchain" /etc/pki/ipa/cert.pem
/bin/cp -f "$LE_CERTS_DIR/privkey" /etc/pki/ipa/cert-key.pem
chmod 400 /etc/pki/ipa/cert-key.pem
ipa-server-certinstall -w -d /etc/pki/ipa/cert.pem /etc/pki/ipa/cert-key.pem --pin='' -p '{{ ipa_manager_password }}'
systemctl reload httpd
systemctl restart "dirsrv@${krb_realm//./-}.service"
echo "Done." >> $LOG_FILE
exit 0