scripts/ssl_certs/cert-expiry.sh
2024-07-02 04:07:29 -05:00

43 lines
2.6 KiB
Bash
Executable file

#!/bin/bash
#: <<'END'
# RHEL/Fedora rigs
RHELHOSTS=("www.schotty.com" "matrix.schotty.com" "shadow.schotty.com")
for rhel in "${RHELHOSTS[@]}"
do
echo "╔═══════════════════════════════════════════════════════════════════════════════════════╗"
echo -e "║Host :" $rhel "\t\t\t\t\t\t\t║"
expiry=$(
echo $rhel |
xargs -n 1 bash -c ' \
openssl s_client -connect $0:443 2> /dev/null | \
openssl x509 -noout -enddate | \
cut -d = -f 2 | \
xargs -I {} echo {} $0 ')
expiry="${expiry:0:24}"
echo -e "║SSL Cert Expiry :" ${expiry} "\t\t\t\t\t\t║"
echo -e "║System Status :" `ssh $rhel "uptime | awk -F'[a-z]:' '{ print $2}'"` "\t║"
echo -e "║Updates :" `ssh $rhel "sudo yum -y list updates | wc -l"`\
"\t\t\t\t\t\t\t\t\t║"
echo -e "╚═══════════════════════════════════════════════════════════════════════════════════════╝"
done
#END
# Debian based rigs
DEBIANHOSTS=("mx.andrewschott.com")
for debian in "${DEBIANHOSTS[@]}"
do
echo "╔═══════════════════════════════════════════════════════════════════════════════════════╗"
echo -e "║Host :" $debian "\t\t\t\t\t\t\t║"
expiry=$(
echo $debian |
xargs -n 1 bash -c ' \
openssl s_client -connect $0:443 2> /dev/null | \
openssl x509 -noout -enddate | \
cut -d = -f 2 | \
xargs -I {} echo {} $0 ')
expiry="${expiry:0:24}"
echo -e "║SSL Cert Expiry :" ${expiry} "\t\t\t\t\t\t║"
echo -e "║System Status :" `ssh $debian "uptime | awk -F'[a-z]:' '{ print $2}'"` "\t║"
echo -e "║Updates :" `ssh $debian "sudo apt update > /dev/null 2>&1;sudo apt-get -s upgrade | grep -P \"\\d\\K upgraded\" | cut -d \" \" -f1" `\
"\t\t\t\t\t\t\t\t\t║"
echo -e "╚═══════════════════════════════════════════════════════════════════════════════════════╝"
done