Some useful bash scripts.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

24 lines
499 B

#!/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