3 BLACKLIST="http://mirrors.se.eu.kernel.org/ubuntu/"
4 #BLACKLIST+=" http://foo.bar"
11 test -n "$DEBUG" && echo "$@" >&2
15 # Check if url is blacklisted in this script
17 for blackurl in $BLACKLIST
19 if [ "$1" == "$blackurl" ]; then
27 # Check mirror's integrity
31 for packdir in dists/trusty-updates/main/binary-amd64 \
32 dists/trusty-updates/restricted/binary-amd64 \
33 dists/trusty-updates/universe/binary-amd64 \
34 dists/trusty-updates/multiverse/binary-amd64 \
35 dists/trusty-security/main/binary-amd64 \
36 dists/trusty-security/restricted/binary-amd64 \
37 dists/trusty-security/universe/binary-amd64 \
38 dists/trusty-security/multiverse/binary-amd64 \
39 dists/trusty-proposed/main/binary-amd64 \
40 dists/trusty-proposed/restricted/binary-amd64 \
41 dists/trusty-proposed/universe/binary-amd64 \
42 dists/trusty-proposed/multiverse/binary-amd64 \
43 dists/trusty/main/binary-amd64 \
44 dists/trusty/restricted/binary-amd64 \
45 dists/trusty/universe/binary-amd64 \
46 dists/trusty/multiverse/binary-amd64 \
47 dists/trusty-backports/main/binary-amd64 \
48 dists/trusty-backports/restricted/binary-amd64 \
49 dists/trusty-backports/universe/binary-amd64 \
50 dists/trusty-backports/multiverse/binary-amd64
52 for packfile in Release Packages.gz
54 if [ $status -ne 1 ]; then
55 curl --output /dev/null --silent --head --fail \
56 $mirror/$packdir/$packfile
58 debugmsg "$mirror: Faulty (at least missing $packdir/$packfile)"
67 if [ "$1" == "-d" ]; then
71 # Hardcode for testing purposes
74 TMPFILE=$(mktemp /tmp/mirrorsXXXXX)A
77 # Generate a list of mirrors considered as "up"
78 curl -s https://launchpad.net/ubuntu/+archivemirrors | \
79 grep -P -B8 "statusUP|statusONE|statusSIX" | \
80 grep -o -P "(f|ht)tp.*\"" | \
81 sed 's/"$//' | sort | uniq > $TMPFILE
83 # Iterate over "close" mirror, check that they are considered up
85 for url in $(curl -s http://mirrors.ubuntu.com/mirrors.txt)
87 if ! grep -q $url $TMPFILE; then
88 debugmsg "$url Faulty (detected by Ubuntu)"
89 elif blacklisted $url; then
90 debugmsg "$url blacklisted"
91 elif [ -z $BESTURL ]; then
92 if grep -q $url $TMPFILE && check_mirror $url; then
93 debugmsg "$url: OK (setting as primary URL)"
95 test -z "$DEBUG" && break
98 grep -q $url $TMPFILE && check_mirror $url && debugmsg "$url: OK"