diff --git a/inc/certs.inc b/inc/certs.inc index bb0d3320..6df5c5cb 100755 --- a/inc/certs.inc +++ b/inc/certs.inc @@ -167,6 +167,21 @@ CONCAT_SSL(){ } LISTCERTS(){ + EDIT=0; SEARCH=0 + while [ $# -gt 0 ]; do + case "${1}" in + -edit|-e) EDIT=1;; + -search|-s) SEARCH=${2};; + -h | -help | --help) + echo -e "Usage: ${idsCL[Yellow]}nodemgmt / nmg listcerts${idsCL[Default]} {" + width=33 + printf "%-${width}s- %s\n" " -edit|-e" "(enables edit mode)" + printf "%-${width}s- %s\n" " -search|-s {search}" "(narrows list to cert names containing {search})" + echo -e "}\n" + exit 0;; + esac + shift + done declare -i cw; declare -i spc1; declare -i c if [ -f ${NM_FOLDER}/conf/ssl-domain-checks.conf ]; then declare -A CHECKCERT_DOMAINS @@ -197,10 +212,15 @@ LISTCERTS(){ echo -e "Subject Name Monitored Expires Alternate Subject Names" DIVIDER false yellow 120 - cw=30; + cw=34; c=0; spc2=''; until [ $c = ${cw} ]; do spc2="${spc2} "; c=`expr $c + 1`; done - ssldir=$(${NCMD} find ${NM_CERTPATH}/live/*dns* -type d) + if [ "${SEARCH}" != "0" ]; then + ssldir=$(${NCMD} find ${NM_CERTPATH}/live/*${SEARCH,,}* -type d) + else + ssldir=$(${NCMD} find ${NM_CERTPATH}/live/* -type d) + fi + i=0 for certdir in ${ssldir[@]}; do SUBJECT=$(${NCMD} openssl x509 -in ${certdir}/cert.pem -noout -subject|grep -oP '(?<=CN = )[^,]+'|sort -uV)