2 # this can help you create/update your fedora mirror
5 LOGDIR=/var/log/fedora-mirroring
6 DATE=$(date '+%Y-%m-%d-%H-%M')
7 LOG=${LOGDIR}/${DATE}.log
16 dhozac_url=rsync://rpm.hozac.com/dhozac/centos/
18 us_fedora_url=rsync://mirrors.kernel.org/fedora
19 us_centos_url=rsync://mirrors.rit.edu/centos
20 us_epel_url=rsync://rsync.gtlib.gatech.edu/fedora-epel
22 # ircam's fedora8 repo has been turned off
23 #eu_fedora_url=rsync://mirrors.ircam.fr/fedora-linux
24 #eu_fedora_url=rsync://mirror.ovh.net/download.fedora.redhat.com/linux
25 eu_fedora_url=rsync://ftp-stud.hs-esslingen.de/fedora/linux
26 eu_centos_url=rsync://mirrors.ircam.fr/CentOS
27 eu_epel_url=rsync://mirrors.ircam.fr/fedora-epel
29 pl_fedora_url=$eu_fedora_url
30 pl_centos_url=rsync://ftp.tpnet.pl/centos
31 pl_epel_url=rsync://ftp.icm.edu.pl/pub/Linux/fedora/linux/epel
33 jp_fedora_url="jp_fedora_url-needs-to-be-defined"
34 jp_centos_url="jp_centos_url-needs-to-be-defined"
35 jp_epel_url="jp_epel_url-needs-to-be-defined"
37 default_distroname="centos5.6"
38 all_distronames="f14 f15 centos5.6 epel5 epel6"
40 all_archs="i386 x86_64"
43 blitz*|*.fr|*.de|*.uk)
44 fedora_url=$eu_fedora_url ; centos_url=$eu_centos_url ; epel_url=$eu_epel_url ;;
46 fedora_url=$pl_fedora_url ; centos_url=$pl_centos_url ; epel_url=$pl_epel_url ;;
48 fedora_url=$jp_fedora_url ; centos_url=$jp_centos_url ; epel_url=$jp_epel_url ;;
50 fedora_url=$us_fedora_url ; centos_url=$us_centos_url ; epel_url=$us_epel_url ;;
53 function mirror_distro_arch () {
57 distroname=$(echo $distroname | tr '[A-Z]' '[a-z]')
60 distroindex=$(echo $distroname | sed -e "s,fc,,g")
65 distroindex=$(echo $distroname | sed -e "s,f,,g")
69 centos[4-5]|centos[4-5].[0-9])
70 distroindex=$(echo $distroname | sed -e "s,centos,,g")
75 distroindex=$(echo $distroname | sed -e "s,epel,,g")
85 echo "WARNING -- Unknown distribution $distroname -- skipped"
90 excludelist="debug/ iso/ ppc/ source/"
91 options="--archive --compress --delete --delete-excluded $dry_run $verbose"
92 [ -n "$(rsync --help | grep no-motd)" ] && options="$options --no-motd"
93 for e in $excludelist; do
94 options="$options --exclude $e"
97 echo ">>>>>>>>>>>>>>>>>>>> root=$root distroname=$distroname arch=$arch rsyncurl=$rsyncurl"
98 [ -n "$verbose" ] && echo "rsync options=$options"
106 [ -z "$skip_core" ] && paths="core/$distroindex/$arch/os/"
107 paths="$paths core/updates/$distroindex/$arch/ extras/$distroindex/$arch/"
111 [ -z "$skip_core" ] && paths="releases/$distroindex/Everything/$arch/os/"
112 paths="$paths updates/$distroindex/$arch/"
113 # f8 and f9 have the additional newkey repo
115 8|9) paths="$paths updates/$distroindex/${arch}.newkey/" ;;
126 [ -z "$skip_core" ] && paths="$distroindex/os/$arch/"
127 paths="$paths $distroindex/updates/$arch/"
137 paths="$paths $distroindex/$arch/"
147 # leave off trailing '/'
148 paths="$paths $distroindex/vserver/$arch"
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 command="rsync $options ${rsyncurl}/${repopath} ${root}/${localpath}/${repopath}"
169 echo "<<<<<<<<<<<<<<<<<<<< $distroname $arch"
175 echo "Usage: $COMMAND [-n] [-v] [-c] [-r root] [-u|U rsyncurl] [-e|-j] [-f distroname|-F] [-a arch|-A]"
176 echo "Defaults to -r $root -f $default_distroname -a $default_arch"
177 echo "Default urls : $fedora_url $centos_url"
181 echo " -l : turns on autologging in $LOGDIR"
182 echo " -c : skips core repository"
183 echo " -C : force syncing core repository (default)"
184 echo " -r root (default is $root)"
185 echo " -u rsyncurl for fedora (default is $fedora_url)"
186 echo " -U rsyncurl for centos (default is $centos_url)"
187 echo " -E rsyncurl for epel (default is $epel_url)"
188 echo " -s : uses standard (US) mirrors $us_fedora_url $us_centos_url $us_epel_url"
189 echo " -e : uses European mirrors $eu_fedora_url $eu_centos_url $eu_epel_url"
190 echo " -j : uses Japanese mirrors $jp_fedora_url $jp_centos_url $jp_epel_url"
191 echo " -f distroname - use vserver convention, e.g. f8 or centos5"
192 echo " -F : for distroname in $all_distronames"
193 echo " -a arch - use yum convention"
194 echo " -A : for arch in $all_archs"
200 for distroname in $distronames ; do
201 for arch in $archs; do
202 mirror_distro_arch "$distroname" "$arch" || RES=1
211 while getopts "nvlcCr:u:U:E:sejf:Fa:Ah" opt ; do
213 n) dry_run=--dry-run ;;
214 v) verbose=--verbose ;;
219 u) fedora_url=$OPTARG ;;
220 U) centos_url=$OPTARG ;;
221 E) epel_url=$OPTARG ;;
222 s) fedora_url=$us_fedora_url ; centos_url=$us_centos_url ; epel_url=$us_epel_url;;
223 e) fedora_url=$eu_fedora_url ; centos_url=$eu_centos_url ; epel_url=$eu_epel_url ;;
224 j) fedora_url=$jp_fedora_url ; centos_url=$jp_centos_url ; epel_url=$jp_epel_url ;;
225 f) distronames="$distronames $OPTARG" ;;
226 F) distronames="$distronames $all_distronames" ;;
227 a) archs="$archs $OPTARG" ;;
228 A) archs="$archs $all_archs" ;;
233 [[ -n "$@" ]] && usage
234 [ -z "$distronames" ] && distronames=$default_distroname
235 [ -z "$archs" ] && archs=$default_arch
237 # auto log : if specified
238 if [ -n "$log" ] ; then