old blog,

Fedora repository mirroring script using reposync

Izhar Firdaus Izhar Firdaus Follow Support Jun 09, 2007 · 1 min read
Fedora repository mirroring script using reposync
Creative Commons License
This work is licensed under a Creative Commons Attribution 4.0 International License.
I'm back~ :D

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
Written by Izhar Firdaus Follow Support
I'm a system architect, data engineer and developer advocate with passion in Free / Open Source software, entrepreneurship, community building, education and martial art. I take enjoyment in bridging and bringing together different FOSS technologies to help businesses and organizations utilize IT infrastructure to aid and optimize their business and organizational process.

GPG Encrypt/Sign Texts in Firefox using FireGPG

Carthik Sharma pointed out a new Firefox extension called FireGPG in his blog post.Just what I'm looking for! :DSite URL: http://fire...

In old blog, Apr 05, 2007

« Previous Post

Running X applications headless using Xvfb

Sometimes, you might want to run certain X applications as a daemon in the background. For example, in my case, I want to make Ktorre...

In old blog, Jun 17, 2007

Next Post »