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
|
|
|
|
|
2016-04-14 19:31:02 +02:00
|
|
|
echo "Done." >> $LE_LOG_DIR/haproxy.log
|
|
|
|
|
|
|
|
exit 0
|
|
|
|
|