diff --git a/ssl-check.sh b/ssl-check.sh index f1b69d05..f3bc592c 100755 --- a/ssl-check.sh +++ b/ssl-check.sh @@ -624,6 +624,73 @@ else exit 1 fi +### If a HOST and PORT were passed on the cmdline, use those values +if [ "${HOST}" != "" ] && [ "${PORT}" != "" ] +then + print_heading + check_server_status "${HOST}" "${PORT}" + print_summary + +### If a file is passed to the "-f" option on the command line, check +### each certificate or server / port combination in the file to see if +### they are about to expire +elif [ -f "${SERVERFILE}" ] +then + print_heading + + IFS=$'\n' + for LINE in `egrep -v '(^#|^$)' ${SERVERFILE}` + do + HOST=${LINE%% *} + PORT=${LINE#* } + IFS=" " + if [ "$PORT" = "FILE" ] + then + check_file_status ${HOST} "FILE" "${HOST}" + else + check_server_status "${HOST}" "${PORT}" + fi + done + IFS=${OLDIFS} + print_summary + +### Check to see if the certificate in CERTFILE is about to expire +elif [ "${CERTFILE}" != "" ] +then + print_heading + check_file_status ${CERTFILE} "FILE" "${CERTFILE}" + print_summary + +### Check to see if the certificates in CERTDIRECTORY are about to expire +elif [ "${CERTDIRECTORY}" != "" ] && (${FIND} -L ${CERTDIRECTORY} -type f > /dev/null 2>&1) +then + print_heading + for FILE in `${FIND} -L ${CERTDIRECTORY} -type f`; do + check_file_status ${FILE} "FILE" "${FILE}" + done + print_summary + +### There was an error, so print a detailed usage message and exit +else + usage + exit 1 +fi + +### Remove the temporary files +if [ $DEBUG == 1 ] +then + echo "DEBUG: Certificate temporary file:" + cat ${CERT_TMP} + echo "DEBUG: Runtime information file:" + cat ${ERROR_TMP} +fi + rm -f ${CERT_TMP} ${ERROR_TMP} -exit 0 +### Exit with a success indicator +if [ "${NAGIOS}" = "TRUE" ] +then + exit $RETCODE +else + exit 0 +fi \ No newline at end of file