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=http://rpm.hozac.com/dhozac/centos/5/vserver
19 us_fedora_url=rsync://mirrors.kernel.org/fedora
20 us_centos_url=rsync://mirrors.rit.edu/centos
21 us_epel_url=rsync://rsync.gtlib.gatech.edu/fedora-epel
23 # this one is contaminated with the .~tmp~ thing
25 eu_fedora_url=rsync://mirrors.ircam.fr/fedora-linux
26 eu_centos_url=rsync://mirrors.ircam.fr/CentOS
27 eu_epel_url=rsync://mirrors.ircam.fr/fedora-epel
29 jp_fedora_url="jp_fedora_url-needs-to-be-defined"
30 jp_centos_url="jp_centos_url-needs-to-be-defined"
31 jp_epel_url="jp_epel_url-needs-to-be-defined"
33 default_distroname="centos5"
34 all_distronames="f8 f10 centos5.2 epel5"
36 all_archs="i386 x86_64"
40 fedora_url=$eu_fedora_url ; centos_url=$eu_centos_url ; epel_url=$eu_epel_url ;;
42 fedora_url=$jp_fedora_url ; centos_url=$jp_centos_url ; epel_url=$jp_epel_url ;;
44 fedora_url=$us_fedora_url ; centos_url=$us_centos_url ; epel_url=$us_epel_url ;;
47 function mirror_distro_arch () {
53 distroname=$(echo $distroname | tr '[A-Z]' '[a-z]')
56 distroindex=$(echo $distroname | sed -e "s,fc,,g")
61 distroindex=$(echo $distroname | sed -e "s,f,,g")
65 centos[4-5]|centos[4-5].[0-9])
66 distroindex=$(echo $distroname | sed -e "s,centos,,g")
81 echo "WARNING -- Unknown distribution $distroname -- skipped"
86 excludelist="debug/ iso/ ppc/ source/"
87 options="--archive --compress --delete --delete-excluded $dry_run $verbose"
88 lftp_options="--delete $dry_run $verbose"
89 [ -n "$(rsync --help | grep no-motd)" ] && options="$options --no-motd"
90 for e in $excludelist; do
91 options="$options --exclude $e"
92 lftp_options="$lftp_options --exclude $e"
95 echo ">>>>>>>>>>>>>>>>>>>> root=$root distroname=$distroname arch=$arch rsyncurl=$rsyncurl"
96 [ -n "$verbose" ] && echo "rsync options=$options"
104 [ -z "$skip_core" ] && paths="core/$distroindex/$arch/os/"
105 paths="$paths core/updates/$distroindex/$arch/ extras/$distroindex/$arch/"
109 [ -z "$skip_core" ] && paths="releases/$distroindex/Everything/$arch/os/"
110 paths="$paths updates/$distroindex/$arch/"
111 # f8 and f9 have the additional newkey repo
113 8|9) paths="$paths updates/$distroindex/${arch}.newkey/" ;;
124 [ -z "$skip_core" ] && paths="$distroindex/os/$arch/"
125 paths="$paths $distroindex/updates/$arch/"
135 paths="$paths $distroindex/$arch/"
145 # leave off trailing '/'
156 if [ "$RES" = 1 ] ; then
157 echo "DISTRIBUTION $distro $distroindex CURRENTLY UNSUPPORTED - skipped"
159 for repopath in $paths; do
160 echo "===== $distro -> $distroindex $repopath"
161 [ -z "$dry_run" ] && mkdir -p ${root}/${localpath}/${repopath}
162 if [ "$LFTP" = 1 ]; then
163 command="lftp -c mirror $lftp_options ${rsyncurl}/${repopath} ${root}/${localpath}/${repopath}"
165 command="rsync $options ${rsyncurl}/${repopath} ${root}/${localpath}/${repopath}"
172 echo "<<<<<<<<<<<<<<<<<<<< $distroname $arch"
178 echo "Usage: $COMMAND [-n] [-v] [-c] [-r root] [-u|U rsyncurl] [-e|-j] [-f distroname|-F] [-a arch|-A]"
179 echo "Defaults to -r $root -f $default_distroname -a $default_arch"
180 echo "Default urls : $fedora_url $centos_url"
184 echo " -l : turns on autologging in $LOGDIR"
185 echo " -c : skips core repository"
186 echo " -r root (default is $root)"
187 echo " -u rsyncurl for fedora (default is $fedora_url)"
188 echo " -U rsyncurl for centos (default is $centos_url)"
189 echo " -E rsyncurl for epel (default is $epel_url)"
190 echo " -s : uses standard (US) mirrors $us_fedora_url $us_centos_url $us_epel_url"
191 echo " -e : uses European mirrors $eu_fedora_url $eu_centos_url $eu_epel_url"
192 echo " -j : uses Japanese mirrors $jp_fedora_url $jp_centos_url $jp_epel_url"
193 echo " -f distroname - use vserver convention, e.g. f8 or centos5"
194 echo " -F : for distroname in $all_distronames"
195 echo " -a arch - use yum convention"
196 echo " -A : for arch in $all_archs"
202 for distroname in $distronames ; do
203 for arch in $archs; do
204 mirror_distro_arch "$distroname" "$arch" || RES=1
213 while getopts "nvlcr:u:U:E:sejf:Fa:Ah" opt ; do
215 n) dry_run=--dry-run ;;
216 v) verbose=--verbose ;;
220 u) fedora_url=$OPTARG ;;
221 U) centos_url=$OPTARG ;;
222 E) epel_url=$OPTARG ;;
223 s) fedora_url=$us_fedora_url ; centos_url=$us_centos_url ; epel_url=$us_epel_url;;
224 e) fedora_url=$eu_fedora_url ; centos_url=$eu_centos_url ; epel_url=$eu_epel_url ;;
225 j) fedora_url=$jp_fedora_url ; centos_url=$jp_centos_url ; epel_url=$jp_epel_url ;;
226 f) distronames="$distronames $OPTARG" ;;
227 F) distronames="$distronames $all_distronames" ;;
228 a) archs="$archs $OPTARG" ;;
229 A) archs="$archs $all_archs" ;;
233 [ -z "$distronames" ] && distronames=$default_distroname
234 [ -z "$archs" ] && archs=$default_arch
236 # auto log : if specified
237 if [ -n "$log" ] ; then