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 us_fedora_url=rsync://mirrors.kernel.org/fedora
18 us_centos_url=rsync://mirrors.rit.edu/centos
19 us_epel_url=rsync://rsync.gtlib.gatech.edu/fedora-epel
21 # this one is contaminated with the .~tmp~ thing
23 eu_fedora_url=rsync://mirrors.ircam.fr/fedora-linux
24 eu_centos_url=rsync://mirrors.ircam.fr/CentOS
25 eu_epel_url=rsync://mirrors.ircam.fr/fedora-epel
27 jp_fedora_url="jp_fedora_url-needs-to-be-defined"
28 jp_centos_url="jp_centos_url-needs-to-be-defined"
29 jp_epel_url="jp_epel_url-needs-to-be-defined"
31 default_distroname="centos5"
32 all_distronames="f8 f10 centos5.2 epel5"
34 all_archs="i386 x86_64"
38 fedora_url=$eu_fedora_url ; centos_url=$eu_centos_url ; epel_url=$eu_epel_url ;;
40 fedora_url=$jp_fedora_url ; centos_url=$jp_centos_url ; epel_url=$jp_epel_url ;;
42 fedora_url=$us_fedora_url ; centos_url=$us_centos_url ; epel_url=$us_epel_url ;;
45 function mirror_distro_arch () {
49 distroname=$(echo $distroname | tr '[A-Z]' '[a-z]')
52 distroindex=$(echo $distroname | sed -e "s,fc,,g")
57 distroindex=$(echo $distroname | sed -e "s,f,,g")
61 centos[4-5]|centos[4-5].[0-9])
62 distroindex=$(echo $distroname | sed -e "s,centos,,g")
72 echo "WARNING -- Unknown distribution $distroname -- skipped"
77 excludelist="debug/ iso/ ppc/ source/"
78 options="--archive --compress --delete --delete-excluded $dry_run $verbose"
79 [ -n "$(rsync --help | grep no-motd)" ] && options="$options --no-motd"
80 for e in $excludelist; do
81 options="$options --exclude $e"
84 echo ">>>>>>>>>>>>>>>>>>>> root=$root distroname=$distroname arch=$arch rsyncurl=$rsyncurl"
85 [ -n "$verbose" ] && echo "rsync options=$options"
93 [ -z "$skip_core" ] && paths="core/$distroindex/$arch/os/"
94 paths="$paths core/updates/$distroindex/$arch/ extras/$distroindex/$arch/"
98 [ -z "$skip_core" ] && paths="releases/$distroindex/Everything/$arch/os/"
99 paths="$paths updates/$distroindex/$arch/"
100 # f8 and f9 have the additional newkey repo
102 8|9) paths="$paths updates/$distroindex/${arch}.newkey/" ;;
113 [ -z "$skip_core" ] && paths="$distroindex/os/$arch/"
114 paths="$paths $distroindex/updates/$arch/"
124 paths="$paths $distroindex/$arch/"
133 if [ "$RES" = 1 ] ; then
134 echo "DISTRIBUTION $distro $distroindex CURRENTLY UNSUPPORTED - skipped"
136 for repopath in $paths; do
137 echo "===== $distro -> $distroindex $repopath"
138 [ -z "$dry_run" ] && mkdir -p ${root}/${localpath}/${repopath}
139 command="rsync $options ${rsyncurl}/${repopath} ${root}/${localpath}/${repopath}"
145 echo "<<<<<<<<<<<<<<<<<<<< $distroname $arch"
151 echo "Usage: $COMMAND [-n] [-v] [-c] [-r root] [-u|U rsyncurl] [-e|-j] [-f distroname|-F] [-a arch|-A]"
152 echo "Defaults to -r $root -f $default_distroname -a $default_arch"
153 echo "Default urls : $fedora_url $centos_url"
157 echo " -l : turns on autologging in $LOGDIR"
158 echo " -c : skips core repository"
159 echo " -r root (default is $root)"
160 echo " -u rsyncurl for fedora (default is $fedora_url)"
161 echo " -U rsyncurl for centos (default is $centos_url)"
162 echo " -E rsyncurl for epel (default is $epel_url)"
163 echo " -s : uses standard (US) mirrors $us_fedora_url $us_centos_url $us_epel_url"
164 echo " -e : uses European mirrors $eu_fedora_url $eu_centos_url $eu_epel_url"
165 echo " -j : uses Japanese mirrors $jp_fedora_url $jp_centos_url $jp_epel_url"
166 echo " -f distroname - use vserver convention, e.g. f8 or centos5"
167 echo " -F : for distroname in $all_distronames"
168 echo " -a arch - use yum convention"
169 echo " -A : for arch in $all_archs"
175 for distroname in $distronames ; do
176 for arch in $archs; do
177 mirror_distro_arch "$distroname" "$arch" || RES=1
186 while getopts "nvlcr:u:U:E:sejf:Fa:Ah" opt ; do
188 n) dry_run=--dry-run ;;
189 v) verbose=--verbose ;;
193 u) fedora_url=$OPTARG ;;
194 U) centos_url=$OPTARG ;;
195 E) epel_url=$OPTARG ;;
196 s) fedora_url=$us_fedora_url ; centos_url=$us_centos_url ; epel_url=$us_epel_url;;
197 e) fedora_url=$eu_fedora_url ; centos_url=$eu_centos_url ; epel_url=$eu_epel_url ;;
198 j) fedora_url=$jp_fedora_url ; centos_url=$jp_centos_url ; epel_url=$jp_epel_url ;;
199 f) distronames="$distronames $OPTARG" ;;
200 F) distronames="$distronames $all_distronames" ;;
201 a) archs="$archs $OPTARG" ;;
202 A) archs="$archs $all_archs" ;;
206 [ -z "$distronames" ] && distronames=$default_distroname
207 [ -z "$archs" ] && archs=$default_arch
209 # auto log : if specified
210 if [ -n "$log" ] ; then