Last active
July 10, 2022 20:06
-
-
Save keithchambers/f159cfa84124d527485c to your computer and use it in GitHub Desktop.
Yum remo mirror with snapshots
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash -ex | |
URL="$1" | |
LABEL="$2" | |
BASEDIR="/vagrant/mirror" | |
MIRRORDIR="${BASEDIR}/${LABEL}" | |
SNAPSHOTDIR="${MIRRORDIR}/$(date +%Y%m%d)" | |
if [[ $(command -v grinder >/dev/null 2>&1) -ne 0 ]] | |
then | |
echo "Error: grinder command was not found." | |
exit 1 | |
fi | |
mkdir -p ${BASEDIR} | |
grinder yum --debug \ | |
--parallel 10 \ | |
--url ${URL} \ | |
--label ${LABEL} \ | |
--basepath ${BASEDIR} | |
[[ -d ${SNAPSHOTDIR} ]] && SNAPSHOTDIR="${SNAPSHOTDIR}-$(date +%H%M%S)" | |
mkdir -p ${SNAPSHOTDIR} | |
PKGS=$(find ${MIRRORDIR} -type f \( -name "*.rpm" -o -name "*.srpm" \) -print) | |
for PKG in ${PKGS} | |
do | |
ln -s ${PKG} ${SNAPSHOTDIR}/$(basename ${PKG}) | |
done | |
cp -r ${MIRRORDIR}/repodata ${SNAPSHOTDIR} | |
echo "Completed in ${SECONDS} seconds." | |
# EOF |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment