#!/bin/sh
# Alpine 5G Router – run modem diagnostics on device via SSH
# Usage: ./scripts/ssh-diag-modem.sh [user@host]
# Or:    TARGET=root@192.168.1.1 ./scripts/ssh-diag-modem.sh

TARGET="${1:-${TARGET:-root@10.130.60.121}}"
SSH_OPTS="${SSH_OPTS:--o ConnectTimeout=10}"

echo "Running modem diagnostics on $TARGET"
echo ""

ssh $SSH_OPTS "$TARGET" "
  echo '========== diag-modem-up.sh =========='
  if [ -x /usr/local/bin/diag-modem-up.sh ]; then
    /usr/local/bin/diag-modem-up.sh
  else
    echo 'Not installed. Deploy first: ./scripts/deploy.sh $TARGET'
    echo 'Then re-run this script.'
    exit 1
  fi
  echo ''
  echo '========== diag-at-port.sh =========='
  if [ -x /usr/local/bin/diag-at-port.sh ]; then
    /usr/local/bin/diag-at-port.sh
  fi
"
