99trisquel 879 Bytes
Newer Older
Ruben Rodriguez committed
1 2 3 4 5
#!/bin/sh
set -e

file="$1"

6
FASTEST=http://ftp.rediris.es/mirror/Trisquel/packages/
Ruben Rodriguez committed
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
SPEED=1000000000000

for i in $(grep 'tp:' /usr/share/python-apt/templates/Trisquel.mirrors)
do
    echo Testing $i
    TIME=$(date +%s%N)
    wget -o /dev/null -O /dev/null $i/speedtest || continue
    TIME2=$(date +%s%N)
    ELAPSED=$(expr $TIME2 - $TIME)
    echo Time: $ELAPSED
    if [ $ELAPSED -lt $SPEED ]
    then
        FASTEST=$i
        SPEED=$ELAPSED
    fi
done

MIRROR=$FASTEST
RELEASE=$(lsb_release -c | cut -f 2)

cat << EOF > $file
# Trisquel repositories for supported software and updates
deb $MIRROR $RELEASE main
deb-src $MIRROR $RELEASE main
deb $MIRROR $RELEASE-security main
deb-src $MIRROR $RELEASE-security main
deb $MIRROR $RELEASE-updates main
deb-src $MIRROR $RELEASE-updates main
#deb $MIRROR $RELEASE-backports main
#deb-src $MIRROR $RELEASE-backports main
EOF