From aa8a028d76d2563582fc8e5c3cc8360196b75675 Mon Sep 17 00:00:00 2001 From: Greg B Date: Sun, 24 Nov 2024 00:20:23 +1100 Subject: [PATCH] If pool is not registered, don't bother with KES related logic as a part of pool list action --- scripts/cnode-helper-scripts/cntools.sh | 31 ++++++++++++++----------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/scripts/cnode-helper-scripts/cntools.sh b/scripts/cnode-helper-scripts/cntools.sh index 54c36c3b4..c096470fe 100755 --- a/scripts/cnode-helper-scripts/cntools.sh +++ b/scripts/cnode-helper-scripts/cntools.sh @@ -2804,23 +2804,26 @@ function main { println "$(printf "%-21s : ${FG_LGRAY}%s${NC}" "ID (hex)" "${pool_id}")" [[ -n ${pool_id_bech32} ]] && println "$(printf "%-21s : ${FG_LGRAY}%s${NC}" "ID (bech32)" "${pool_id_bech32}")" println "$(printf "%-21s : %s" "Registered" "${pool_registered}")" - unset pool_kes_start - unset remaining_kes_periods - [[ -f "${pool}/${POOL_CURRENT_KES_START}" ]] && pool_kes_start="$(cat "${pool}/${POOL_CURRENT_KES_START}")" - if ! kesExpiration ${pool_kes_start}; then - println "$(printf "%-21s : ${FG_LGRAY}%s${NC} - ${FG_RED}%s${NC}%s${FG_GREEN}%s${NC}" "KES expiration date" "ERROR" ": failure during KES calculation for " "$(basename ${pool})")" - else - if [[ ${expiration_time_sec_diff} -lt ${KES_ALERT_PERIOD} ]]; then - if [[ ${expiration_time_sec_diff} -lt 0 ]]; then - println "$(printf "%-21s : ${FG_LGRAY}%s${NC} - ${FG_RED}%s${NC} %s ago" "KES expiration date" "${kes_expiration}" "EXPIRED!" "$(timeLeft ${expiration_time_sec_diff:1})")" + if [[ ${pool_registered} = *YES* ]]; then + unset pool_kes_start + unset remaining_kes_periods + [[ -f "${pool}/${POOL_CURRENT_KES_START}" ]] && pool_kes_start="$(cat "${pool}/${POOL_CURRENT_KES_START}")" + + if ! kesExpiration ${pool_kes_start}; then + println "$(printf "%-21s : ${FG_LGRAY}%s${NC} - ${FG_RED}%s${NC}%s${FG_GREEN}%s${NC}" "KES expiration date" "ERROR" ": failure during KES calculation for " "$(basename ${pool})")" + else + if [[ ${expiration_time_sec_diff} -lt ${KES_ALERT_PERIOD} ]]; then + if [[ ${expiration_time_sec_diff} -lt 0 ]]; then + println "$(printf "%-21s : ${FG_LGRAY}%s${NC} - ${FG_RED}%s${NC} %s ago" "KES expiration date" "${kes_expiration}" "EXPIRED!" "$(timeLeft ${expiration_time_sec_diff:1})")" + else + println "$(printf "%-21s : ${FG_LGRAY}%s${NC} - ${FG_RED}%s${NC} %s until expiration" "KES expiration date" "${kes_expiration}" "ALERT!" "$(timeLeft ${expiration_time_sec_diff})")" + fi + elif [[ ${expiration_time_sec_diff} -lt ${KES_WARNING_PERIOD} ]]; then + println "$(printf "%-21s : ${FG_LGRAY}%s${NC} - ${FG_YELLOW}%s${NC} %s until expiration" "KES expiration date" "${kes_expiration}" "WARNING!" "$(timeLeft ${expiration_time_sec_diff})")" else - println "$(printf "%-21s : ${FG_LGRAY}%s${NC} - ${FG_RED}%s${NC} %s until expiration" "KES expiration date" "${kes_expiration}" "ALERT!" "$(timeLeft ${expiration_time_sec_diff})")" + println "$(printf "%-21s : ${FG_LGRAY}%s${NC}" "KES expiration date" "${kes_expiration}")" fi - elif [[ ${expiration_time_sec_diff} -lt ${KES_WARNING_PERIOD} ]]; then - println "$(printf "%-21s : ${FG_LGRAY}%s${NC} - ${FG_YELLOW}%s${NC} %s until expiration" "KES expiration date" "${kes_expiration}" "WARNING!" "$(timeLeft ${expiration_time_sec_diff})")" - else - println "$(printf "%-21s : ${FG_LGRAY}%s${NC}" "KES expiration date" "${kes_expiration}")" fi fi done < <(find "${POOL_FOLDER}" -mindepth 1 -maxdepth 1 -type d -print0 | sort -z)