From 89e359ae7d6d8f186a2908d78eb8d4fc70818a67 Mon Sep 17 00:00:00 2001 From: apple Date: Sat, 25 Apr 2026 14:14:39 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=20letsencrypt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../.github/workflows/bump-version.yaml | 2 +- .../.github/workflows/tagged-release.yaml | 2 +- plugins/letsencrypt/Dockerfile | 2 +- plugins/letsencrypt/README.md | 2 +- plugins/letsencrypt/command-functions | 28 +++++++++++-------- plugins/letsencrypt/internal-functions | 7 +++-- 6 files changed, 24 insertions(+), 19 deletions(-) diff --git a/plugins/letsencrypt/.github/workflows/bump-version.yaml b/plugins/letsencrypt/.github/workflows/bump-version.yaml index 998807466..ab6ba5c22 100644 --- a/plugins/letsencrypt/.github/workflows/bump-version.yaml +++ b/plugins/letsencrypt/.github/workflows/bump-version.yaml @@ -25,7 +25,7 @@ jobs: steps: - name: Checkout - uses: actions/checkout@v4.2.2 + uses: actions/checkout@v6.0.2 with: fetch-depth: 0 token: ${{ env.GITHUB_ACCESS_TOKEN }} diff --git a/plugins/letsencrypt/.github/workflows/tagged-release.yaml b/plugins/letsencrypt/.github/workflows/tagged-release.yaml index 4a4e6adbf..1805bd2be 100644 --- a/plugins/letsencrypt/.github/workflows/tagged-release.yaml +++ b/plugins/letsencrypt/.github/workflows/tagged-release.yaml @@ -14,7 +14,7 @@ jobs: steps: - name: Release - uses: softprops/action-gh-release@v2.2.1 + uses: softprops/action-gh-release@v2.6.1 with: generate_release_notes: true make_latest: "true" diff --git a/plugins/letsencrypt/Dockerfile b/plugins/letsencrypt/Dockerfile index d41a94622..5e4cecefa 100644 --- a/plugins/letsencrypt/Dockerfile +++ b/plugins/letsencrypt/Dockerfile @@ -1 +1 @@ -FROM ccr.ccs.tencentyun.com/miaogai/goacme:v4.22.2 \ No newline at end of file +FROM goacme/lego:v4.33.0 diff --git a/plugins/letsencrypt/README.md b/plugins/letsencrypt/README.md index 469a07313..2c67796dc 100644 --- a/plugins/letsencrypt/README.md +++ b/plugins/letsencrypt/README.md @@ -9,7 +9,7 @@ dokku-letsencrypt is the official plugin for [dokku][dokku] that gives the abili ## Installation ```shell -sudo dokku plugin:install http://47.94.22.80:3000/gitea/dokku-letsencrypt.git +sudo dokku plugin:install https://github.com/dokku/dokku-letsencrypt.git sudo dokku letsencrypt:cron-job --add # <- To enable auto-renew ``` diff --git a/plugins/letsencrypt/command-functions b/plugins/letsencrypt/command-functions index 258d0d134..492fd8348 100755 --- a/plugins/letsencrypt/command-functions +++ b/plugins/letsencrypt/command-functions @@ -38,19 +38,23 @@ cmd-letsencrypt-auto-renew() { # For all apps, sorted by ascending time left until renewal. # This way, we'll prioritize apps that need to be renewed soon # if we should hit a rate limit along the way. - fn-letsencrypt-list-apps-with-expiry \ - | sort -nk5 \ - | while IFS=$'\t' read -r -a appExpiry; do - - if [[ ${appExpiry[4]} -lt 0 ]]; then - dokku_log_info1 "${appExpiry[0]} needs renewal" - dokku letsencrypt:enable "${appExpiry[0]}" || EXIT_CODE=$? - else - days_left=$(fn-letsencrypt-format-timediff "${appExpiry[4]}") - dokku_log_verbose "${appExpiry[0]} still has $days_left days left before renewal" + # Store the list in a temporary file to avoid subshell issues with pipelines + local temp_file=$(mktemp) + fn-letsencrypt-list-apps-with-expiry | sort -nk5 > "$temp_file" + + while IFS=$'\t' read -r -a appExpiry; do + if [[ ${appExpiry[4]} -lt 0 ]]; then + dokku_log_info1 "${appExpiry[0]} needs renewal" + if ! dokku letsencrypt:enable "${appExpiry[0]}"; then + EXIT_CODE=1 fi - - done + else + days_left=$(fn-letsencrypt-format-timediff "${appExpiry[4]}") + dokku_log_verbose "${appExpiry[0]} still has $days_left days left before renewal" + fi + done < "$temp_file" + + rm -f "$temp_file" dokku_log_info2 "Finished auto-renewal" if [[ "$EXIT_CODE" != 0 ]]; then diff --git a/plugins/letsencrypt/internal-functions b/plugins/letsencrypt/internal-functions index 644a70fd3..a460f58d6 100755 --- a/plugins/letsencrypt/internal-functions +++ b/plugins/letsencrypt/internal-functions @@ -231,7 +231,7 @@ fn-letsencrypt-check-email() { fn-letsencrypt-configure-and-get-dir() { declare desc="assemble lego command line arguments and create a config hash directory for them" declare APP="$1" - local config config_dir config_hash dns_provider domain_args domains email extra_args graceperiod key server value + local config config_dir config_hash dns_provider domain_args domains email extra_args cert_timeout key server value local app_root="$DOKKU_ROOT/$APP" local le_root="$app_root/letsencrypt" @@ -251,10 +251,11 @@ fn-letsencrypt-configure-and-get-dir() { domain_args="$domain_args --domains $domain" done - graceperiod="$(fn-letsencrypt-computed-graceperiod "$APP")" + # lego --cert.timeout is in seconds and defaults to 30 + cert_timeout=30 email="$(fn-letsencrypt-computed-email "$APP")" extra_args="$(fn-letsencrypt-computed-lego-docker-args "$APP")" - config="--pem --accept-tos --cert.timeout $graceperiod --path /certs --server $server --email $email $extra_args $domain_args" + config="--pem --accept-tos --cert.timeout $cert_timeout --path /certs --server $server --email $email $extra_args $domain_args" dns_provider="$(fn-letsencrypt-computed-dns-provider "$APP")" if [[ -n "$dns_provider" ]]; then