From 607cb60110fab704bfa58668fbe2681df9fe0fd4 Mon Sep 17 00:00:00 2001 From: Luke Bratch Date: Wed, 21 Nov 2018 22:50:23 +0000 Subject: Move the list of hosts and ports to a separate file, plus add sample and readme files --- README | 3 +++ certexpiry.sh | 9 +++------ hostsandports.txt.sample | 6 ++++++ 3 files changed, 12 insertions(+), 6 deletions(-) create mode 100644 README create mode 100644 hostsandports.txt.sample diff --git a/README b/README new file mode 100644 index 0000000..138e448 --- /dev/null +++ b/README @@ -0,0 +1,3 @@ +1. Create a file with a list of hosts and ports in the format "host:port" with one on each line - see the sample file myhostsandports.txt.sample +2. By default the hosts/ports file is expected to be in the current directory and named "myhostsandports.txt" +3. Edit default settings such as expiry warn time and the hosts/ports file name/path by editing certexpiry.sh diff --git a/certexpiry.sh b/certexpiry.sh index 90c5fd6..ea2feeb 100755 --- a/certexpiry.sh +++ b/certexpiry.sh @@ -5,14 +5,11 @@ set -euo pipefail # Output warning if fewer than this number of seconds until expiry WARNSECONDS=1209600 # Two weeks # Bash array of host:port combinations to be checked -HOSTSANDPORTS=(irc.tghost.co.uk:6697 irc.lc8n.com:6697 irc.pgburton.com:6697 www.tghost.co.uk mail.tghost.co.uk:25 \ - mail.tghost.co.uk:143 mail.tghost.co.uk mumble.tghost.co.uk:64738 bladns.net www.lc8n.com \ - www.blatech.net upload.bratch.co.uk www.nokiaplan3.com davmail.tghost.co.uk:1143 bcal.tghost.co.uk \ - www.blaupload.co.uk up.org.je) +HOSTSANDPORTS="hostsandports.txt" # ==== Variables ==== # Loop through all host:port combinations -for HOSTANDPORT in "${HOSTSANDPORTS[@]}" ; do +while read HOSTANDPORT ; do # echo "DEBUG: HOSTANDPORT: $HOSTANDPORT." @@ -72,4 +69,4 @@ for HOSTANDPORT in "${HOSTSANDPORTS[@]}" ; do # echo "DEBUG: The certificate at $HOST:$PORT expires in $DIFFERENCE seconds (~$(expr $DIFFERENCE / 60 / 60 / 24) days)." fi -done +done < "$HOSTSANDPORTS" diff --git a/hostsandports.txt.sample b/hostsandports.txt.sample new file mode 100644 index 0000000..b55841d --- /dev/null +++ b/hostsandports.txt.sample @@ -0,0 +1,6 @@ +www.mywebsite.com +foo.myotherwebsite.com +bar.yetanotherwebsite.com:443 +mail.myhost.com:25 +mail.myhost.com:143 +mumble.myhost.com:64738 -- cgit v1.2.3