2018-09-11 17:37:10 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
LE_CERTS_DIR=/etc/letsencrypt/live/$HOSTNAME
|
2018-09-12 19:00:01 +02:00
|
|
|
LE_LOG_DIR=/var/log/acme
|
2018-09-11 17:37:10 +02:00
|
|
|
MONGODB_CERTDIR=/etc/pki/mongodb
|
|
|
|
MONGODB_CERTFILE=$MONGODB_CERTDIR/mongodb.pem
|
|
|
|
DATE=$( date )
|
|
|
|
echo "$DATE" >> $LE_LOG_DIR/mongodb.log
|
|
|
|
|
|
|
|
if [ -f /etc/default/letsencrypt ] ; then
|
|
|
|
. /etc/default/letsencrypt
|
|
|
|
else
|
|
|
|
echo "No letsencrypt default file" >> $LE_LOG_DIR/mongodb.log
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
[ ! -d $MONGODB_CERTDIR ] && mkdir $MONGODB_CERTDIR
|
|
|
|
|
|
|
|
echo "Building the new certificate file" >> $LE_LOG_DIR/mongodb.log
|
|
|
|
cat ${LE_CERTS_DIR}/{cert,privkey} > ${MONGODB_CERTFILE}
|
|
|
|
chmod 440 ${MONGODB_CERTFILE}
|
|
|
|
chgrp mongodb ${MONGODB_CERTFILE}
|
|
|
|
|
|
|
|
{% if mongodb_ssl_enabled %}
|
2019-01-16 13:54:13 +01:00
|
|
|
echo "Reload the mongod service" >> "$LE_LOG_DIR/mongodb.log"
|
|
|
|
service mongod stop >> "$LE_LOG_DIR/mongodb.log" 2>&1
|
2018-09-11 17:37:10 +02:00
|
|
|
sleep 10
|
2019-01-16 13:54:13 +01:00
|
|
|
service mongod start > "$LE_LOG_DIR/mongodb.log" 2>&1
|
2018-09-11 17:37:10 +02:00
|
|
|
{% endif %}
|
|
|
|
echo "Done." >> $LE_LOG_DIR/mongodb.log
|
|
|
|
|
|
|
|
exit 0
|
|
|
|
|