Refactor start.letsencrypt.sh to simplify curl command and enhance certificate management with config-home option
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
gyurix
2025-11-05 09:43:37 +01:00
parent 62303cf2fc
commit 1e256e169b

View File

@@ -55,7 +55,7 @@ create_json() {
start_letsencrypt() {
cd /root
if [ "$LETSENCRYPT_INSTALLED" != "true" ]; then
curl https://get.acme.sh | sh -s -- --home /acme.sh/$DOMAIN email=$EMAIL
curl https://get.acme.sh | sh -s email=$EMAIL
LETSENCRYPT_INSTALLED=true
fi
@@ -64,12 +64,12 @@ start_letsencrypt() {
SUBJECT=$(openssl x509 -in /acme.sh/$DOMAIN/fullchain.pem -text -noout | grep -w CN | grep Subject | cut -d '=' -f2)
if [ "$ISSUER" == "$SUBJECT" ]; then
echo "Self signed certificate found"
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
else sh /root/.acme.sh/acme.sh $L_S $EK $EHK --renew --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
sh /root/.acme.sh/acme.sh $L_S $EK $EHK --config-home /acme.sh --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
else sh /root/.acme.sh/acme.sh $L_S $EK $EHK --config-home /acme.sh --renew --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
fi
else
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
sh /root/.acme.sh/acme.sh $L_S $EK $EHK --config-home /acme.sh --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
fi
RESPONSE=$?
@@ -78,7 +78,7 @@ start_letsencrypt() {
if [ "$(echo $RESPONSE)" == "1" ]; then
for retries in $(seq 0 $((RESTART + 1))); do
if [[ $retries -le $RESTART ]]; then
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
sh /root/.acme.sh/acme.sh $L_S $EK $EHK --config-home /acme.sh --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=$?
if [[ "$(echo $RESPONSE)" == "1" && "$(cat $LOG_FILE | grep force)" == "" ]]; then
sleep $TIMEOUT