Added updates_available() and update_status()

This commit is contained in:
Gerhard Hoffmann 2022-06-03 19:59:50 +02:00
parent 6cca174d66
commit 57df68fabf

View File

@ -1 +1,35 @@
# !/bin/bash -
source ./log_helpers
if [ ${news_to_ismas_sourced:-1} = "1" ]; then # include only once
readonly APISM_DIRECT_PORT=7778
updates_available () {
local func="${FUNCNAME[0]}"
local json_response="$((echo -n '#M=APISM #C=REQ_ISMASParameter #J={}';
sleep 1) | nc localhost $APISM_DIRECT_PORT)"
if [ $? -eq 0 ]; then
local trigger="$(echo $json_response | jq -r .Fileupload.TRG)"
log_debug "$func:${LINENO}: apism_trigger=\"$trigger\""
grep -qE "WAIT" <<< "$trigger" && return 0
else
log_error "$func:${LINENO}: apism request failed"
fi
return 1
}
update_status () {
local func="${FUNCNAME[0]}"
local json_response="$((echo -n '#M=APISM #C=REQ_ISMASParameter #J={}';
sleep 1) | nc localhost $APISM_DIRECT_PORT)"
local trigger=""
if [ $? -eq 0 ]; then
trigger="$(echo $json_response | jq -r .Fileupload.TRG)"
log_debug "$func:${LINENO}: apism_trigger=\"$trigger\""
else
log_error "$func:${LINENO}: apism request failed"
fi
echo "$trigger"
}
fi