#!/bin/bash # To be sourced by scripts to use # Variables that can be overriden should be noted with optional context. It is # expected that these values are here in this file (per variable or per set): # # * Allowed # * Allowed with caveats # * Not Allowed # * Required # Temporary probably. This makes it so if RLVER=... is called before the script # it will set the version for the variables to call up. This was easier than # creating duplicates of a bunch of stuff. Default version is 8. if [ -z "$RLVER" ]; then export RLVER=8 fi if [ -z "$RLREL" ]; then export RLREL=stable fi # Override: Not Allowed STAGING_ROOT="/mnt/repos-staging" PRODUCTION_ROOT="/mnt/repos-production" COMPOSE_ROOT="/mnt/compose" # Override: Not Allowed # relative to ${ENV}_ROOT CATEGORY_STUB="mirror/pub/rocky" SIG_CATEGORY_STUB="mirror/pub/sig" # Override: Required #RELEASE_DIR="${CATEGORY_STUB}/${REVISION}${APPEND_TO_DIR}" # Define arches we support # Override: Not Allowed ARCHES=(x86_64 aarch64) # Source Major common # Override: Not Allowed test -f "$(dirname "${BASH_SOURCE[0]}")/common_${RLVER}" && source "$(dirname "${BASH_SOURCE[0]}")/common_${RLVER}" if [ "$?" -ne 0 ]; then echo "Could not source common_${RLVER}" exit 1 fi # Combined variables based on common data # Override: Capable with caveats REV="${REVISION}${APPEND_TO_DIR}" # These repos have modules # Override: Allowed # This variable can (and probably should) be overriden by their common_X files # that are sourced. The reason is because future EL's can potentially change up # which repos are module based (whether adding/removing). This is something to # keep in mind. For example, Fedora (sanely) has a "base" repo and then an # updates repo for both their regular packages *and* their modularity repos. # This obviously makes sense and I can only hope Red Hat decides to bring that # back in some way. MODS=( AppStream PowerTools ) # Used to iterate over ISOs? # Override: Allowed VARIANTS=(boot minimal dvd1) # Syncing functions function parallel_rsync_no_delete_staging() { TARGET="${1}" sudo -l && find **/* -maxdepth 0 -type d | parallel --will-cite -j 18 sudo rsync -av --chown=10004:10005 --progress --relative --human-readable {} "${TARGET}" } function parallel_rsync_no_delete_prod() { TARGET="${1}" sudo -l && find ./ -mindepth 1 -maxdepth 1 -type d -exec find {}/ -mindepth 1 -maxdepth 1 -type d \;|sed 's/^..//g' | parallel --will-cite -j 18 sudo rsync -av --chown=10004:10005 --progress --relative --human-readable {} "${TARGET}" # shellcheck disable=SC2035 sudo -l && find ** -maxdepth 0 -type l | parallel --will-cite -j 18 sudo rsync -av --chown=10004:10005 --progress --relative --human-readable {} "${TARGET}" } function parallel_rsync_delete_staging() { TARGET="${1}" sudo -l && find **/* -maxdepth 0 -type d | parallel --will-cite -j 18 sudo rsync -av --chown=10004:10005 --progress --relative --human-readable --delete {} "${TARGET}" } function parallel_rsync_delete_prod() { TARGET="${1}" sudo -l && find ./ -mindepth 1 -maxdepth 1 -type d -exec find {}/ -mindepth 1 -maxdepth 1 -type d \;|sed 's/^..//g' | parallel --will-cite -j 18 sudo rsync -av --chown=10004:10005 --progress --relative --human-readable --delete {} "${TARGET}" # shellcheck disable=SC2035 sudo -l && find ** -maxdepth 0 -type l | parallel --will-cite -j 18 sudo rsync -av --chown=10004:10005 --progress --relative --human-readable {} "${TARGET}" } function rsync_no_delete_staging() { TARGET="${1}" sudo -l && rsync -vrlptDSH --chown=10004:10005 --progress --human-readable compose/ "${TARGET}" } function rsync_no_delete_prod() { REV="${1}" TARGET="${2}" sudo -l && rsync -vrlptDSH --chown=10004:10005 --progress --human-readable "${REV}/" "${TARGET}" } function rsync_delete_staging() { TARGET="${1}" sudo -l && rsync -vrlptDSH --chown=10004:10005 --progress --human-readable --delete compose/ "${TARGET}" } function rsync_delete_prod() { REV="${1}" TARGET="${2}" sudo -l && rsync -vrlptDSH --chown=10004:10005 --progress --human-readable --delete "${REV}/" "${TARGET}" } function perform_hardlink() { TARGET="${1}" hardlink -x '.*\.xml.*' "${TARGET}" } export -f parallel_rsync_no_delete_staging export -f parallel_rsync_no_delete_prod export -f parallel_rsync_delete_staging export -f parallel_rsync_delete_prod export -f rsync_no_delete_staging export -f rsync_no_delete_prod export -f rsync_delete_staging export -f rsync_delete_prod export -f perform_hardlink