move syncing into common

This commit is contained in:
Louis Abel 2023-05-13 13:44:17 -07:00
parent f152ff5a44
commit e756e71203
Signed by: label
GPG Key ID: B37E62D143879B36
4 changed files with 83 additions and 24 deletions

BIN
func/common/.imports.sh.swp Normal file

Binary file not shown.

View File

@ -1,3 +1,4 @@
#!/bin/bash
# To be sourced by scripts to use # To be sourced by scripts to use
# Variables that can be overriden should be noted with optional context. It is # Variables that can be overriden should be noted with optional context. It is
@ -65,3 +66,59 @@ MODS=(
# Used to iterate over ISOs? # Used to iterate over ISOs?
# Override: Allowed # Override: Allowed
VARIANTS=(boot minimal dvd1) 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}"
}
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

View File

@ -15,7 +15,8 @@ fi
# Major Version (eg, 8) # Major Version (eg, 8)
MAJ=${RLVER} MAJ=${RLVER}
cd "${RELEASE_COMPOSE_ROOT}/compose" || { echo "Failed to change directory"; ret_val=1; exit 1; } #cd "${RELEASE_COMPOSE_ROOT}/compose" || { echo "Failed to change directory"; ret_val=1; exit 1; }
cd "${RELEASE_COMPOSE_ROOT}/" || { echo "Failed to change directory"; ret_val=1; exit 1; }
ret_val=$? ret_val=$?
if [ $ret_val -eq "0" ]; then if [ $ret_val -eq "0" ]; then
@ -23,17 +24,17 @@ if [ $ret_val -eq "0" ]; then
mkdir -p "${TARGET}" mkdir -p "${TARGET}"
# disabling because none of our files should be starting with dashes. If they # disabling because none of our files should be starting with dashes. If they
# are something is *seriously* wrong here. # are something is *seriously* wrong here.
# shellcheck disable=SC2035 #sudo -l && find **/* -maxdepth 0 -type d | parallel --will-cite -j 18 sudo rsync -av --chown=10004:10005 --progress --relative --human-readable --delete \
sudo -l && find **/* -maxdepth 0 -type d | parallel --will-cite -j 18 sudo rsync -av --chown=10004:10005 --progress --relative --human-readable --delete \ # {} "${TARGET}"
{} "${TARGET}"
# This is temporary until we implement rsync into empanadas # This is temporary until we implement rsync into empanadas
if [ -f "COMPOSE_ID" ]; then #if [ -f "COMPOSE_ID" ]; then
cp COMPOSE_ID "${TARGET}" # cp COMPOSE_ID "${TARGET}"
chown 10004:10005 "${TARGET}/COMPOSE_ID" # chown 10004:10005 "${TARGET}/COMPOSE_ID"
fi #fi
if [ -d "metadata" ]; then #if [ -d "metadata" ]; then
rsync -av --chown=10004:10005 --progress --relative --human-readable metadata "${TARGET}" # rsync -av --chown=10004:10005 --progress --relative --human-readable metadata "${TARGET}"
fi #fi
rsync_delete_staging "${TARGET}"
fi fi

View File

@ -15,27 +15,28 @@ fi
# Major Version (eg, 8) # Major Version (eg, 8)
MAJ=${RLVER} MAJ=${RLVER}
cd "${RELEASE_COMPOSE_ROOT}/compose" || { echo "Failed to change directory"; ret_val=1; exit 1; } #cd "${RELEASE_COMPOSE_ROOT}/compose" || { echo "Failed to change directory"; ret_val=1; exit 1; }
cd "${RELEASE_COMPOSE_ROOT}/" || { echo "Failed to change directory"; ret_val=1; exit 1; }
ret_val=$? ret_val=$?
if [ $ret_val -eq "0" ]; then if [ $ret_val -eq "0" ]; then
TARGET="${STAGING_ROOT}/${CATEGORY_STUB}/${REV}" TARGET="${STAGING_ROOT}/${CATEGORY_STUB}/${REV}"
mkdir -p "${TARGET}" mkdir -p "${TARGET}"
rsync_no_delete_staging "${TARGET}"
# disabling because none of our files should be starting with dashes. If they # disabling because none of our files should be starting with dashes. If they
# are something is *seriously* wrong here. # are something is *seriously* wrong here.
# shellcheck disable=SC2035 #sudo -l && find **/* -maxdepth 0 -type d | parallel --will-cite -j 18 sudo rsync -av --chown=10004:10005 --progress --relative --human-readable \
sudo -l && find **/* -maxdepth 0 -type d | parallel --will-cite -j 18 sudo rsync -av --chown=10004:10005 --progress --relative --human-readable \ # {} "${TARGET}"
{} "${TARGET}"
# This is temporary until we implement rsync into empanadas # This is temporary until we implement rsync into empanadas
if [[ "${COMPOSE}" == "Rocky" ]]; then #if [[ "${COMPOSE}" == "Rocky" ]]; then
if [ -f "COMPOSE_ID" ]; then # if [ -f "COMPOSE_ID" ]; then
cp COMPOSE_ID "${TARGET}" # cp COMPOSE_ID "${TARGET}"
chown 10004:10005 "${TARGET}/COMPOSE_ID" # chown 10004:10005 "${TARGET}/COMPOSE_ID"
fi # fi
if [ -d "metadata" ]; then # if [ -d "metadata" ]; then
rsync -av --chown=10004:10005 --progress --relative --human-readable metadata "${TARGET}" # rsync -av --chown=10004:10005 --progress --relative --human-readable metadata "${TARGET}"
fi # fi
fi # fi
fi fi