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

28 lines
690 B
Bash

#!/bin/bash
LE_LOG_DIR=/var/log/acme
LOG_FILE="$LE_LOG_DIR/ipa-server.log"
DATE=$( date )
[ ! -d $LE_LOG_DIR ] && mkdir $LE_LOG_DIR
echo "$DATE" >> $LOG_FILE
if [ -f /etc/default/letsencrypt ] ; then
. /etc/default/letsencrypt
else
echo "No letsencrypt default file" >> $LOG_FILE
fi
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
ipa-server-certinstall -w -d /etc/pki/ipa/cert.pem /etc/pki/ipa/cert-key.pem --pin='' -p ''
systemctl reload httpd
systemctl restart "dirsrv@${krb_realm//./-}.service"
echo "Done." >> $LOG_FILE
exit 0