Files
gree-controller/scripts/network-debug.sh
T
2026-09-03 13:08:28 +02:00

54 lines
1.3 KiB
Bash
Executable File

#!/usr/bin/env bash
set -Eeuo pipefail
IFACE="${1:-}"
TARGET="${2:-}"
ENV_FILE="${GREE_CONTROLLER_ENV_FILE:-/etc/gree-controller.env}"
if [[ -z "$IFACE" && -r "$ENV_FILE" ]]; then
IFACE="$(sed -n 's/^GREE_CONTROLLER_GREE_INTERFACE=//p' "$ENV_FILE" | tail -n1)"
fi
if [[ -z "$TARGET" && -r "$ENV_FILE" ]]; then
TARGET="$(sed -n 's/^GREE_CONTROLLER_DISCOVERY_BROADCAST=//p' "$ENV_FILE" | tail -n1)"
TARGET="${TARGET%:*}"
fi
if [[ -z "$IFACE" ]]; then
echo "Usage: $0 <interface> [broadcast-ip]" >&2
echo "Example: $0 eth1 10.87.65.127" >&2
exit 2
fi
echo "==> Interface"
ip -br addr show dev "$IFACE"
echo
echo "==> IPv4 details"
ip -4 addr show dev "$IFACE"
echo
echo "==> Routes"
ip route show dev "$IFACE"
echo
if [[ -n "$TARGET" ]]; then
echo "==> Route to discovery target $TARGET"
ip route get "$TARGET" || true
echo
fi
echo "==> GREE Controller environment"
if [[ -r "$ENV_FILE" ]]; then
grep -E '^(GREE_CONTROLLER_GREE_INTERFACE|GREE_CONTROLLER_DISCOVERY_BROADCAST|GREE_CONTROLLER_SIMULATE|GREE_CONTROLLER_AUTO_SEED)=' "$ENV_FILE" || true
else
echo "$ENV_FILE is not readable"
fi
echo
if command -v tcpdump >/dev/null 2>&1; then
echo "Capture discovery traffic with:"
echo " tcpdump -ni $IFACE -vv 'udp port 7000'"
else
echo "tcpdump is not installed. Optional: apt-get install tcpdump"
fi