centos-mirror: add dry run mode

Add a dry-run flag and abstract the rsync command to make for easier
testing if modifying the copy flags.

Change-Id: Ie658b60257b94436b1eda0cddf6deb639a87d659
This commit is contained in:
Ian Wienand 2021-06-22 09:33:56 +10:00
parent 3d5d2779d2
commit 917544546f

View File

@ -24,6 +24,14 @@ else
TIMEOUT="timeout -k 2m 30m"
fi
_DRY_RUN=''
if [[ ${DRY_RUN:-0} -eq 1 ]]; then
echo "Dry run only"
_DRY_RUN='--dry-run'
fi
RSYNC="rsync ${_DRY_RUN} -rltvz"
BASE="/afs/.openstack.org/mirror/centos"
K5START="k5start -t -f /etc/centos.keytab service/centos-mirror -- $TIMEOUT"
@ -38,7 +46,7 @@ if ! [ -f $BASE/8-stream ]; then
fi
date --iso-8601=ns
echo "Running Centos 8-stream rsync..."
$K5START rsync -rltvz \
$K5START ${RSYNC} \
--delete \
--delete-excluded \
--exclude="isos" \
@ -56,7 +64,7 @@ if ! [ -f $BASE/8 ]; then
fi
date --iso-8601=ns
echo "Running Centos 8 rsync..."
$K5START rsync -rltvz \
$K5START ${RSYNC} \
--delete \
--delete-excluded \
--exclude="isos" \
@ -94,7 +102,7 @@ for REPO in $REPOS; do
date --iso-8601=ns
echo "Running rsync..."
$K5START rsync -rltvz \
$K5START ${RSYNC} \
--delete \
--delete-excluded \
--exclude="atomic" \
@ -110,9 +118,11 @@ for REPO in $REPOS; do
# TODO(pabelanger): Validate rsync process
done
date --iso-8601=ns | $K5START tee $BASE/timestamp.txt
echo "rsync completed successfully, running vos release."
vos_release $MIRROR_VOLUME
if [[ ${DRY_RUN:-0} -ne 1 ]]; then
date --iso-8601=ns | $K5START tee $BASE/timestamp.txt
echo "rsync completed successfully, running vos release."
vos_release $MIRROR_VOLUME
fi
date --iso-8601=ns
echo "Done."