2 ##############################################################################
3 # Copyright (c) 2015,2016 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 ##############################################################################
11 # Try to choose close ubuntu mirror
13 # Some Ubuntu mirrors seem less reliable for this type of mirroring -
14 # as they are discoved they can be added to the blacklist below in order
15 # for them not to be considered.
16 BLACKLIST="mirrors.se.eu.kernel.org mirror.its.dal.ca"
18 for url in $(curl -s http://mirrors.ubuntu.com/mirrors.txt)
20 host=$(echo $url | cut -d'/' -f3)
21 echo ${BLACKLIST} | grep -q ${host} && continue
22 if curl -s -o /dev/null --head --fail "$url"; then
30 # If no suitable local mirror can be found,
31 # the default archive is returned instead.
32 echo "http://archive.ubuntu.com/ubuntu/"