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
16 us_fedora_url=rsync://mirrors.kernel.org/fedora
18 us_centos_url=rsync://mirrors.rit.edu/centos
20 # this one is contaminated with the .~tmp~ thing
21 #eu_fedora_url=rsync://ftp-stud.hs-esslingen.de/fedora/linux
22 eu_fedora_url=rsync://mirrors.ircam.fr/fedora-linux
23 eu_centos_url=rsync://mirrors.ircam.fr/CentOS
26 jp_fedora_url="need-to-be-defined"
28 jp_centos_url="need-to-be-defined"
31 all_distronames="f7 f8 f9 centos5.2"
33 all_archs="i386 x86_64"
37 fedora_url=$eu_fedora_url ; centos_url=$eu_centos_url ;;
39 fedora_url=$jp_fedora_url ; centos_url=$jp_centos_url ;;
41 fedora_url=$us_fedora_url ; centos_url=$us_centos_url ;;
44 function mirror_distro_arch () {
48 distroname=$(echo $distroname | tr '[A-Z]' '[a-z]')
51 distroindex=$(echo $distroname | sed -e "s,fc,,g")
56 distroindex=$(echo $distroname | sed -e "s,f,,g")
60 centos[4-5]|centos[4-5].[0-9])
61 distroindex=$(echo $distroname | sed -e "s,centos,,g")
66 echo "WARNING -- Unknown distribution $distroname -- skipped"
71 excludelist="debug/ iso/ ppc/ source/"
72 options="--archive --compress --delete --delete-excluded $dry_run $verbose"
73 [ -n "$(rsync --help | grep no-motd)" ] && options="$options --no-motd"
74 for e in $excludelist; do
75 options="$options --exclude $e"
78 echo ">>>>>>>>>>>>>>>>>>>> root=$root distroname=$distroname arch=$arch rsyncurl=$rsyncurl"
79 [ -n "$verbose" ] && echo "rsync options=$options"
87 [ -z "$skip_core" ] && paths="core/$distroindex/$arch/os/"
88 paths="$paths core/updates/$distroindex/$arch/ extras/$distroindex/$arch/"
92 [ -z "$skip_core" ] && paths="releases/$distroindex/Everything/$arch/os/"
93 paths="$paths updates/$distroindex/$arch/"
94 # f8 and f9 have the additional newkey repo
96 8|9) paths="$paths updates/$distroindex/${arch}.newkey/" ;;
107 [ -z "$skip_core" ] && paths="$distroindex/os/$arch/"
108 paths="$paths $distroindex/updates/$arch/"
117 if [ "$RES" = 1 ] ; then
118 echo "DISTRIBUTION $distro $distroindex CURRENTLY UNSUPPORTED - skipped"
120 for repopath in $paths; do
121 echo "===== $distro -> $distroindex $repopath"
122 [ -z "$dry_run" ] && mkdir -p ${root}/${localpath}/${repopath}
123 command="rsync $options ${rsyncurl}/${repopath} ${root}/${localpath}/${repopath}"
129 echo "<<<<<<<<<<<<<<<<<<<< $distroname $arch"
135 echo "Usage: $COMMAND [-n] [-v] [-c] [-r root] [-u|U rsyncurl] [-e|-j] [-f distroname|-F] [-a arch|-A]"
136 echo "Defaults to -r $root -f $default_distroname -a $default_arch"
137 echo "Default urls : $fedora_url $centos_url"
141 echo " -l : turns on autologging in $LOGDIR"
142 echo " -c : skips core repository"
143 echo " -r root (default is $root)"
144 echo " -u rsyncurl for fedora (default is $fedora_url)"
145 echo " -U rsyncurl for centos (default is $centos_url)"
146 echo " -s : uses standard (US) mirrors $us_fedora_url $us_centos_url"
147 echo " -e : uses European mirrors $eu_fedora_url $eu_centos_url"
148 echo " -j : uses Japanese mirrors $jp_fedora_url $jp_centos_url"
149 echo " -f distroname - use vserver convention, e.g. fc6 and f7"
150 echo " -F : for distroname in $all_distronames"
151 echo " -a arch - use yum convention"
152 echo " -A : for arch in $all_archs"
158 for distroname in $distronames ; do
159 for arch in $archs; do
160 mirror_distro_arch "$distroname" "$arch" || RES=1
169 while getopts "nvlcr:u:U:sejf:Fa:Ah" opt ; do
171 n) dry_run=--dry-run ;;
172 v) verbose=--verbose ;;
176 u) fedora_url=$OPTARG ;;
177 U) centos_url=$OPTARG ;;
178 s) fedora_url=$us_fedora_url ; centos_url=$us_centos_url ;;
179 e) fedora_url=$eu_fedora_url ; centos_url=$eu_centos_url ;;
180 j) fedora_url=$jp_fedora_url ; centos_url=$jp_centos_url ;;
181 f) distronames="$distronames $OPTARG" ;;
182 F) distronames="$distronames $all_distronames" ;;
183 a) archs="$archs $OPTARG" ;;
184 A) archs="$archs $all_archs" ;;
188 [ -z "$distronames" ] && distronames=$default_distroname
189 [ -z "$archs" ] && archs=$default_arch
191 # auto log : if specified
192 if [ -n "$log" ] ; then