2016-04-14 19:31:02 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
2016-06-23 14:05:11 +02:00
|
|
|
H_NAME=$( hostname -f )
|
2016-04-14 19:31:02 +02:00
|
|
|
LE_SERVICES_SCRIPT_DIR=/usr/lib/acme/hooks
|
2016-06-23 14:05:11 +02:00
|
|
|
LE_CERTS_DIR=/var/lib/acme/live/$H_NAME
|
2016-04-14 19:31:02 +02:00
|
|
|
LE_LOG_DIR=/var/log/letsencrypt
|
2016-04-20 15:21:19 +02:00
|
|
|
HAPROXY_CERTDIR=/etc/pki/haproxy
|
2016-04-14 19:31:02 +02:00
|
|
|
HAPROXY_CERTFILE=$HAPROXY_CERTDIR/haproxy.pem
|
|
|
|
DATE=$( date )
|
|
|
|
|
2016-04-18 17:01:05 +02:00
|
|
|
[ ! -d $HAPROXY_CERTDIR ] && mkdir -p $HAPROXY_CERTDIR
|
2016-04-14 19:31:02 +02:00
|
|
|
[ ! -d $LE_LOG_DIR ] && mkdir $LE_LOG_DIR
|
|
|
|
echo "$DATE" >> $LE_LOG_DIR/haproxy.log
|
|
|
|
|
|
|
|
if [ -f /etc/default/letsencrypt ] ; then
|
|
|
|
. /etc/default/letsencrypt
|
|
|
|
else
|
|
|
|
echo "No letsencrypt default file" >> $LE_LOG_DIR/haproxy.log
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo "Building the new certificate file" >> $LE_LOG_DIR/haproxy.log
|
|
|
|
cat ${LE_CERTS_DIR}/{fullchain,privkey} > ${HAPROXY_CERTFILE}
|
|
|
|
chmod 440 ${HAPROXY_CERTFILE}
|
|
|
|
chgrp haproxy ${HAPROXY_CERTFILE}
|
|
|
|
|
|
|
|
echo "Reload the haproxy service" >> $LE_LOG_DIR/haproxy.log
|
2016-04-22 18:01:58 +02:00
|
|
|
if [ -x /bin/systemctl ] ; then
|
|
|
|
systemctl reload haproxy >> $LE_LOG_DIR/haproxy.log 2>&1
|
|
|
|
else
|
|
|
|
service haproxy reload >> $LE_LOG_DIR/haproxy.log 2>&1
|
|
|
|
fi
|
|
|
|
|
2017-10-27 12:49:50 +02:00
|
|
|
# Run the OCSP stapling script
|
|
|
|
if [ -x /usr/local/bin/hapos-upd ] ; then
|
2017-10-27 13:06:49 +02:00
|
|
|
echo "Run the OCSP stapling updater script" >> $LE_LOG_DIR/haproxy.log
|
2018-01-02 14:43:43 +01:00
|
|
|
/usr/local/bin/hapos-upd --cert {{ haproxy_cert_dir }}/haproxy.pem -v {{ letsencrypt_acme_certs_dir }}/fullchain -s {{ haproxy_admin_socket }} -v - >> $LE_LOG_DIR/haproxy.log 2>&1
|
2017-10-27 13:06:49 +02:00
|
|
|
else
|
|
|
|
echo "No OCPS stapling updater script" >> $LE_LOG_DIR/haproxy.log
|
2017-10-27 12:49:50 +02:00
|
|
|
fi
|
|
|
|
|
2016-04-14 19:31:02 +02:00
|
|
|
echo "Done." >> $LE_LOG_DIR/haproxy.log
|
|
|
|
|
|
|
|
exit 0
|
|
|
|
|