summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFlorian Pritz <bluewind@xinu.at>2016-12-26 11:24:32 +0100
committerFlorian Pritz <bluewind@xinu.at>2016-12-26 11:24:32 +0100
commit9f902db6b0443e26b2886d81bae5e87a10531a6c (patch)
tree0d851921a6be0e855e516085e42240c4e4e624af
parent3eb9b83189845d73fc54d1d65b0856b088304ed2 (diff)
downloadbin-9f902db6b0443e26b2886d81bae5e87a10531a6c.tar.gz
bin-9f902db6b0443e26b2886d81bae5e87a10531a6c.tar.xz
Add check_le_expiry.sh
Signed-off-by: Florian Pritz <bluewind@xinu.at>
-rw-r--r--check_le_expiry.sh15
1 files changed, 15 insertions, 0 deletions
diff --git a/check_le_expiry.sh b/check_le_expiry.sh
new file mode 100644
index 0000000..6ef8f2e
--- /dev/null
+++ b/check_le_expiry.sh
@@ -0,0 +1,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