2 # this can help you create/update your fedora mirror
6 LOGDIR=/var/log/fedora-mirroring
7 DATE=$(date '+%Y-%m-%d-%H-%M')
8 LOG=${LOGDIR}/${DATE}.log
17 hozac_url=ftp://rpm.hozac.com/dhozac/centos/5/vserver
18 # Daniel mentions rsync://rpm.hozac.com/dhozac/centos/5/vserver/
20 us_fedora_url=rsync://mirrors.kernel.org/fedora
21 us_centos_url=rsync://mirrors.rit.edu/centos
22 us_epel_url=rsync://rsync.gtlib.gatech.edu/fedora-epel
24 # ircam's fedora8 repo has been turned off
25 #eu_fedora_url=rsync://mirrors.ircam.fr/fedora-linux
26 eu_fedora_url=rsync://mirror.ovh.net/download.fedora.redhat.com/linux
27 eu_centos_url=rsync://mirrors.ircam.fr/CentOS
28 eu_epel_url=rsync://mirrors.ircam.fr/fedora-epel
30 jp_fedora_url="jp_fedora_url-needs-to-be-defined"
31 jp_centos_url="jp_centos_url-needs-to-be-defined"
32 jp_epel_url="jp_epel_url-needs-to-be-defined"
34 default_distroname="centos5"
35 all_distronames="f8 f10 f11 centos5.2 centos5.3 epel5"
37 all_archs="i386 x86_64"
41 fedora_url=$eu_fedora_url ; centos_url=$eu_centos_url ; epel_url=$eu_epel_url ;;
43 fedora_url=$jp_fedora_url ; centos_url=$jp_centos_url ; epel_url=$jp_epel_url ;;
45 fedora_url=$us_fedora_url ; centos_url=$us_centos_url ; epel_url=$us_epel_url ;;
48 function mirror_distro_arch () {
54 distroname=$(echo $distroname | tr '[A-Z]' '[a-z]')
57 distroindex=$(echo $distroname | sed -e "s,fc,,g")
62 distroindex=$(echo $distroname | sed -e "s,f,,g")
66 centos[4-5]|centos[4-5].[0-9])
67 distroindex=$(echo $distroname | sed -e "s,centos,,g")
82 echo "WARNING -- Unknown distribution $distroname -- skipped"
87 excludelist="debug/ iso/ ppc/ source/"
88 options="--archive --compress --delete --delete-excluded $dry_run $verbose"
89 lftp_options="--delete $dry_run $verbose"
90 [ -n "$(rsync --help | grep no-motd)" ] && options="$options --no-motd"
91 for e in $excludelist; do
92 options="$options --exclude $e"
93 lftp_options="$lftp_options --exclude $e"
96 echo ">>>>>>>>>>>>>>>>>>>> root=$root distroname=$distroname arch=$arch rsyncurl=$rsyncurl"
97 [ -n "$verbose" ] && echo "rsync options=$options"
105 [ -z "$skip_core" ] && paths="core/$distroindex/$arch/os/"
106 paths="$paths core/updates/$distroindex/$arch/ extras/$distroindex/$arch/"
110 [ -z "$skip_core" ] && paths="releases/$distroindex/Everything/$arch/os/"
111 paths="$paths updates/$distroindex/$arch/"
112 # f8 and f9 have the additional newkey repo
114 8|9) paths="$paths updates/$distroindex/${arch}.newkey/" ;;
125 [ -z "$skip_core" ] && paths="$distroindex/os/$arch/"
126 paths="$paths $distroindex/updates/$arch/"
136 paths="$paths $distroindex/$arch/"
146 # leave off trailing '/'
157 if [ "$RES" = 1 ] ; then
158 echo "DISTRIBUTION $distro $distroindex CURRENTLY UNSUPPORTED - skipped"
160 for repopath in $paths; do
161 echo "===== $distro -> $distroindex $repopath"
162 [ -z "$dry_run" ] && mkdir -p ${root}/${localpath}/${repopath}
163 if [ "$LFTP" = 1 ]; then
164 command="lftp -c mirror $lftp_options ${rsyncurl}/${repopath} ${root}/${localpath}/${repopath}"
166 command="rsync $options ${rsyncurl}/${repopath} ${root}/${localpath}/${repopath}"
173 echo "<<<<<<<<<<<<<<<<<<<< $distroname $arch"
179 echo "Usage: $COMMAND [-n] [-v] [-c] [-r root] [-u|U rsyncurl] [-e|-j] [-f distroname|-F] [-a arch|-A]"
180 echo "Defaults to -r $root -f $default_distroname -a $default_arch"
181 echo "Default urls : $fedora_url $centos_url"
185 echo " -l : turns on autologging in $LOGDIR"
186 echo " -c : skips core repository"
187 echo " -r root (default is $root)"
188 echo " -u rsyncurl for fedora (default is $fedora_url)"
189 echo " -U rsyncurl for centos (default is $centos_url)"
190 echo " -E rsyncurl for epel (default is $epel_url)"
191 echo " -s : uses standard (US) mirrors $us_fedora_url $us_centos_url $us_epel_url"
192 echo " -e : uses European mirrors $eu_fedora_url $eu_centos_url $eu_epel_url"
193 echo " -j : uses Japanese mirrors $jp_fedora_url $jp_centos_url $jp_epel_url"
194 echo " -f distroname - use vserver convention, e.g. f8 or centos5"
195 echo " -F : for distroname in $all_distronames"
196 echo " -a arch - use yum convention"
197 echo " -A : for arch in $all_archs"
203 for distroname in $distronames ; do
204 for arch in $archs; do
205 mirror_distro_arch "$distroname" "$arch" || RES=1
214 while getopts "nvlcr:u:U:E:sejf:Fa:Ah" opt ; do
216 n) dry_run=--dry-run ;;
217 v) verbose=--verbose ;;
221 u) fedora_url=$OPTARG ;;
222 U) centos_url=$OPTARG ;;
223 E) epel_url=$OPTARG ;;
224 s) fedora_url=$us_fedora_url ; centos_url=$us_centos_url ; epel_url=$us_epel_url;;
225 e) fedora_url=$eu_fedora_url ; centos_url=$eu_centos_url ; epel_url=$eu_epel_url ;;
226 j) fedora_url=$jp_fedora_url ; centos_url=$jp_centos_url ; epel_url=$jp_epel_url ;;
227 f) distronames="$distronames $OPTARG" ;;
228 F) distronames="$distronames $all_distronames" ;;
229 a) archs="$archs $OPTARG" ;;
230 A) archs="$archs $all_archs" ;;
234 [ -z "$distronames" ] && distronames=$default_distroname
235 [ -z "$archs" ] && archs=$default_arch
237 # auto log : if specified
238 if [ -n "$log" ] ; then