fix: no boolean for jq, it considers "false" as missing (null)

This commit is contained in:
Oleg Sheynin 2024-12-03 13:41:32 -05:00
parent 1fe5edcd74
commit 8b38ffa1af
2 changed files with 9 additions and 10 deletions

View File

@ -1 +1 @@
1.8.8.F1,build script fix, host checking improving 1.8.8.F2,no boolean for jq, it considers "false" as missing (null)

View File

@ -5,7 +5,7 @@
# "users": ["oleg"], # "users": ["oleg"],
# "type": "cloud", # "type": "cloud",
# "ssh_port": 7822, # "ssh_port": 7822,
# # "to_check": false # # "to_check": "false"
# "timeout_sec": 5 # "timeout_sec": 5
# }, # },
@ -48,6 +48,7 @@ User=oleg
Hosts=() Hosts=()
DEFAULT_SSH_PORT=22 DEFAULT_SSH_PORT=22
DEFAULT_TIMEOUT=5 DEFAULT_TIMEOUT=5
DEFAULT_TO_CHECK="true"
Domains=("${Domains[@]}" "$(get_domains)") Domains=("${Domains[@]}" "$(get_domains)")
for Domain in ${Domains[@]} ; do for Domain in ${Domains[@]} ; do
@ -58,18 +59,16 @@ for Host in ${Hosts[@]} ; do
host=$(echo $Host | cut -d'.' -f1) host=$(echo $Host | cut -d'.' -f1)
Domain=$(echo $Host | cut -d'.' -f2-) Domain=$(echo $Host | cut -d'.' -f2-)
# ToCheck=$(echo "$HOSTS_CONFIG" | jq -r --arg domain "$Domain" --arg host "$host" '.[$domain][$host].to_check // "Yes"')
# if [ "${ToCheck^^}" == "NO" ]; then
# continue
# fi
ToCheck=$(echo "$HOSTS_CONFIG" | jq -r --arg domain "$Domain" --arg host "$host" '.[$domain][$host].to_check // true')
if [ "$ToCheck" != "true" ]; then
continue
fi
PortSSH=$(echo "$HOSTS_CONFIG" | jq -r --arg domain "$Domain" --arg host "$host" '.[$domain][$host].ssh_port // '"$DEFAULT_SSH_PORT"'') PortSSH=$(echo "$HOSTS_CONFIG" | jq -r --arg domain "$Domain" --arg host "$host" '.[$domain][$host].ssh_port // '"$DEFAULT_SSH_PORT"'')
Timeout=$(echo "$HOSTS_CONFIG" | jq -r --arg domain "$Domain" --arg host "$host" '.[$domain][$host].timeout_sec // '"$DEFAULT_TIMEOUT"'') Timeout=$(echo "$HOSTS_CONFIG" | jq -r --arg domain "$Domain" --arg host "$host" '.[$domain][$host].timeout_sec // '"$DEFAULT_TIMEOUT"'')
ToCheck=$(echo "$HOSTS_CONFIG" | jq -r --arg domain "$Domain" --arg host "$host" '.[$domain][$host].to_check // '"$DEFAULT_TO_CHECK"'')
to_check="${ToCheck}^^"
if [ "${to_check}" != "TRUE" && "${to_check}" != "YES" && "${to_check}" != "Y" && "${to_check}" != "T" ]; then
continue
fi
echo "Checking host: $Host on port $PortSSH" echo "Checking host: $Host on port $PortSSH"
# Use nc to check if the specified port is open # Use nc to check if the specified port is open