If you have to install a lot if machines with CentOS or you just play with kickstart script you should create a local repository to speed the process up. All you need as prerequisite is a configured web server and a script which copies the changes only from the public repository.
This script handles the CentOS and EPEL repository as well.
Here comes the script:
# cat > /usr/local/bin/repo-sync.sh #!/bin/bash rsync=/usr/bin/rsync rsyncopts='--progress -avHSP --bwlimit=512 --delete' rsyncexcl='--exclude=openoffice*.rpm --exclude=fonts-chinese*.rpm --exclude=fonts-japanese*.rpm --exclude=fonts-korean*.rpm --exclude=libreoffice*.rpm --exclude=firefox*.rpm --exclude=thunderbird*.rpm --exclude=ImageMagick*.rpm --exclude=/SRPMS/ --exclude=/headers/ --exclude=*.src.rpm --exclude=*.drpm --exclude=*-debuginfo-*.rpm --exclude=/debug/ --exclude=/repoview/' if [ -f /var/lock/subsys/repo-sync ]; then echo "Updates via rsync already running." exit 0 fi mirror=ftp.fsn.hu::linux/centos verlist="6 5" archlist="i386 x86_64" baselist="updates os" local=/var/www/html/mirror/centos/ for ver in $verlist; do for arch in $archlist; do for base in $baselist; do echo "===================================" echo "===== CentOS $ver/$base/$arch =====" echo "===================================" lrepo=$local/$ver/$base/$arch /bin/mkdir $lrepo 2> /dev/null /bin/touch /var/lock/subsys/rsync_sync remote=$mirror/$ver/$base/$arch/ $rsync $rsyncopts $rsyncexcl $remote $lrepo newpkgs=`/usr/bin/find $lrepo -ctime -1 | wc -l` if [ $newpkgs -gt 0 ]; then /usr/bin/createrepo $lrepo #>> /dev/null fi done done done mirror=ftp.linux.cz::pub/linux/fedora/epel verlist="6 5" archlist="i386 x86_64" baselist="." local=/var/www/html/mirror/epel/ for ver in $verlist; do for arch in $archlist; do for base in $baselist; do echo "===================================" echo "===== EPEL $ver/$base/$arch =====" echo "===================================" lrepo=$local/$ver/$base/$arch /bin/mkdir $lrepo 2> /dev/null /bin/touch /var/lock/subsys/rsync_sync remote=$mirror/$ver/$base/$arch/ $rsync $rsyncopts $rsyncexcl $remote $lrepo newpkgs=`/usr/bin/find $lrepo -ctime -1 | wc -l` if [ $newpkgs -gt 0 ]; then /usr/bin/createrepo $lrepo #>> /dev/null fi done done done Ctrl-DSome explanation:
- there are some exclusions at the beginning of the script because I do not need any graphical programs for servers
- you should replace mirror hosts and path with one which is closer to you
- be sure that you choose a mirror which supports rsync protocol. http and/or ftp is not necessary for this script. - you can select which version (verlist) and which architecture (archlist) to sync
No comments:
Post a Comment