Do not restart when the certificate did not change.

This commit is contained in:
Andrea Dell'Amico 2022-06-10 15:56:05 +02:00
parent 1fa3343662
commit 84b92decb4
Signed by: andrea.dellamico
GPG Key ID: 147ABE6CEB9E20FF
1 changed files with 10 additions and 2 deletions

View File

@ -12,13 +12,21 @@ echo "$DATE" > $LE_LOG_DIR/mongodb.log
[ ! -d $MONGODB_CERTDIR ] && mkdir $MONGODB_CERTDIR [ ! -d $MONGODB_CERTDIR ] && mkdir $MONGODB_CERTDIR
cat ${LE_CERTS_DIR}/{cert,privkey} > ${MONGODB_CERTFILE}.new
cmp ${MONGODB_CERTFILE}.new ${MONGODB_CERTFILE} 2>/dev/null
if [ $? -eq 0 ] ; then
echo "The certificate is up to date" >> $LE_LOG_DIR/mongodb.log
rm -f ${MONGODB_CERTFILE}.new
exit 0
fi
echo "Building the new certificate file" >> $LE_LOG_DIR/mongodb.log echo "Building the new certificate file" >> $LE_LOG_DIR/mongodb.log
cat ${LE_CERTS_DIR}/{cert,privkey} > ${MONGODB_CERTFILE} /bin/mv -f ${MONGODB_CERTFILE}.new ${MONGODB_CERTFILE}
chmod 440 ${MONGODB_CERTFILE} chmod 440 ${MONGODB_CERTFILE}
chgrp mongodb ${MONGODB_CERTFILE} chgrp mongodb ${MONGODB_CERTFILE}
{% if mongodb_ssl_enabled %} {% if mongodb_ssl_enabled %}
echo "Reload the mongod service" >> "$LE_LOG_DIR/mongodb.log" echo "Restart the mongod service, reload is not supported" >> "$LE_LOG_DIR/mongodb.log"
{% if mongodb_install_from_external_repo %} {% if mongodb_install_from_external_repo %}
service mongod stop >> "$LE_LOG_DIR/mongodb.log" 2>&1 service mongod stop >> "$LE_LOG_DIR/mongodb.log" 2>&1
sleep 10 sleep 10