Configuring Fedora for updates from local mirror.

Submitted by Zebar on Fri, 2007-01-26 06:01. ::

I have local mirror of Fedora Core, Fedora Extras, Fedora Updates. And I have a lot (not really lot, but more then 3) of computers with installed Fedora. I am interested in automatic updates, but I am not interested in downloading updates personally for computer or configuring real repos manually.

What have I done?

At first

I add in file /etc/hosts one line:

 192.168.1.1 mirrors.fedoraproject.org

And now computers go to my mirror.

Secondly

I configure apache on my mirror, and share folder with Fedora.

Thirdly

I wrote perl script, which accept parameters and generate repo-information and put it into /var/www/cgi-bin

 #!/usr/bin/perl
 use warnings;
 use strict;
 use CGI qw/:standard/;
 print header();
 my $arch="Empty";
 my $query=$ENV {"QUERY_STRING"};
 my @pairs = split ("&", $query) ;
 foreach my $pair (@pairs) {
  my ($name,$value) = split("=",$pair);
     if ( $name eq "arch") {
       $arch=$value;
     }
 }
 foreach my $pair (@pairs) {
  my ($name,$value) = split("=",$pair);
  if ( $name eq "repo") {
     if ( $value eq "core-6") {
       print "http://192.168.1.1/Fedora/fedora/core/6/$arch/os/";
     }
     if ( $value eq "extras-6") {
       print "http://192.168.1.1/Fedora/fedora/extras/6/$arch/";
     }
     if ( $value eq "updates-released-fc6") {
       print "http://192.168.1.1/Fedora/fedora/core/updates/6/$arch/";
     }
  }
 }

And Finally

I add rewrite rule to apache. And put it into /etc/httpd/conf.d/rewrite.conf

 <Directory "/var/www/html">
    RewriteEngine on
    RewriteRule   ^mirrorlist  /cgi-bin/mirrorlist
 </Directory>

Reload httpd - and test. Ok. Now all works!