blob: 6ef8f2e38195373266a48ddeceac516b0d234a3c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
|
#!/bin/bash
_now=$(date +"%s")
_result=''
while read -r -d '' _path; do
_domain=$(basename "${_path}")
_dates=$(openssl x509 -in "${_path}/cert.pem" -noout -dates)
_expire=$(echo "${_dates}" | awk -F'=' '/^notAfter/{print $2}')
_unix_expire=$(date --date="${_expire}" +"%s")
_days_remain=$(bc -l <<< "scale=0; (${_unix_expire} - ${_now})/86400")
printf -v _line "%40s: %3d %s\n" "${_domain}" "${_days_remain}" "days left"
_result="${_result}${_line}"
done < <(find /etc/letsencrypt/live/ -maxdepth 1 -type d -not -wholename '/etc/letsencrypt/live/' -print0)
echo "${_result}" | grep -v '^$' | sort -k 2,2 -n
|