From ebeff580402a3bc950d5cd5cda0b74663aafe1f0 Mon Sep 17 00:00:00 2001 From: Louis Abel Date: Thu, 10 Nov 2022 11:56:09 -0700 Subject: [PATCH] general sync script cleanup --- sync/common_8 | 1 + sync/minor-release-sync-to-staging.sh | 6 ++++ sync/sync-to-prod.delete.sh | 42 +++++++++++++++++++++++++++ sync/sync-to-staging.delete.sh | 38 ++++++++++++++++++++++++ sync/sync-to-staging.sh | 14 +++++---- 5 files changed, 95 insertions(+), 6 deletions(-) create mode 100644 sync/sync-to-prod.delete.sh create mode 100644 sync/sync-to-staging.delete.sh diff --git a/sync/common_8 b/sync/common_8 index b19fd68..735c1a6 100644 --- a/sync/common_8 +++ b/sync/common_8 @@ -51,6 +51,7 @@ ALL_REPOS=( NONSIG_COMPOSE=( Rocky + Extras Rocky-devel Plus ) diff --git a/sync/minor-release-sync-to-staging.sh b/sync/minor-release-sync-to-staging.sh index 0996790..823e7d9 100644 --- a/sync/minor-release-sync-to-staging.sh +++ b/sync/minor-release-sync-to-staging.sh @@ -21,6 +21,12 @@ for COMPOSE in "${NONSIG_COMPOSE[@]}"; do sudo -l && find **/* -maxdepth 0 -type d | parallel --will-cite -j 18 sudo rsync -av --chown=10004:10005 --progress --relative --human-readable \ {} "${TARGET}" + if [[ "${COMPOSE}" == "Rocky" ]]; then + cp COMPOSE_ID "${TARGET}" + chown 10004:10005 "${TARGET}/COMPOSE_ID" + rsync -av --chown=10004:10005 --progress --relative --human-readable metadata "${TARGET}" + fi + # Return back to where we started popd || { echo "${COMPOSE}: Failed to change back"; break; } done diff --git a/sync/sync-to-prod.delete.sh b/sync/sync-to-prod.delete.sh new file mode 100644 index 0000000..b1446b2 --- /dev/null +++ b/sync/sync-to-prod.delete.sh @@ -0,0 +1,42 @@ +#!/bin/bash +# Syncs everything from staging to production + +# Source common variables +# shellcheck disable=SC2046,1091,1090 +source "$(dirname "$0")/common" + +REV=${REVISION}${APPEND_TO_DIR} + +cd "${STAGING_ROOT}/${CATEGORY_STUB}/${REV}" || { echo "Failed to change directory"; ret_val=1; exit 1; } +ret_val=$? + +if [ $ret_val -eq "0" ]; then + TARGET="${PRODUCTION_ROOT}/${CATEGORY_STUB}/${REV:0:3}" + mkdir -p "${TARGET}" + # disabling because none of our files should be starting with dashes. If they + # are something is *seriously* wrong here. + # shellcheck disable=SC2035 + 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}" + + # Temporary until empanadas has this support + if [ -f "COMPOSE_ID" ]; then + cp COMPOSE_ID "${TARGET}" + chown 10004:10005 "${TARGET}/COMPOSE_ID" + fi + + if [ -d "metadata" ]; then + rsync -av --chown=10004:10005 --progress --relative --human-readable metadata "${TARGET}" + fi + + # Full file list update for production root + cd "${PRODUCTION_ROOT}/${CATEGORY_STUB}/" || { echo "Failed to change directory"; exit 1; } + ## Hardlink everything except xml files + echo "Hard linking" + hardlink -x '.*\.xml.*' "${REVISION}" + echo "Syncing to prod completed. Please run the file list script." +fi + diff --git a/sync/sync-to-staging.delete.sh b/sync/sync-to-staging.delete.sh new file mode 100644 index 0000000..de1be80 --- /dev/null +++ b/sync/sync-to-staging.delete.sh @@ -0,0 +1,38 @@ +#!/bin/bash + +# Source common variables +# shellcheck disable=SC2046,1091,1090 +source "$(dirname "$0")/common" + +if [[ $# -eq 0 ]]; then + echo "You must specify a short name." + exit 1 +fi + +# Major Version (eg, 8) +MAJ=${RLVER} +# Short name (eg, NFV, extras, Rocky, gluster9) +SHORT=${1} + +cd "/mnt/compose/${MAJ}/latest-${SHORT}-${MAJ}/compose" || { echo "Failed to change directory"; ret_val=1; exit 1; } +ret_val=$? + +if [ $ret_val -eq "0" ]; then + TARGET="${STAGING_ROOT}/${CATEGORY_STUB}/${REV}" + mkdir -p "${TARGET}" + # disabling because none of our files should be starting with dashes. If they + # 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 \ + {} "${TARGET}" + + # This is temporary until we implement rsync into empanadas + if [ -f "COMPOSE_ID" ]; then + cp COMPOSE_ID "${TARGET}" + chown 10004:10005 "${TARGET}/COMPOSE_ID" + fi + + if [ -d "metadata" ]; then + rsync -av --chown=10004:10005 --progress --relative --human-readable metadata "${TARGET}" + fi +fi diff --git a/sync/sync-to-staging.sh b/sync/sync-to-staging.sh index d256fd5..dc14ba2 100644 --- a/sync/sync-to-staging.sh +++ b/sync/sync-to-staging.sh @@ -27,12 +27,14 @@ if [ $ret_val -eq "0" ]; then {} "${TARGET}" # This is temporary until we implement rsync into empanadas - if [ -f "COMPOSE_ID" ]; then - cp COMPOSE_ID "${TARGET}" - chown 10004:10005 "${TARGET}/COMPOSE_ID" - fi + if [[ "${COMPOSE}" == "Rocky" ]]; then + if [ -f "COMPOSE_ID" ]; then + cp COMPOSE_ID "${TARGET}" + chown 10004:10005 "${TARGET}/COMPOSE_ID" + fi - if [ -d "metadata" ]; then - rsync -av --chown=10004:10005 --progress --relative --human-readable metadata "${TARGET}" + if [ -d "metadata" ]; then + rsync -av --chown=10004:10005 --progress --relative --human-readable metadata "${TARGET}" + fi fi fi