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