|
|
|
@ -24,11 +24,12 @@ |
|
|
|
# 2015-12-06 Added --renew argument to list domains ready for renew v0.4 - srvrco) |
|
|
|
# 2015-12-19 Added --command argument to perform action to renew certs ( or send email or anything else needed) (v0.5 srvrco) |
|
|
|
# 2016-01-07 Added option to just provide domain name on command line (v0.6 srvrco) |
|
|
|
# 2016-01-30 Ipdated after using shellcheck to maintain a better coding standard (0.7) |
|
|
|
# 2016-01-30 Updated after using shellcheck to maintain a better coding standard (0.7) |
|
|
|
# 2016-01-31 Added check at start to ensure all required applications are installed (0.8) |
|
|
|
# --------------------------------------------------------------------------- |
|
|
|
|
|
|
|
PROGNAME=${0##*/} |
|
|
|
VERSION="0.7" |
|
|
|
VERSION="0.8" |
|
|
|
RENEW_ALERT="30" # set to number of days to be alerted for certificate renewal ( default, can be changed with -expires argument) |
|
|
|
|
|
|
|
clean_up() { # Perform pre-exit housekeeping |
|
|
|
@ -61,7 +62,8 @@ signal_exit() { # Handle trapped signals |
|
|
|
} |
|
|
|
|
|
|
|
usage() { |
|
|
|
echo -e "Usage: $PROGNAME [-h|--help] [-d|--debug] [-f|--file filename] [-s|--server stype] [-l|--location directory] [-e|--expires days] [-r:--renew] [-c:--command command] [domain]" |
|
|
|
echo -e "Usage: $PROGNAME [-h|--help] [-d|--debug] [-f|--file filename] [-s|--server stype] [-l|--location directory] |
|
|
|
[-e|--expires days] [-r:--renew] [-c:--command command] [domain]" |
|
|
|
} |
|
|
|
|
|
|
|
log() { |
|
|
|
@ -74,31 +76,41 @@ debug() { |
|
|
|
fi |
|
|
|
} |
|
|
|
|
|
|
|
_requires() { |
|
|
|
result=$(which "$1" 2>/dev/null) |
|
|
|
debug "checking for required $1 ... $result" |
|
|
|
if [ -z "$result" ]; then |
|
|
|
error_exit "This script requires $1 installed" |
|
|
|
fi |
|
|
|
} |
|
|
|
|
|
|
|
help_message() { |
|
|
|
cat <<- _EOF_ |
|
|
|
$PROGNAME ver. $VERSION |
|
|
|
checks ssl certs for a set of domains |
|
|
|
|
|
|
|
$(usage) |
|
|
|
|
|
|
|
Options: |
|
|
|
-h, --help Display this help message and exit. |
|
|
|
-d, --debug outputs debug information |
|
|
|
-f, --file filename |
|
|
|
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/) |
|
|
|
-e, --expires days |
|
|
|
Where 'days' is the number of days to alert if cert expires in that time period |
|
|
|
-r, --renew this just lists domain names that need to be renewed. This list could be used by an auto renew script, or to email you. |
|
|
|
-c, --command run_command |
|
|
|
Where 'run_command' is a command which will be run ( with domain name passed) for any certs due for renewal |
|
|
|
|
|
|
|
a domain name can also be specified on the command line |
|
|
|
_EOF_ |
|
|
|
cat <<- _EOF_ |
|
|
|
$PROGNAME ver. $VERSION |
|
|
|
Checks ssl certs for a set of domains |
|
|
|
|
|
|
|
$(usage) |
|
|
|
|
|
|
|
Options: |
|
|
|
-h, --help Display this help message and exit. |
|
|
|
-d, --debug Outputs debug information |
|
|
|
-f, --file filename |
|
|
|
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/) |
|
|
|
-e, --expires days |
|
|
|
Where 'days' is the number of days to alert if cert expires in that time period |
|
|
|
-r, --renew this just lists domain names that need to be renewed. |
|
|
|
This list could be used by an auto renew script, or to email you. |
|
|
|
-c, --command run_command |
|
|
|
Where 'run_command' is a command which will be run (with domain name passed) |
|
|
|
for any certs due for renewal |
|
|
|
|
|
|
|
A domain name can also be specified on the command line |
|
|
|
_EOF_ |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
@ -138,11 +150,20 @@ done |
|
|
|
|
|
|
|
# Main logic |
|
|
|
|
|
|
|
#check if required applications are included |
|
|
|
|
|
|
|
_requires openssl |
|
|
|
_requires mktemp |
|
|
|
_requires grep |
|
|
|
_requires awk |
|
|
|
_requires column |
|
|
|
|
|
|
|
if [[ ! $FILEARG && ! $SERVERARG && ! $LOCATIONARG && ! $DOMAINARG ]]; then |
|
|
|
help_message |
|
|
|
graceful_exit |
|
|
|
fi |
|
|
|
|
|
|
|
|
|
|
|
# create temporary file for the list of domains, and output |
|
|
|
LIST_OF_DOMAINS=$(mktemp) |
|
|
|
DATA_OUT=$(mktemp) |
|
|
|
|