gioser

sergio/takana

> Una distribución Linux construida con un laboratorio funcional y hermético en el > sótano, y una terminal mutable, clásica y anárquica en el piso de arriba — diseñada > desde el suelo para que una IA programadora entienda, modifique y co…

TOML 1430Shell 145Markdown 87Rust 852973 Definiciones

⎇ 03e908fa20939db7003e6aeecc78d6d930971d21 scripts/foco-egress-remoto.sh Shell · 49 líneas · 2.3 KB Historia crudo

atuq §6.5: el foco por cgroup MEDIDO — y corregido el propio documento 212b304b6 · Sergio ·

1#!/usr/bin/env bash
2# Corre `test-foco-egress.sh` donde SÍ hay root: empaqueta los artefactos VIGENTES, los manda al
3# worker y trae el veredicto.
4#
5#   scripts/foco-egress-remoto.sh [--broken-rules] [host]   (host default: 1º de scripts/farm/.fleet)
6#
7# ⚠ Los artefactos se resuelven con `takana hash`, NO con `ls store/*-gmp`. La diferencia no es
8# estética: el store guarda artefactos VIEJOS con el mismo nombre, y la primera corrida de esto
9# empaquetó un `gmp` de otra época que sólo traía `libgmp.a` ⇒ `libnftables.so` no relocaba. En el
10# hub no se veía porque el lab tiene su propia libgmp y la tapaba. Sellado ≠ vigente.
11set -euo pipefail
12cd "$(dirname "$0")/.."
13
14ROTO=""
15if [ "${1:-}" = "--broken-rules" ]; then ROTO="--broken-rules"; shift; fi
16HOST="${1:-}"
17if [ -z "$HOST" ]; then
18    HOST="$(awk 'NR==1{print $1}' scripts/farm/.fleet 2>/dev/null || true)"
19    [ -n "$HOST" ] || { echo "✗ no hay host: pasalo por argumento o poné uno en scripts/farm/.fleet" >&2; exit 2; }
20fi
21LLAVE="${SSH_KEY:-$HOME/.ssh/github5}"
22TAKANA=./target/release/takana
23TMP="$(mktemp -d)"; trap 'rm -rf "$TMP"' EXIT
24
25echo "== artefactos vigentes"
26DIRS=()
27for r in nftables libmnl libnftnl gmp; do
28    h="$($TAKANA --store ./store hash "recipes/$r.toml" | tail -1)"; h="${h#b3:}"
29    d="store/$h-$r"
30    [ -d "$d" ] || { echo "✗ $r vigente no está sellado ($d) — construilo antes" >&2; exit 1; }
31    [ -n "$(ls -A "$d")" ] || { echo "✗ $r vigente está VACÍO: eso no es un artefacto, es un nombre" >&2; exit 1; }
32    echo "   $r → ${h:0:12}"
33    DIRS+=("$h-$r")
34done
35tar czf "$TMP/artefactos-nft.tar.gz" -C store "${DIRS[@]}"
36
37echo "== enviando a $HOST"
38scp -i "$LLAVE" -o StrictHostKeyChecking=no -q \
39    scripts/test-foco-egress.sh .dev-fs/alpine-minirootfs.tar.gz "$TMP/artefactos-nft.tar.gz" \
40    "root@$HOST:/root/"
41# `set -e` mataría el script antes de leer $? de un ssh que falla, y entonces el veredicto ROJO del
42# guardián llegaría como si nunca hubiera corrido. Se captura explícitamente.
43SALIDA=0
44ssh -i "$LLAVE" -o BatchMode=yes "root@$HOST" \
45    "bash /root/test-foco-egress.sh --rootfs /root/alpine-minirootfs.tar.gz --artifacts /root/artefactos-nft.tar.gz $ROTO" \
46    || SALIDA=$?
47ssh -i "$LLAVE" -o BatchMode=yes "root@$HOST" \
48    'rm -f /root/test-foco-egress.sh /root/alpine-minirootfs.tar.gz /root/artefactos-nft.tar.gz' || true
49exit $SALIDA