Refactor start.letsencrypt.sh to improve error handling and logging during certificate issuance
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:
@@ -58,10 +58,11 @@ start_letsencrypt() {
|
|||||||
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
|
||||||
cd /root/.acme.sh
|
|
||||||
chmod a+x ./acme.sh
|
sh /root/.acme.sh/acme.sh $L_S $EK $EHK --issue --standalone --keylength 4096 -d $DOMAIN --cert-file /acme.sh/$DOMAIN/cert.pem --key-file /acme.sh/$DOMAIN/key.pem --fullchain-file /acme.sh/$DOMAIN/fullchain.pem >$LOG_FILE 2>&1
|
||||||
RESPONSE=$(./acme.sh $L_S $EK $EHK --issue --standalone --keylength 4096 -d $DOMAIN --cert-file /acme.sh/$DOMAIN/cert.pem --key-file /acme.sh/$DOMAIN/key.pem --fullchain-file /acme.sh/$DOMAIN/fullchain.pem >$LOG_FILE)
|
RESPONSE=$?
|
||||||
if [[ "$(echo $?)" == "1" ]]; then
|
echo "OUTPOUT: $RESPONSE"
|
||||||
|
if [[ "$(echo $RESPONSE)" == "1" ]]; then
|
||||||
for retries in $(seq 0 $((RESTART + 1))); do
|
for retries in $(seq 0 $((RESTART + 1))); do
|
||||||
if [[ $retries -le $RESTART ]]; then
|
if [[ $retries -le $RESTART ]]; then
|
||||||
# Check certificate issuer
|
# Check certificate issuer
|
||||||
@@ -69,8 +70,9 @@ start_letsencrypt() {
|
|||||||
SUBJECT=$(openssl x509 -in /acme.sh/$DOMAIN/fullchain.pem -text -noout | grep -w CN | grep Subject | cut -d '=' -f2)
|
SUBJECT=$(openssl x509 -in /acme.sh/$DOMAIN/fullchain.pem -text -noout | grep -w CN | grep Subject | cut -d '=' -f2)
|
||||||
if [ "$ISSUER" == "$SUBJECT" ]; then
|
if [ "$ISSUER" == "$SUBJECT" ]; then
|
||||||
echo "Self signed certificate found"
|
echo "Self signed certificate found"
|
||||||
RESPONSE=$(./acme.sh $L_S $EK $EHK --issue --standalone --keylength 4096 -d $DOMAIN --cert-file /acme.sh/$DOMAIN/cert.pem --key-file /acme.sh/$DOMAIN/key.pem --fullchain-file /acme.sh/$DOMAIN/fullchain.pem >>$LOG_FILE)
|
sh /root/.acme.sh/acme.sh $L_S $EK $EHK --issue --standalone --keylength 4096 -d $DOMAIN --cert-file /acme.sh/$DOMAIN/cert.pem --key-file /acme.sh/$DOMAIN/key.pem --fullchain-file /acme.sh/$DOMAIN/fullchain.pem >>$LOG_FILE 2>&1
|
||||||
if [[ "$(echo $?)" != "1" ]]; then
|
RESPONSE=$?
|
||||||
|
if [[ "$(echo $RESPONSE)" == "1" ]]; then
|
||||||
sleep $TIMEOUT
|
sleep $TIMEOUT
|
||||||
echo "Restarting number is only: "$retries" so try again"
|
echo "Restarting number is only: "$retries" so try again"
|
||||||
else
|
else
|
||||||
|
Reference in New Issue
Block a user