diff --git a/checkssl b/checkssl
index 7304bb8..990c42e 100755
--- a/checkssl
+++ b/checkssl
@@ -2,25 +2,19 @@
# ---------------------------------------------------------------------------
# checkssl - checks ssl certs for a set of domains
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
+# This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version.
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License at for
-# more details.
+# This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License at for # more details.
-# Usage: checkssl [-h|--help] [-d|--debug] [-f|--file filename] [-s|--server stype]
+# Usage: checkssl [-h|--help] [-d|--debug] [-f|--file filename] [-s|--server stype] [-l|--location]
# Revision history:
# 2015-12-05 Created (v0.1)
+# 2015-12-05 Added the ability to automatically search for domains from the letsencrypt live directory (v0.2 - sleeps)
# ---------------------------------------------------------------------------
PROGNAME=${0##*/}
-VERSION="0.1"
+VERSION="0.2"
RENEW_ALERT="30" # set to number of days to be alerted for certificate renewal
@@ -54,12 +48,11 @@ signal_exit() { # Handle trapped signals
}
usage() {
- echo -e "Usage: $PROGNAME [-h|--help] [-d|--debug] [-f|--file filename] [-s|--server stype]"
+ echo -e "Usage: $PROGNAME [-h|--help] [-d|--debug] [-f|--file filename] [-s|--server stype] [-l|--location directory]"
}
log() {
- echo "[$(date +%Y-%m-%d\ %H:%M:%S)] $*" >> ${PROGNAME}.log
-}
+ echo "[$(date +%Y-%m-%d\ %H:%M:%S)] $*" >> ${PROGNAME}.log }
debug() {
if [[ "${_USE_DEBUG:-"0"}" -eq 1 ]]; then
@@ -81,6 +74,9 @@ help_message() {
Where 'filename' is a file containing a list of domain names
-s, --server server_type
Where 'server_type' is the server type (cpanel, ISPconfig, apache2 ...)
+ -l, --location directory
+ Where 'directory' is where your lets encrypt live directory is
+ (typically /etc/letsencrypt/live/)
_EOF_
return
@@ -103,6 +99,8 @@ while [[ -n $1 ]]; do
FILEARG=true; shift; FILE="$1" ;;
-s | --server)
SERVERARG=true; shift; STYPE="$1" ;;
+ -l | --location)
+ LOCATIONARG=true; shift; LOC="$1";;
-* | --*)
usage
error_exit "Unknown option $1" ;;
@@ -114,7 +112,7 @@ done
# Main logic
-if [[ ! $FILEARG && ! $SERVERARG ]]; then
+if [[ ! $FILEARG && ! $SERVERARG && ! $LOCATIONARG ]]; then
help_message
graceful_exit
fi
@@ -125,8 +123,7 @@ DATA_OUT=$(mktemp)
debug "created tmp files for input (${LIST_OF_DOMAINS}) and output (${DATA_OUT})"
echo "Domain|cert issued for|valid until|cert issued by| possible issues?" > $DATA_OUT
-# check and inport file if specified on command line
-if [ $FILEARG ]; then
+# check and inport file if specified on command line if [ $FILEARG ]; then
if [ -f $FILE ]; then
cat $FILE >> $LIST_OF_DOMAINS
else
@@ -135,8 +132,7 @@ if [ $FILEARG ]; then
fi
fi
-# get a list of domains from server (if -s flag used)
-if [ $SERVERARG ]; then
+# get a list of domains from server (if -s flag used) if [ $SERVERARG ]; then
if [ "$STYPE" == "cpanel" ]; then
cat /etc/userdomains | cut -d":" -f 1 | grep "\." >> $LIST_OF_DOMAINS
elif [ "$STYPE" == "ISPconfig" ]; then
@@ -147,6 +143,16 @@ if [ $SERVERARG ]; then
fi
fi
+if [ $LOCATIONARG ]; then
+LELOC=$LOC/*
+ for f in $LELOC; do
+ if [[ -d $f ]]; then
+ dir=$(basename "$f")
+ echo $dir >> $LIST_OF_DOMAINS
+ fi
+ done
+fi
+
cat $LIST_OF_DOMAINS | while read -d $'\n\b' DOMAIN; do
PROBLEMS=""
debug " --------------- domain ${DOMAIN} ---------------------"
@@ -177,11 +183,9 @@ cat $LIST_OF_DOMAINS | while read -d $'\n\b' DOMAIN; do
PROBLEMS=$(echo "${PROBLEMS}- certificate near renewal date")
fi
fi
- printf "%s|%s|%s|%s|%s\n" "$DOMAIN" "$ISSUEDTO" "$ENDDATE" "$ISSUER" "$PROBLEMS">> $DATA_OUT
-done
+ printf "%s|%s|%s|%s|%s\n" "$DOMAIN" "$ISSUEDTO" "$ENDDATE" "$ISSUER" "$PROBLEMS">> $DATA_OUT done
echo ""
cat $DATA_OUT | column -t -s"|"
graceful_exit
-