From 6d219eaa6c238adb1d6dec95f5382cd485878da0 Mon Sep 17 00:00:00 2001 From: gyurix Date: Sat, 29 Mar 2025 23:22:15 +0100 Subject: [PATCH] Refactor start.letsencrypt.sh to correct installation check logic and improve domain file handling --- start.letsencrypt.sh | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/start.letsencrypt.sh b/start.letsencrypt.sh index 2e4a81b..05b71aa 100755 --- a/start.letsencrypt.sh +++ b/start.letsencrypt.sh @@ -54,7 +54,7 @@ create_json() { start_letsencrypt() { cd /root - if [ "$LETSENCRYPT_INSTALLED" == "true" ]; then + if [ "$LETSENCRYPT_INSTALLED" != "true" ]; then curl https://get.acme.sh | sh -s email=$EMAIL LETSENCRYPT_INSTALLED=true fi @@ -110,7 +110,6 @@ check_new_cert() { } LETSENCRYPT_FILES=$(find /acme.sh/ -type f -name letsencrypt) -echo "letsencrypt files exist" if [ "$DOMAIN" != "localhost" ]; then if [ ! -f $LETSENCRYPT_OUTPUT ]; then @@ -128,6 +127,7 @@ if [ "$DOMAIN" != "localhost" ]; then fi elif [ -n "$LETSENCRYPT_FILES" ]; then + echo "letsencrypt files exist" for LETSENCRYPT_FILE in $(echo $LETSENCRYPT_FILES); do DOMAIN=$(jq -r .DOMAIN $LETSENCRYPT_FILE) echo "DOMAIN: $DOMAIN" @@ -142,10 +142,9 @@ if [ "$DOMAIN" != "localhost" ]; then else DOMAIN_FILE="" echo "no any new created domain exists try renew all" - for D in $(ls /domains); do - echo "D: $D" - DOMAIN_FILE=$(basename $D) - echo "DOMAIN_FILE: $DOMAIN_FILE" + for DOMAIN_FILE in $(ls /domains); do + cd /domains + echo "DOMAIN_FILE: $(basename $DOMAIN_FILE)" DOMAIN=$(jq -r .DOMAIN $DOMAIN_FILE) echo "DOMAIN: $DOMAIN" if [ "$DOMAIN" != "localhost" ]; then @@ -153,8 +152,6 @@ if [ "$DOMAIN" != "localhost" ]; then start_letsencrypt $DOMAIN check_new_cert fi - DOMAIN="" - DOMAIN_FILE="" done fi fi