25 lines
499 B
Bash
25 lines
499 B
Bash
|
#!/bin/bash
|
||
|
|
||
|
if [[ "$#" -lt 2 ]]; then
|
||
|
echo "Usage: $0 <uuid> <command>"
|
||
|
exit 1;
|
||
|
fi
|
||
|
|
||
|
UUID=$1
|
||
|
ARGS=("$@")
|
||
|
COMMANDS=("${ARGS[@]:1}")
|
||
|
|
||
|
echo -n "PING: "
|
||
|
curl -fsS --retry 3 "https://health.sp-codes.de/ping/$UUID/start"
|
||
|
echo
|
||
|
|
||
|
echo "RUN ${COMMANDS[@]}:"
|
||
|
LOG=$("${COMMANDS[@]}" 2>&1)
|
||
|
CODE=$?
|
||
|
echo "$LOG"
|
||
|
|
||
|
echo -n "PING: "
|
||
|
# append the last 10 kb
|
||
|
echo "$LOG" | tail --bytes 10240 | curl -fsS --retry 3 --data-binary @- "https://health.sp-codes.de/ping/$UUID$([[ ${CODE} -ne 0 ]] && echo -n /fail)"
|
||
|
echo
|