Skip to content

Commit

Permalink
fix error when glob matches nothing (variable 'file' will have the gl…
Browse files Browse the repository at this point in the history
…ob as a value in the for loop and produce the error "mv: cannot stat '/home/user-data/ssl/*-+([0-9])-+([0-9a-f]).pem': No such file or directory")
  • Loading branch information
downtownallday committed Dec 22, 2024
1 parent 0aa7050 commit 4c2e4ba
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion tools/ssl_cleanup
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ shopt -s extglob
retain_after="$(date --date="7 days ago" +%Y%m%d)"

mkdir -p $STORAGE_ROOT/ssl.expired
for file in $STORAGE_ROOT/ssl/*-+([0-9])-+([0-9a-f]).pem; do
ls $STORAGE_ROOT/ssl/*-+([0-9])-+([0-9a-f]).pem 2>/dev/null | while read file
do
pem="$(basename "$file")"
not_valid_after="$(cut -d- -f1 <<< "${pem: -21}")"

Expand Down

0 comments on commit 4c2e4ba

Please sign in to comment.