Skip to content

Commit cf7d6dd

Browse files
committed
Refactor entrypoint.sh for improved clarity and POSIX compliance
- Changed variable name from 'dir' to 'target_dir' for better readability. - Updated the method of calculating the next renewal check time to be POSIX-compliant. - Enhanced the handling of date formatting to ensure compatibility across environments. Co-authored-by: Jay Rogers <[email protected]>
1 parent 394a9c9 commit cf7d6dd

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/entrypoint.sh

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,10 @@ configure_windows_file_permissions() {
2020
# Workaround https://github.com/microsoft/wsl/issues/12250 by replacing symlinks with direct copies of the files they
2121
# reference.
2222
replace_symlinks() {
23-
# shellcheck disable=SC3043
24-
local dir="$1"
23+
target_dir="$1"
2524

2625
# Iterate over all items in the directory
27-
for item in "$dir"/*; do
26+
for item in "$target_dir"/*; do
2827
if [ -L "$item" ]; then
2928
# If the item is a symlink
3029
target=$(readlink -f "$item")
@@ -116,7 +115,10 @@ run_certbot
116115

117116
# Infinite loop to keep the container running and periodically check for renewals
118117
while true; do
119-
next_run=$(date -d "@$(($(date +%s) + RENEWAL_INTERVAL))" '+%Y-%m-%d %H:%M:%S')
118+
# POSIX-compliant way to show next run time
119+
current_timestamp=$(date +%s)
120+
next_timestamp=$((current_timestamp + RENEWAL_INTERVAL))
121+
next_run=$(date -r "$next_timestamp" '+%Y-%m-%d %H:%M:%S' 2>/dev/null || date '+%Y-%m-%d %H:%M:%S')
120122
echo "Next certificate renewal check will be at ${next_run}"
121123

122124
# Use wait with timeout to allow for signal interruption

0 commit comments

Comments
 (0)