#!/usr/bin/bash # SPDX-License-Identifier: MIT-0 set -euo pipefail SOURCE="/mnt/koji/repos-dist/mxos0/latest/" DEST_HOST="{{ groups['reposerver'][0] }}" DEST_DIR="/srv/www/repo/BaseOS" if [[ ! -d "$SOURCE" ]]; then echo "Source directory $SOURCE does not exist. Skipping sync." >&2 exit 0 fi echo "Starting atomic synchronization of mxos0 repository to $DEST_HOST..." # Pre-create directory structure on the destination /usr/bin/ssh -o StrictHostKeyChecking=no "root@${DEST_HOST}" "mkdir -p ${DEST_DIR}/x86_64/os ${DEST_DIR}/x86_64/debug/tree ${DEST_DIR}/source/tree" # Sync x86_64 to BaseOS/x86_64/os if [[ -d "${SOURCE}x86_64" ]]; then echo "Syncing x86_64 architecture..." /usr/bin/rsync -a -L --delete --delay-updates "${SOURCE}x86_64/" "root@${DEST_HOST}:${DEST_DIR}/x86_64/os/" fi # Sync x86_64-debuginfo to BaseOS/x86_64/debug/tree if [[ -d "${SOURCE}x86_64-debuginfo" ]]; then echo "Syncing x86_64 debuginfo..." /usr/bin/rsync -a -L --delete --delay-updates "${SOURCE}x86_64-debuginfo/" "root@${DEST_HOST}:${DEST_DIR}/x86_64/debug/tree/" fi # Sync src to BaseOS/source/tree if [[ -d "${SOURCE}src" ]]; then echo "Syncing source RPMs..." /usr/bin/rsync -a -L --delete --delay-updates "${SOURCE}src/" "root@${DEST_HOST}:${DEST_DIR}/source/tree/" fi echo "Synchronization completed successfully."