As my first post of this holidays .. I give y'all the script i've been using to mirror and sync the fedora repos. The script is using reposync,repomanage (both provided by yum-utils) and createrepo , so you will need to yum for those them first.
#!/bin/bash -x
unset http_proxy
#export http_proxy=http://127.0.0.1:3128
# mirror root - the place you want the rpms to be downloaded
MROOT="/mnt/mirror/repos"
# processor architectures (space separated)
ARCHS="i686 x86_64"
# repository names (space separated)
REPOS="fedora updates"
if [ "$1" != "" ];then
REPOS="$@"
fi
downcomps(){
wget -N $1/repodata/comps.xml
}
# this part will download the comps.xml files .. it still need some improvements though
getcomps(){
case "$1" in
fedora)
downcomps http://download.fedora.redhat.com/pub/fedora/linux/releases/7/Everything/i386/os/
;;
updates)
downcomps http://download.fedora.redhat.com/pub/fedora/linux/updates/7/i386/
;;
*)
echo error
;;
esac
}
downrepo () {
cd $MROOT
if [ "$2" == "i686" ];then
cd i386
else
cd $2
fi
echo "Sychronizing Repositories"
reposync -r $1 -a $2 --newest-only -t /var/tmp/reposync-cache
STAT=$?
if [ "$STAT" == "0" ];then
cd $1
echo "Cleaning old packages"
repomanage --withbroken --old . |grep -v 'kernel\-' |grep -v -i 'nvidia'|grep -v -i 'fglrx'|xargs rm -rf
rm -rf .repodata .olddata
echo "Recreating repodata"
getcomps $1
# rm -f comps.xml
if [ -e comps.xml ];then
createrepo --groupfile comps.xml .
else
createrepo .
fi
fi
cd $MROOT
}
#yum clean all --noplugins
while [ "1" == "1" ];do
for REPO in $REPOS;do
# yum makecache --disablerepo=* --enablerepo=$REPO
for ARCH in $ARCHS;do
echo downloading $REPO $ARCH
downrepo $REPO $ARCH
done
done
echo Update done, halting for 2 hours
sleep 7200
done