all repos — zion-terminal @ 66508a0a605214d34c7a2231848d44ee63b394b2

dotfiles

opt/zion-terminal/bin/zion-map (view raw)

 1
 2
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
#!/usr/bin/env bash
# ZION TERMINAL - Topologia ASCII do tailnet
# Cyberdeck criado por Pablo Murad em 2026
export LC_ALL=C
. /opt/zion-terminal/bin/zion-lib.sh 2>/dev/null
[ "$1" = "--help" ] && { echo "Uso: zion mapa — desenha o tailnet em arvore (peers online/offline, SO, exit nodes)."; exit 0; }
command -v tailscale >/dev/null || { echo "Tailscale nao instalado."; exit 1; }

self=$(hostname)
printf '%b  TAILNET — mapa%b\n' "$ZP$ZB" "$ZR"; zion_regua 50
printf '  %b(%s)%b  %b%s%b  %s\n' "$ZA" "este" "$ZR" "$ZP$ZB" "$self" "$ZR" "$(zion_ip_ts)"
printf '   %b│%b\n' "$ZMUT" "$ZR"

mapfile -t peers < <(tailscale status 2>/dev/null | awk '/^100\./ && $2!="'"$self"'"{print $0}')
n=${#peers[@]}; i=0
for line in "${peers[@]}"; do
  i=$((i+1)); ip=$(echo "$line" | awk '{print $1}'); name=$(echo "$line" | awk '{print $2}')
  so=$(echo "$line" | awk '{print $4}'); rest=$(echo "$line" | grep -o 'offline')
  [ "$i" -eq "$n" ] && ramo="└─" || ramo="├─"
  if [ -n "$rest" ]; then cor=$ZMUT; st="offline"; else cor=$ZOK; st="online"; fi
  printf '   %b%s%b %b%-16s%b %b%-8s%b %b%s%b\n' "$ZMUT" "$ramo" "$ZR" "$cor" "$name" "$ZR" "$ZGRY" "$so" "$ZR" "$cor" "$st" "$ZR"
done
zion_regua 50
online=$(printf '%s\n' "${peers[@]}" | grep -vc offline)
printf '  %b%d peers · %d online · exit nodes: %s%b\n' "$ZGRY" "$n" "$online" \
  "$(tailscale status 2>/dev/null | grep -c 'offers exit node' 2>/dev/null || echo '?')" "$ZR"