feat(sync): add dedicated Fedora updates synchronization script
- Download Fedora 43, 44, and 45 updates with 10 parallel streams - Maintain backward-compatible symlinks for shortened updates paths - Auto-rebuild HTML, UnixFS filestore ingest, IPNS/DNSLink publish, and web0 pin Signed-off-by: Rénich Bon Ćirić <renich@evalinux.com> Co-authored-by: Antigravity <antigravity@google.com>
This commit is contained in:
parent
7c7ef4de69
commit
fa8896effe
1 changed files with 100 additions and 0 deletions
100
bin/mxos-sync-fedora-updates.bash
Executable file
100
bin/mxos-sync-fedora-updates.bash
Executable file
|
|
@ -0,0 +1,100 @@
|
|||
#!/usr/bin/bash
|
||||
set -euo pipefail
|
||||
IFS=$'\n\t'
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
REPO_ROOT="$(cd "${SCRIPT_DIR}/.." && pwd)"
|
||||
|
||||
if [[ -f "${REPO_ROOT}/config/etc/mirrors.env" ]]; then
|
||||
# shellcheck source=/dev/null
|
||||
source "${REPO_ROOT}/config/etc/mirrors.env"
|
||||
elif [[ -f "${REPO_ROOT}/etc/mirrors.env" ]]; then
|
||||
# shellcheck source=/dev/null
|
||||
source "${REPO_ROOT}/etc/mirrors.env"
|
||||
fi
|
||||
|
||||
STAGING_DIR="${MIRRORS_STAGING_DIR:-$HOME/ipfs/staging}"
|
||||
LOG_DIR="${MIRRORS_LOG_DIR:-$HOME/ipfs/logs}"
|
||||
mkdir -p "${STAGING_DIR}" "${LOG_DIR}"
|
||||
|
||||
LOG_FILE="${LOG_DIR}/fedora-updates-sync-$(date +%Y%m%d-%H%M%S).log"
|
||||
|
||||
log() {
|
||||
local timestamp
|
||||
timestamp="$(date -u +"%Y-%m-%dT%H:%M:%SZ")"
|
||||
echo "[${timestamp}] $*" | tee -a "${LOG_FILE}"
|
||||
}
|
||||
|
||||
sync_update_repo() {
|
||||
local ver="$1"
|
||||
local dest_os="${STAGING_DIR}/fedora/updates/${ver}/Everything/x86_64/os"
|
||||
local url="https://dl.fedoraproject.org/pub/fedora/linux/updates/${ver}/Everything/x86_64/"
|
||||
local repo_id="f${ver}-updates"
|
||||
|
||||
mkdir -p "${dest_os}"
|
||||
|
||||
log "INFO: Sincronizando Fedora ${ver} Updates desde ${url}..."
|
||||
dnf5 --setopt=max_parallel_downloads=10 \
|
||||
--repofrompath="${repo_id},${url}" \
|
||||
--repo="${repo_id}" reposync \
|
||||
--download-metadata \
|
||||
--norepopath \
|
||||
--destdir="${dest_os}" \
|
||||
--delete 2>&1 | tee -a "${LOG_FILE}"
|
||||
|
||||
# Crear enlace de conveniencia para clientes con ruta abreviada (updates/$ver/$basearch)
|
||||
local compat_link="${STAGING_DIR}/fedora/updates/${ver}/x86_64"
|
||||
if [[ ! -e "${compat_link}" ]]; then
|
||||
ln -s "Everything/x86_64/os" "${compat_link}"
|
||||
log "INFO: Enlace de compatibilidad creado: ${compat_link} -> Everything/x86_64/os"
|
||||
fi
|
||||
}
|
||||
|
||||
main() {
|
||||
log "=========================================================="
|
||||
log " Inicio de Sincronización de Actualizaciones Fedora (updates)"
|
||||
log " Destino: ${STAGING_DIR}/fedora/updates"
|
||||
log " Log: ${LOG_FILE}"
|
||||
log "=========================================================="
|
||||
|
||||
# 1. Fedora 43 Updates (~60 GB)
|
||||
sync_update_repo "43"
|
||||
|
||||
# 2. Fedora 44 Updates (~53 GB)
|
||||
sync_update_repo "44"
|
||||
|
||||
# 3. Fedora 45 Updates (0 GB, inicialización de metadatos)
|
||||
sync_update_repo "45"
|
||||
|
||||
log "INFO: Actualizaciones sincronizadas. Regenerando tamaños y portales..."
|
||||
"${SCRIPT_DIR}/mxos-build-html.bash" 2>&1 | tee -a "${LOG_FILE}"
|
||||
|
||||
log "INFO: Ingesta UnixFS y publicación en IPFS..."
|
||||
local root_cid
|
||||
root_cid="$(ipfs add -r --nocopy --cid-version=1 --hash=sha2-256 -Q "${STAGING_DIR}")"
|
||||
log "INFO: Nuevo CID raíz: ${root_cid}"
|
||||
|
||||
ipfs pin add "${root_cid}" >/dev/null 2>&1 || true
|
||||
|
||||
if ipfs files stat /mxos-root >/dev/null 2>&1; then
|
||||
ipfs files rm -r /mxos-root
|
||||
fi
|
||||
ipfs files cp "/ipfs/${root_cid}" /mxos-root
|
||||
|
||||
log "INFO: Actualizando DNSLink y publicando IPNS..."
|
||||
"${SCRIPT_DIR}/mxos-dnslink-update.bash" "${root_cid}" 2>&1 | tee -a "${LOG_FILE}" || true
|
||||
"${SCRIPT_DIR}/mxos-ipns-publish.bash" "${root_cid}" 2>&1 | tee -a "${LOG_FILE}" || true
|
||||
|
||||
log "INFO: Replicando en web0.mx-os.mx..."
|
||||
# shellcheck disable=SC2029
|
||||
ssh root@web0.mx-os.mx "ipfs --api=/ip4/127.0.0.1/tcp/5001 swarm connect /ip4/192.168.1.100/tcp/4001/p2p/$(ipfs id -f='<id>') || true"
|
||||
# shellcheck disable=SC2029
|
||||
ssh root@web0.mx-os.mx "ipfs --api=/ip4/127.0.0.1/tcp/5001 pin add ${root_cid}/fedora/updates" || true
|
||||
|
||||
log "=========================================================="
|
||||
log " Sincronización de Fedora Updates completada con éxito."
|
||||
log " CID activo: ${root_cid}"
|
||||
log "=========================================================="
|
||||
}
|
||||
|
||||
main "$@"
|
||||
Loading…
Reference in a new issue