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.
23 while [ "$1" != "" ]; do
28 # Shift all the parameters down by one
37 for url in $(curl -s http://mirrors.ubuntu.com/mirrors.txt)
39 host=$(echo $url | cut -d'/' -f3)
40 if $RSYNC "${host}::ubuntu/." &> /dev/null
42 if ! $RSYNC "${host}::ubuntu/Archive-Update-in-Progress*" &> /dev/null
44 if [ "$return_url" = "1" ]; then
58 if [ "$return_url" = "1" ]; then
59 echo "http://archive.ubuntu.com/ubuntu/"
61 echo "archive.ubuntu.com"