Browse Source

adding --command option

pull/4/head
srvrco 10 years ago
parent
commit
3f6eb08706
2 changed files with 23 additions and 5 deletions
  1. +12
    -3
      README
  2. +11
    -2
      checkssl

+ 12
- 3
README View File

@ -15,7 +15,14 @@ You can also get a list of domains that need to be renewed, to list the domains
checkssl -l /etc/letsencrypt/live/ -e 20 -r
domain7.com
domain 12.com
domain12.com
You can also get it to run a specific command if domains need renewal, for example
check -i ISPconfig -e 20 -c ~/scripts/renewssl
will run the renewssl command with the domain name passed as an argument. If there are more than one domain that needs renewal it will call the command multiple times. This can then easily be run as a cron to regularly check and update SSL certs.
running checkssl with no arguments gives help;
@ -38,9 +45,11 @@ checkssl
-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 to be run if certificates are due for renewal.
V0.1 initial commit by SRVRCO
v0.2 modification by MrSleeps
v0.3 Corrected issue in grep affecting performance on some servers
v0.3 corrected issue in grep affecting performance on some servers
v0.4 correct typo and added -e and -r arguments
v0.5 added --command option

+ 11
- 2
checkssl View File

@ -13,7 +13,7 @@
# GNU General Public License at <http://www.gnu.org/licenses/> for
# more details.
# Usage: checkssl [-h|--help] [-d|--debug] [-f|--file filename] [-s|--server stype] [-l|--location] [-e:--expires days] [-r:--renew]
# Usage: checkssl [-h|--help] [-d|--debug] [-f|--file filename] [-s|--server stype] [-l|--location] [-e:--expires days] [-r:--renew] [-c:--command command]
# Revision history:
# 2015-12-05 Created (v0.1)
@ -22,6 +22,7 @@
# 2015-12-06 corrected typo (srvrco)
# 2015-12-06 Added --expires days argument to set the timescale you want to know about certs coming to end of life (srvrco)
# 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)
# ---------------------------------------------------------------------------
PROGNAME=${0##*/}
@ -58,7 +59,7 @@ 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]"
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]"
}
log() {
@ -91,6 +92,8 @@ help_message() {
-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
_EOF_
return
@ -109,6 +112,8 @@ while [[ -n $1 ]]; do
help_message; graceful_exit ;;
-d | --debug)
_USE_DEBUG=1 ;;
-c | --command)
COMMANDARG=true; shift; RUNCOMMAND="$1" ;;
-e | --expires)
shift; RENEW_ALERT="$1" ;;
-f | --file)
@ -208,6 +213,10 @@ done
if [[ $RENEWARG ]]; then
grep "certificate near renewal date" $DATA_OUT | awk -F"|" '{print $1}'
elif [[ $COMMANDARG ]]; then
for DOMAIN in $(grep "certificate near renewal date" $DATA_OUT | awk -F"|" '{print $1}'); do
$RUNCOMMAND $DOMAIN
done
else
echo ""
cat $DATA_OUT | column -t -s"|"


Loading…
Cancel
Save