diff --git a/bin/info-cert.sh b/bin/info-cert.sh index 1bcee79..e62d5c0 100755 --- a/bin/info-cert.sh +++ b/bin/info-cert.sh @@ -156,7 +156,10 @@ main(){ while [[ "$#" -gt 0 ]]; do case "$1" in -a|--all) - certList=($CERTS_PATH/*.crt) + # set - if no .crt → files=() (empty) + shopt -s nullglob + certList=("$CERTS_PATH"/*.crt) + shopt -u nullglob cert_info shift ;; @@ -179,7 +182,10 @@ main(){ # check if nbr days is numeric and > 1 and < $DAYS elif [[ "$2" =~ ^[0-9]+$ ]] && [ "$2" -ge 1 ] && [ "$2" -le "$DAYS" ]; then - expired_date $2 + expired_date $2 + if [ "${#expireDate[@]}" == "0" ]; then + msg_warn "There are no certificates that expire in less than $2 days." + fi for certData in "${expireDate[@]}"; do daysLeft=$(echo $certData | cut -d"|" -f1 ) cn=$(echo $certData | cut -d"|" -f2 ) diff --git a/bin/renew-cert.sh b/bin/renew-cert.sh index 6430255..08b6375 100755 --- a/bin/renew-cert.sh +++ b/bin/renew-cert.sh @@ -98,7 +98,10 @@ main(){ msg_warn " - $KEY_CA_PATH/$CA_KEY" exit 1 fi - expired_date $2 + expired_date $2 + if [ "${#expireDate[@]}" == "0" ]; then + msg_warn "There are no certificates that expire in less than $2 days." + fi for certData in "${expireDate[@]}"; do COMMON_NAME=$(echo $certData | cut -d"|" -f2 )