From 70f7f45c3a610e74e560514593c5261924e0ea23 Mon Sep 17 00:00:00 2001 From: gyurix Date: Tue, 7 Sep 2021 11:18:22 +0000 Subject: [PATCH 1/4] Minor changes --- start.letsencrypt.sh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/start.letsencrypt.sh b/start.letsencrypt.sh index 6c48d78..3bce929 100755 --- a/start.letsencrypt.sh +++ b/start.letsencrypt.sh @@ -1,5 +1,7 @@ #!/bin/sh +DATE=`date +%F-%H-%M-%S` + cd /domains email=$EMAIL @@ -26,7 +28,9 @@ else DOMAIN=$(jq -r .DOMAIN $i) ; if [[ -f /acme.sh/$DOMAIN/key.pem && -f /acme.sh/$DOMAIN/fullchain.pem && -f /acme.sh/$DOMAIN/cert.pem ]] ; then start_letsencrypt ; - touch /acme.sh/$DOMAIN/renew_certificate; + if [ find /acme.sh/$DOMAIN/ -type f -newermt "$(date '+%Y-%m-%d %H:%M:%S' -d '1 hour ago')" ]; then + touch /acme.sh/$DOMAIN/renew_certificate; + fi else start_letsencrypt; touch /acme.sh/$DOMAIN/new_certificate; From 0e03438728939ce78a0bda0de730266e6a9c4608 Mon Sep 17 00:00:00 2001 From: gyurix Date: Tue, 7 Sep 2021 11:33:11 +0000 Subject: [PATCH 2/4] Minor changes --- start.letsencrypt.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/start.letsencrypt.sh b/start.letsencrypt.sh index 3bce929..b1b55c4 100755 --- a/start.letsencrypt.sh +++ b/start.letsencrypt.sh @@ -28,7 +28,7 @@ else DOMAIN=$(jq -r .DOMAIN $i) ; if [[ -f /acme.sh/$DOMAIN/key.pem && -f /acme.sh/$DOMAIN/fullchain.pem && -f /acme.sh/$DOMAIN/cert.pem ]] ; then start_letsencrypt ; - if [ find /acme.sh/$DOMAIN/ -type f -newermt "$(date '+%Y-%m-%d %H:%M:%S' -d '1 hour ago')" ]; then + if [ find /acme.sh/$DOMAIN/ -type f -mmin +60 ]; then touch /acme.sh/$DOMAIN/renew_certificate; fi else From 89b26b9027498b2a2df0c76ff85cbac92677e8d3 Mon Sep 17 00:00:00 2001 From: gyurix Date: Tue, 7 Sep 2021 12:45:09 +0000 Subject: [PATCH 3/4] Minor changes. --- start.letsencrypt.sh | 42 ++++++++++++++++++++---------------------- 1 file changed, 20 insertions(+), 22 deletions(-) diff --git a/start.letsencrypt.sh b/start.letsencrypt.sh index b1b55c4..13c9e58 100755 --- a/start.letsencrypt.sh +++ b/start.letsencrypt.sh @@ -2,8 +2,6 @@ DATE=`date +%F-%H-%M-%S` -cd /domains - email=$EMAIL start_letsencrypt() { @@ -18,24 +16,24 @@ start_letsencrypt() { } -LETSENCRYPT_FILE=$(find . -type f -name letsencrypt); -if [ -n "$LETSENCRYPT_FILE" ] ; then - DOMAIN=$(jq -r .DOMAIN $LETSENCRYPT_FILE) ; - start_letsencrypt; - rm $LETSENCRYPT_FILE; -else - for i in `ls` ; do - DOMAIN=$(jq -r .DOMAIN $i) ; - if [[ -f /acme.sh/$DOMAIN/key.pem && -f /acme.sh/$DOMAIN/fullchain.pem && -f /acme.sh/$DOMAIN/cert.pem ]] ; then - start_letsencrypt ; - if [ find /acme.sh/$DOMAIN/ -type f -mmin +60 ]; then - touch /acme.sh/$DOMAIN/renew_certificate; - fi - else - start_letsencrypt; - touch /acme.sh/$DOMAIN/new_certificate; - fi - done ; -fi - +LETSENCRYPT_FILE=$(find /acme.sh/ -type f -name letsencrypt); +if [ -f "$LETSENCRYPT_FILE" ] ; then + DOMAIN=$(jq -r .DOMAIN $LETSENCRYPT_FILE) ; + start_letsencrypt; + rm $LETSENCRYPT_FILE; +else + for i in `ls /domains/` ; do + DOMAIN=$(jq -r .DOMAIN /domains/$i) ; + if [[ -f "/acme.sh/$DOMAIN/key.pem" && -f "/acme.sh/$DOMAIN/fullchain.pem" && -f "/acme.sh/$DOMAIN/cert.pem" ]] ; then + echo "Found certificate files"; + start_letsencrypt; + if [ find /acme.sh/$DOMAIN/ -type f -mmin +60 ]; then + touch /acme.sh/$DOMAIN/renew_certificate; + fi + else + start_letsencrypt; + touch /acme.sh/$DOMAIN/new_certificate; + fi + done ; +fi From 3743865892d47141640025195413c6fb35a79355 Mon Sep 17 00:00:00 2001 From: gyurix Date: Wed, 8 Sep 2021 05:48:28 +0000 Subject: [PATCH 4/4] Minor bugfix. --- start.letsencrypt.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/start.letsencrypt.sh b/start.letsencrypt.sh index 13c9e58..e7b8642 100755 --- a/start.letsencrypt.sh +++ b/start.letsencrypt.sh @@ -27,8 +27,8 @@ else if [[ -f "/acme.sh/$DOMAIN/key.pem" && -f "/acme.sh/$DOMAIN/fullchain.pem" && -f "/acme.sh/$DOMAIN/cert.pem" ]] ; then echo "Found certificate files"; start_letsencrypt; - if [ find /acme.sh/$DOMAIN/ -type f -mmin +60 ]; then - touch /acme.sh/$DOMAIN/renew_certificate; + if [[ -n "$(find /acme.sh/$DOMAIN/ -type f -mmin +60)" ]]; then + touch /acme.sh/$DOMAIN/renew_certificate; fi else start_letsencrypt;