From cd38bbaab4fe28684af93a996a505decc92a037a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20S?= Date: Thu, 5 Jul 2018 10:19:43 +0200 Subject: [PATCH] IS_EVOACME_LIVELINKS: Add a condition when there is no certificates --- evocheck.sh | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/evocheck.sh b/evocheck.sh index 8698ffe..d85f4c2 100755 --- a/evocheck.sh +++ b/evocheck.sh @@ -782,18 +782,22 @@ if [ -e /etc/debian_version ]; then if [ "$IS_EVOACME_LIVELINKS" = 1 ]; then if [ -x "$(which evoacme)" ]; then - for live in /etc/letsencrypt/*/live; do - actualLink=$(ls -lhad $live | tr -s ' ' | cut -d' ' -f 11) - actualCertDate=$(cut -d'/' -f5 <<< $actualLink) - liveDir=$(ls -lhad $live | tr -s ' ' | cut -d' ' -f 9) - certDir=${liveDir%%/live} - lastCertDir=$(stat -c %n ${certDir}/[0-9]* | tail -1) - lastCertDate=$(cut -d'/' -f5 <<< $lastCertDir) - if [[ "$actualCertDate" != "$lastCertDate" ]]; then - echo 'IS_EVOACME_LIVELINKS FAILED!' - break - fi - done + # Sometimes evoacme is installed but no certificates has been generated + numberOfLinks=$(find /etc/letsencrypt/ -type l | wc -l) + if [ $numberOfLinks -gt 0 ]; then + for live in /etc/letsencrypt/*/live; do + actualLink=$(ls -lhad $live | tr -s ' ' | cut -d' ' -f 11) + actualCertDate=$(cut -d'/' -f5 <<< $actualLink) + liveDir=$(ls -lhad $live | tr -s ' ' | cut -d' ' -f 9) + certDir=${liveDir%%/live} + lastCertDir=$(stat -c %n ${certDir}/[0-9]* | tail -1) + lastCertDate=$(cut -d'/' -f5 <<< $lastCertDir) + if [[ "$actualCertDate" != "$lastCertDate" ]]; then + echo 'IS_EVOACME_LIVELINKS FAILED!' + break + fi + done + fi fi fi