File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -38,19 +38,23 @@ cmd-letsencrypt-auto-renew() {
3838 # For all apps, sorted by ascending time left until renewal.
3939 # This way, we'll prioritize apps that need to be renewed soon
4040 # if we should hit a rate limit along the way.
41- fn-letsencrypt-list-apps-with-expiry \
42- | sort -nk5 \
43- | while IFS=$' \t ' read -r -a appExpiry; do
44-
45- if [[ ${appExpiry[4]} -lt 0 ]]; then
46- dokku_log_info1 " ${appExpiry[0]} needs renewal"
47- dokku letsencrypt:enable " ${appExpiry[0]} " || EXIT_CODE=$?
48- else
49- days_left=$( fn-letsencrypt-format-timediff " ${appExpiry[4]} " )
50- dokku_log_verbose " ${appExpiry[0]} still has $days_left days left before renewal"
41+ # Store the list in a temporary file to avoid subshell issues with pipelines
42+ local temp_file=$( mktemp)
43+ fn-letsencrypt-list-apps-with-expiry | sort -nk5 > " $temp_file "
44+
45+ while IFS=$' \t ' read -r -a appExpiry; do
46+ if [[ ${appExpiry[4]} -lt 0 ]]; then
47+ dokku_log_info1 " ${appExpiry[0]} needs renewal"
48+ if ! dokku letsencrypt:enable " ${appExpiry[0]} " ; then
49+ EXIT_CODE=1
5150 fi
52-
53- done
51+ else
52+ days_left=$( fn-letsencrypt-format-timediff " ${appExpiry[4]} " )
53+ dokku_log_verbose " ${appExpiry[0]} still has $days_left days left before renewal"
54+ fi
55+ done < " $temp_file "
56+
57+ rm -f " $temp_file "
5458
5559 dokku_log_info2 " Finished auto-renewal"
5660 if [[ " $EXIT_CODE " != 0 ]]; then
You can’t perform that action at this time.
0 commit comments