Skip to content

Commit

Permalink
If pool is not registered, don't bother with KES related logic as a p…
Browse files Browse the repository at this point in the history
…art of pool list action
  • Loading branch information
Greg B committed Nov 23, 2024
1 parent bc41248 commit aa8a028
Showing 1 changed file with 17 additions and 14 deletions.
31 changes: 17 additions & 14 deletions scripts/cnode-helper-scripts/cntools.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit aa8a028

Please sign in to comment.