From 3a24f881badf6e649c45a950f62b9891d5351a5f Mon Sep 17 00:00:00 2001 From: Daniel Berteaud Date: Mon, 25 Jan 2016 15:20:04 +0100 Subject: [PATCH] Adapt hook scripts --- .../hooks_clean_challenge.d/10smeserver.sh | 7 +++ .../hooks_deploy_cert.d/10smeserver.sh | 69 ++++++++++------------ 2 files changed, 37 insertions(+), 39 deletions(-) create mode 100644 root/etc/letsencrypt.sh/hooks_clean_challenge.d/10smeserver.sh diff --git a/root/etc/letsencrypt.sh/hooks_clean_challenge.d/10smeserver.sh b/root/etc/letsencrypt.sh/hooks_clean_challenge.d/10smeserver.sh new file mode 100644 index 0000000..337f46b --- /dev/null +++ b/root/etc/letsencrypt.sh/hooks_clean_challenge.d/10smeserver.sh @@ -0,0 +1,7 @@ +#!/bin/sh + +ALTNAME=${1} +if [[ "$ALTNAME" == "" ]]; then + echo "Error while creating or renewing letsencrypt certificate" | mail -s "Letsencrypt error" admin +fi + diff --git a/root/etc/letsencrypt.sh/hooks_deploy_cert.d/10smeserver.sh b/root/etc/letsencrypt.sh/hooks_deploy_cert.d/10smeserver.sh index 64db3ba..2974e34 100644 --- a/root/etc/letsencrypt.sh/hooks_deploy_cert.d/10smeserver.sh +++ b/root/etc/letsencrypt.sh/hooks_deploy_cert.d/10smeserver.sh @@ -1,44 +1,35 @@ #!/bin/sh -ACTION=${1} - -if [[ "$ACTION" == "deploy_cert" ]]; then - # New cert - DOM=${2} - KEY=${3} - CRT=${4} - CHAIN=${5} - /sbin/e-smith/db configuration setprop modSSL key $KEY crt $CRT CertificateChainFile $CHAIN - # There's a new ssl-udpate event which update everything in a single event - # fallback to manual operations if this event doesn't exist - if [ -d /etc/e-smith/events/ssl-update ]; then - /sbin/e-smith/signal-event ssl-update +# New cert +DOM=${1} +KEY=${2} +CRT=${3} +CHAIN=${4} +/sbin/e-smith/db configuration setprop modSSL key $KEY crt $CRT CertificateChainFile $CHAIN +# There's a new ssl-udpate event which update everything in a single event +# fallback to manual operations if this event doesn't exist +if [ -d /etc/e-smith/events/ssl-update ]; then + /sbin/e-smith/signal-event ssl-update +else + /sbin/e-smith/expand-template /home/e-smith/db/ssl.pem/pem + /sbin/e-smith/expand-template /etc/httpd/conf/httpd.conf + /sbin/e-smith/expand-template /var/service/qpsmtpd/ssl/cert.pem + /usr/bin/sv 1 /service/httpd-e-smith + /usr/bin/sv h /service/ldap + /usr/bin/sv 1 /service/pop3s + /usr/bin/sv h /service/qpsmtpd + /usr/bin/sv h /service/sqpsmtpd + if [ -d /service/dovecot ]; then + /usr/bin/sv 1 /service/dovecot + /usr/bin/sv h /service/dovecot else - /sbin/e-smith/expand-template /home/e-smith/db/ssl.pem/pem - /sbin/e-smith/expand-template /etc/httpd/conf/httpd.conf - /sbin/e-smith/expand-template /var/service/qpsmtpd/ssl/cert.pem - /usr/bin/sv 1 /service/httpd-e-smith - /usr/bin/sv h /service/ldap - /usr/bin/sv 1 /service/pop3s - /usr/bin/sv h /service/qpsmtpd - /usr/bin/sv h /service/sqpsmtpd - if [ -d /service/dovecot ]; then - /usr/bin/sv 1 /service/dovecot - /usr/bin/sv h /service/dovecot - else - /usr/bin/sv 1 /service/imaps - fi - fi - # Now revoke old certificates - CUR_CRT=$(readlink /home/e-smith/db/letsencrypt.sh/certs/$DOM/cert.pem) - for cert in $(find /home/e-smith/db/letsencrypt.sh/certs/$DOM/ -type f -name cert\*.pem -exec basename "{}" \;); do - if [[ "$cert" != "$CUR_CRT" ]]; then - /usr/bin/letsencrypt.sh -r /home/e-smith/db/letsencrypt.sh/certs/$DOM/$cert - fi - done -elif [[ "$ACTION" == "clean_challenge" ]]; then - ALTNAME=${2} - if [[ "$ALTNAME" == "" ]]; then - echo "Error while creating or renewing letsencrypt certificate" | mail -s "Letsencrypt error" admin + /usr/bin/sv 1 /service/imaps fi fi +# Now revoke old certificates +CUR_CRT=$(readlink /home/e-smith/db/letsencrypt.sh/certs/$DOM/cert.pem) +for cert in $(find /home/e-smith/db/letsencrypt.sh/certs/$DOM/ -type f -name cert\*.pem -exec basename "{}" \;); do + if [[ "$cert" != "$CUR_CRT" ]]; then + /usr/bin/letsencrypt.sh -r /home/e-smith/db/letsencrypt.sh/certs/$DOM/$cert + fi +done