#!/bin/bash

# Stupid-simple rsync of Rocky 9 minor versions, complete with all arches and historical packages


# Where we want the root of our repos to be, dir. of this script is fine
BASEDIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )

# source rsync mirror to pull data from
#SRC_REPO="rsync://dfw.mirror.rackspace.com/rocky/"
SRC_REPO="rsync://mirror.atl.genesisadaptive.com/rocky/"


VERSIONS="9.0 9.1 9.2 9.3 9.4 9.5 9.6 9.7 9.8"
REPOS="AppStream BaseOS CRB extras HighAvailability NFV RT ResilientStorage SAP SAPHANA devel plus"

# Bandwidth limit (kb/sec) and excludes
MAX_BW=35000
EXCLUDES="--exclude=debug/ --exclude=kickstart/"



# Make folders first
for vers in `echo "$VERSIONS"`; do
  for repo in `echo "$REPOS"`; do
    mkdir -p "${BASEDIR}/${vers}/${repo}"
  done
done


# Sync each repo
for vers in `echo "$VERSIONS"`; do
  for repo in `echo "$REPOS"`; do
    rsync -avzH --bwlimit=${MAX_BW} ${EXCLUDES}  ${SRC_REPO}/${vers}/${repo}/  ${BASEDIR}/${vers}/${repo}/
  done
done

