Refactor start.letsencrypt.sh to correct installation check logic and improve domain file handling
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
@@ -54,7 +54,7 @@ create_json() {
|
|||||||
|
|
||||||
start_letsencrypt() {
|
start_letsencrypt() {
|
||||||
cd /root
|
cd /root
|
||||||
if [ "$LETSENCRYPT_INSTALLED" == "true" ]; then
|
if [ "$LETSENCRYPT_INSTALLED" != "true" ]; then
|
||||||
curl https://get.acme.sh | sh -s email=$EMAIL
|
curl https://get.acme.sh | sh -s email=$EMAIL
|
||||||
LETSENCRYPT_INSTALLED=true
|
LETSENCRYPT_INSTALLED=true
|
||||||
fi
|
fi
|
||||||
@@ -110,7 +110,6 @@ check_new_cert() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
LETSENCRYPT_FILES=$(find /acme.sh/ -type f -name letsencrypt)
|
LETSENCRYPT_FILES=$(find /acme.sh/ -type f -name letsencrypt)
|
||||||
echo "letsencrypt files exist"
|
|
||||||
|
|
||||||
if [ "$DOMAIN" != "localhost" ]; then
|
if [ "$DOMAIN" != "localhost" ]; then
|
||||||
if [ ! -f $LETSENCRYPT_OUTPUT ]; then
|
if [ ! -f $LETSENCRYPT_OUTPUT ]; then
|
||||||
@@ -128,6 +127,7 @@ if [ "$DOMAIN" != "localhost" ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
elif [ -n "$LETSENCRYPT_FILES" ]; then
|
elif [ -n "$LETSENCRYPT_FILES" ]; then
|
||||||
|
echo "letsencrypt files exist"
|
||||||
for LETSENCRYPT_FILE in $(echo $LETSENCRYPT_FILES); do
|
for LETSENCRYPT_FILE in $(echo $LETSENCRYPT_FILES); do
|
||||||
DOMAIN=$(jq -r .DOMAIN $LETSENCRYPT_FILE)
|
DOMAIN=$(jq -r .DOMAIN $LETSENCRYPT_FILE)
|
||||||
echo "DOMAIN: $DOMAIN"
|
echo "DOMAIN: $DOMAIN"
|
||||||
@@ -142,10 +142,9 @@ if [ "$DOMAIN" != "localhost" ]; then
|
|||||||
else
|
else
|
||||||
DOMAIN_FILE=""
|
DOMAIN_FILE=""
|
||||||
echo "no any new created domain exists try renew all"
|
echo "no any new created domain exists try renew all"
|
||||||
for D in $(ls /domains); do
|
for DOMAIN_FILE in $(ls /domains); do
|
||||||
echo "D: $D"
|
cd /domains
|
||||||
DOMAIN_FILE=$(basename $D)
|
echo "DOMAIN_FILE: $(basename $DOMAIN_FILE)"
|
||||||
echo "DOMAIN_FILE: $DOMAIN_FILE"
|
|
||||||
DOMAIN=$(jq -r .DOMAIN $DOMAIN_FILE)
|
DOMAIN=$(jq -r .DOMAIN $DOMAIN_FILE)
|
||||||
echo "DOMAIN: $DOMAIN"
|
echo "DOMAIN: $DOMAIN"
|
||||||
if [ "$DOMAIN" != "localhost" ]; then
|
if [ "$DOMAIN" != "localhost" ]; then
|
||||||
@@ -153,8 +152,6 @@ if [ "$DOMAIN" != "localhost" ]; then
|
|||||||
start_letsencrypt $DOMAIN
|
start_letsencrypt $DOMAIN
|
||||||
check_new_cert
|
check_new_cert
|
||||||
fi
|
fi
|
||||||
DOMAIN=""
|
|
||||||
DOMAIN_FILE=""
|
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
Reference in New Issue
Block a user