improve dummy check and in scripts

This commit is contained in:
Pim Kunis 2023-05-26 23:20:20 +02:00
parent e45133a155
commit c78384f93b
2 changed files with 35 additions and 3 deletions

20
check
View file

@ -1,6 +1,20 @@
#!/bin/sh
exec 3>&1
exec 1>&2
set -e
echo "[]" >&3
exec 3>&1 # make stdout available as fd 3 for the result
exec 1>&2 # redirect all output to stderr for logging
PAYLOAD=$(mktemp /tmp/resource-check.XXXXXX)
cat > "$PAYLOAD" <&0
TS=$(jq '.version.timestamp // empty' < "$PAYLOAD")
if [ -z "$TS" ]; then
echo '[]' >&3
else
jq -n "[
{ timestamp: $TS }
]" >&3
fi

18
in
View file

@ -1 +1,19 @@
#!/bin/sh
set -e
exec 3>&1 # make stdout available as fd 3 for the result
exec 1>&2 # redirect all output to stderr for logging
PAYLOAD=$(mktemp /tmp/resource-in.XXXXXX)
cat > "$PAYLOAD" <&0
TS=$(jq '.version.timestamp // empty' < "$PAYLOAD")
[ -z "$TS" ] && TS='"none"'
jq -n "{
version: {
timestamp: $TS
}
}" >&3