#!/bin/bash # Preparacion del crawl: hosts, liberacion de RAM, estructura de la corrida set -uo pipefail BASE=/home/rafa/joomla-migration/mirror-antiguo INV=$BASE/inventory WORKERS=${WORKERS:-4} IP=$(docker inspect joomla-mirror-web -f '{{range $k,$v := .NetworkSettings.Networks}}{{$v.IPAddress}}{{end}}') if ! grep -q 'antiguo.feadulta.com' /etc/hosts; then echo "$IP antiguo.feadulta.com" | sudo -n tee -a /etc/hosts >/dev/null 2>&1 \ || echo "AVISO: no pude escribir /etc/hosts (hazlo como root)" fi grep 'antiguo.feadulta.com' /etc/hosts || true # --- parar contenedores no implicados (autorizado por Rafa) --- KEEP='joomla-mirror-web|joomla-mysql|gitea|hub-proxy|beszel-agent' STOPPED=$BASE/stopped-containers.txt if [ ! -s "$STOPPED" ]; then docker ps --format '{{.Names}}' | grep -vE "^($KEEP)$" > "$STOPPED" echo "--- parando ---"; cat "$STOPPED" xargs -r -a "$STOPPED" docker stop >/dev/null fi echo "--- en marcha ahora ---" docker ps --format '{{.Names}}' | tr '\n' ' '; echo # --- estructura de la corrida --- RUN=$(date -u +%Y%m%dT%H%M%SZ) DIR=$BASE/runs/$RUN mkdir -p "$DIR/raw" "$DIR/chunks" "$DIR/logs" echo "$RUN" > "$BASE/CURRENT_RUN" split -n l/$WORKERS -d --additional-suffix=.txt "$INV/urls-input.txt" "$DIR/chunks/urls-" wc -l "$DIR/chunks"/*.txt cat > "$DIR/meta.json" <