Update nodemgmt-scripts.sh
This commit is contained in:
@@ -86,18 +86,22 @@ CERTRENEW(){
|
||||
LISTCERTS(){
|
||||
#DIVIDER true
|
||||
for certdir in /etc/letsencrypt/live/*/ ; do
|
||||
#SUBJECT=$(openssl x509 -in ${certdir}/cert.pem -noout -subject)
|
||||
SUBJECT=$(openssl x509 -in ${certdir}/cert.pem -noout -subject|grep -oP '(?<=CN = )[^,]+'|sort -uV)
|
||||
SUBJECTNAMES=$(openssl x509 -in ${certdir}/cert.pem -noout -text|grep -oP '(?<=DNS:|IP Address:)[^,]+'|sort -uV)
|
||||
IFS=':'; SUBJECTNAMES=(${SUBJECTNAMES//$'\n'/:}); unset IFS
|
||||
CERTEXPIRE=$(date -d "$(: | openssl x509 -in ${certdir}/cert.pem -text | grep 'Not After' |awk '{print $4,$5,$7}')" '+%s');
|
||||
DAYS=14; DUEIN=$(($(date +%s) + (86400*$DAYS)));
|
||||
if [ $DUEIN -gt $CERTEXPIRE ]; then CERTEXPIRED=true; else CERTEXPIRED=false; fi
|
||||
|
||||
echo $d
|
||||
echo $SUBJECT
|
||||
declare -p SUBJECTNAMES
|
||||
echo "Expires: $(date -d @${CERTEXPIRE} '+%Y-%m-%d')"
|
||||
|
||||
DIVIDER true
|
||||
echo -e "Certificate Subject: ${idsST[Bold]}${idsCL[Cyan]}${SUBJECT}${idsST[Reset]}${idsCL[Default]}"
|
||||
for ALTNAME in "${SUBJECTNAMES[@]}"; do
|
||||
echo -e "Alternate Subject: ${idsCL[LightCyan]}${ALTNAME}${idsCL[Default]}"
|
||||
done
|
||||
if [ $DUEIN -gt $CERTEXPIRE ]; then
|
||||
echo -e "Expiration Date: ${idsST[Bold]}${idsCL[Red]}$(date -d @${CERTEXPIRE} '+%m-%d-%Y')${idsST[Reset]}${idsCL[Default]}"
|
||||
else
|
||||
echo -e "Expiration Date: ${idsCL[Green]}$(date -d @${CERTEXPIRE} '+%m-%d-%Y')${idsCL[Default]}"
|
||||
fi
|
||||
echo ""
|
||||
done
|
||||
|
||||
|
||||
Reference in New Issue
Block a user