HTML_CSS
echo "${body_content}"
cat << 'HTML_FOOT'
HTML_FOOT
} > "${OUTPUT_HTML}"
vigia_url="${MIRRORS_VIGIA_URL:-https://mirrors.mx-os.mx/vigia/?x-ipfs-companion-no-redirect}"
sed -i "s|__MIRRORS_VIGIA_URL__|${vigia_url}|g" "${OUTPUT_HTML}"
echo " Generado: ${OUTPUT_HTML} ($(wc -c < "${OUTPUT_HTML}") bytes)"
# Generar index.html dedicado como portal principal
"${SCRIPT_DIR}/mxos-build-index.bash" "${REPO_ROOT}/index.html"
echo "==> Copiando archivos a directorio de preparación (${MIRRORS_STAGING_DIR})..."
if [[ -d "${MIRRORS_STAGING_DIR}" ]]; then
# Limpiar archivos de desarrollo/soporte innecesarios en la raíz de staging
rm -rf "${MIRRORS_STAGING_DIR}/README.rst" \
"${MIRRORS_STAGING_DIR}/logo.svg" \
"${MIRRORS_STAGING_DIR:?}/bin" \
"${MIRRORS_STAGING_DIR}/config" \
"${MIRRORS_STAGING_DIR:?}/etc" \
"${MIRRORS_STAGING_DIR}/systemd" \
"${MIRRORS_STAGING_DIR}/guardianes.json" 2>/dev/null || true
# Copiar páginas web y metadatos públicos
cp -f "${OUTPUT_HTML}" "${MIRRORS_STAGING_DIR}/README.html"
cp -f "${REPO_ROOT}/index.html" "${MIRRORS_STAGING_DIR}/index.html"
for meta_file in bitacora-cids.json modules.json cover.jpg; do
if [[ -f "${REPO_ROOT}/${meta_file}" ]]; then
cp -f "${REPO_ROOT}/${meta_file}" "${MIRRORS_STAGING_DIR}/${meta_file}"
fi
done
# Sincronizar artefactos web de Vigía hacia staging si están disponibles
vigia_dist="${MIRRORS_VIGIA_DIST_DIR:-${REPO_ROOT}/../vigia/web/dist}"
if [[ -d "${vigia_dist}" ]] && [[ -f "${vigia_dist}/vigia.html" ]]; then
mkdir -p "${MIRRORS_STAGING_DIR}/vigia"
cp -f "${vigia_dist}/vigia.html" "${MIRRORS_STAGING_DIR}/vigia/index.html"
for f in favicon.svg favicon.ico logo.svg guardianes.json modules.json; do
if [[ -f "${vigia_dist}/${f}" ]]; then
cp -f "${vigia_dist}/${f}" "${MIRRORS_STAGING_DIR}/vigia/${f}"
fi
done
fi
mkdir -p "${MIRRORS_STAGING_DIR}/nodo" "${MIRRORS_STAGING_DIR}/docs"
cp -rf "${REPO_ROOT}/nodo/"* "${MIRRORS_STAGING_DIR}/nodo/"
if [[ -d "${REPO_ROOT}/docs/_build/html" ]]; then
cp -rf "${REPO_ROOT}/docs/_build/html/"* "${MIRRORS_STAGING_DIR}/docs/"
fi
echo " Archivos sincronizados en staging (raíz limpia con portal, vigia/, docs/ y nodo/)."
fi
echo "==> Proceso completado exitosamente."