mirror of
https://github.com/mail-in-a-box/mailinabox.git
synced 2025-03-30 23:37:05 +00:00
Check if expired certificates matching the file name pattern exist before trying to move them into ssl.expired subdirectory.
This commit is contained in:
parent
e6c354c312
commit
8bac222ea5
@ -4,14 +4,16 @@
|
||||
source /etc/mailinabox.conf
|
||||
shopt -s extglob
|
||||
|
||||
retain_after="$(date --date="7 days ago" +%Y%m%d)"
|
||||
if ls "$STORAGE_ROOT/ssl/"*-+([0-9])-+([0-9a-f]).pem &>/dev/null; then
|
||||
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
|
||||
pem="$(basename "$file")"
|
||||
not_valid_after="$(cut -d- -f1 <<< "${pem: -21}")"
|
||||
mkdir -p $STORAGE_ROOT/ssl.expired
|
||||
for file in $STORAGE_ROOT/ssl/*-+([0-9])-+([0-9a-f]).pem; do
|
||||
pem="$(basename "$file")"
|
||||
not_valid_after="$(cut -d- -f1 <<< "${pem: -21}")"
|
||||
|
||||
if [ "$not_valid_after" -lt "$retain_after" ]; then
|
||||
mv "$file" "$STORAGE_ROOT/ssl.expired/${pem}"
|
||||
fi
|
||||
done
|
||||
if [ "$not_valid_after" -lt "$retain_after" ]; then
|
||||
mv "$file" "$STORAGE_ROOT/ssl.expired/${pem}"
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
Loading…
Reference in New Issue
Block a user