#!/usr/bin/env sh
# Metamorphose Swarm C2 one-command gateway install (Linux, systemd). Usage: sudo sh install.sh <lat> <lon> [tak host:port] [--offline]
set -e
LAT="$1"; LON="$2"; TAK="${3:-239.2.3.1:6969}"; EXTRA="$4"
[ -z "$LAT" ] || [ -z "$LON" ] && { echo "usage: sudo sh install.sh <lat> <lon> [tak host:port] [--offline]"; exit 1; }
command -v python3 >/dev/null || { echo "python3 is required"; exit 1; }
BASE=https://metamorphosesystems.com/edge
mkdir -p /opt/metamorphose
curl -fsSL "$BASE/metamorphose-edge.py" -o /opt/metamorphose/metamorphose-edge.py
cat > /etc/systemd/system/metamorphose-edge.service <<UNIT
[Unit]
Description=Metamorphose Swarm C2 edge bridge
After=network-online.target
[Service]
ExecStart=/usr/bin/python3 /opt/metamorphose/metamorphose-edge.py --lat $LAT --lon $LON --tak $TAK $EXTRA
Restart=always
DynamicUser=yes
[Install]
WantedBy=multi-user.target
UNIT
systemctl daemon-reload && systemctl enable --now metamorphose-edge
curl -fsS https://metamorphosesystems.com/api/public/cuas/health >/dev/null && echo "Cloud link OK" || echo "Cloud unreachable: running local cueing only"
echo "Installed. Live feed: http://127.0.0.1:8765/events  Sensors: CoT UDP 4242, JSON UDP 5005"
