-
-
Save juanxhos/e1e5dfe64af8025c0bfd8a89d7f07362 to your computer and use it in GitHub Desktop.
reposync script
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 | |
# based on: http://blog.kagesenshi.org/2007/06/fedora-repository-mirroring-script.html | |
# mirror root - the place you want the rpms to be downloaded | |
MROOT="/opt/delivery/files/centos" | |
# processor architectures (space separated) | |
ARCHS="x86_64" | |
# repository names (space separated) | |
REPOS="base centosplus cr epel extras pgdg94 updates" | |
downrepo () { | |
cd $MROOT | |
echo "Sychronizing Repositories" >> /var/log/reposync.log | |
echo date >> /var/log/reposync.log | |
reposync --download-metadata --gpgcheck --plugins --repoid=$1 --arch=$2 --newest-only -t /var/tmp/reposync-cache --download_path=$1 >> /var/log/reposync.log | |
STAT=$? | |
if [ "$STAT" == "0" ];then | |
cd $1 | |
echo "Cleaning old packages" | |
# dont delete old kernels | |
repomanage --old . | grep -v 'kernel\-' | xargs rm -rf | |
echo "Recreating repodata" | |
if [ -f comps.xml ]; then | |
echo "comps.xml found" | |
createrepo --workers 2 -g comps.xml . | |
else | |
echo "comps.xml not found, creating without groups" | |
createrepo . | |
fi | |
if [ -f *-updateinfo.xml.gz ]; then | |
zcat *-updateinfo.xml.gz > updateinfo.xml | |
modifyrepo updateinfo.xml ./repodata/ | |
rm *-updateinfo.xml.gz | |
fi | |
fi | |
cd $MROOT | |
} | |
for REPO in $REPOS;do | |
downrepo $REPO $ARCH | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment