2 ##############################################################################
3 # Copyright (c) 2015 Ericsson AB and others.
4 # mskalski@mirantis.com
5 # All rights reserved. This program and the accompanying materials
6 # are made available under the terms of the Apache License, Version 2.0
7 # which accompanies this distribution, and is available at
8 # http://www.apache.org/licenses/LICENSE-2.0
9 ##############################################################################
10 RSYNC="rsync -4 --contimeout 5 --no-motd --list-only"
12 # try to choose close ubuntu mirror which support rsync protocol
13 # https://bugs.launchpad.net/fuel/+bug/1459252
15 # A minor modificiation of Michal Skalski's original Makefile version
16 # to only consider repos where no repo updates are in progress (as
17 # that may have us hanging quite a while otherwise). If no suitable
18 # local mirror can be found after four attempts, the default archive
19 # is returned instead.
21 # Some Ubuntu mirrors seem less reliable for this type of mirroring -
22 # as they are discoved they can be added to the blacklist below in order
23 # for them not to be considered.
24 BLACKLIST="mirrors.se.eu.kernel.org mirror.its.dal.ca"
28 while [ "$1" != "" ]; do
33 # Shift all the parameters down by one
41 for url in $(curl -s http://mirrors.ubuntu.com/mirrors.txt)
43 host=$(echo $url | cut -d'/' -f3)
44 echo ${BLACKLIST} | grep -q ${host} && continue
45 if $RSYNC "${host}::ubuntu/." &> /dev/null
47 if ! $RSYNC "${host}::ubuntu/Archive-Update-in-Progress*" &> /dev/null
49 if [ "$return_url" = "1" ]; then
63 if [ "$return_url" = "1" ]; then
64 echo "http://archive.ubuntu.com/ubuntu/"
66 echo "archive.ubuntu.com"