File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 9696if [ ! -f " $STORAGE_ROOT /ssl/dh2048.pem" ]; then
9797 openssl dhparam -out " $STORAGE_ROOT /ssl/dh2048.pem" 2048
9898fi
99+
100+ # Cleanup expired SSL certificates from $STORAGE_ROOT/ssl daily
101+ cat > /etc/cron.daily/mailinabox-ssl-cleanup << EOF ;
102+ #!/bin/bash
103+ # Mail-in-a-Box
104+ # Cleanup expired SSL certificates
105+ $( pwd) /tools/ssl_cleanup
106+ EOF
107+ chmod +x /etc/cron.daily/mailinabox-ssl-cleanup
Original file line number Diff line number Diff line change 1+ #! /bin/bash
2+ # Cleanup SSL certificates which expired more than 7 days ago from $STORAGE_ROOT/ssl and move them to $STORAGE_ROOT/ssl.expired
3+
4+ source /etc/mailinabox.conf
5+ shopt -s extglob
6+
7+ retain_after=" $( date --date=" 7 days ago" +%Y%m%d) "
8+
9+ mkdir -p $STORAGE_ROOT /ssl.expired
10+ for file in $STORAGE_ROOT /ssl/* -+ ([0-9])-+ ([0-9a-f]).pem; do
11+ pem=" $( basename " $file " ) "
12+ not_valid_after=" $( cut -d- -f1 <<< " ${pem: -21}" ) "
13+
14+ if [ " $not_valid_after " -lt " $retain_after " ]; then
15+ mv " $file " " $STORAGE_ROOT /ssl.expired/${pem} "
16+ fi
17+ done
You can’t perform that action at this time.
0 commit comments