[转帖][分享]用脚本寻找ubuntu最快的源

为当前最终发行版之前的所有版本提供支持
回复
newx
帖子: 146
注册时间: 2006-02-28 19:05
送出感谢: 0
接收感谢: 0

[转帖][分享]用脚本寻找ubuntu最快的源

#1

帖子 newx » 2006-04-07 23:07

用脚本寻找ubuntu最快的源

在网络上寻找速度最快的源。








1. 建立一个新的脚本

sudo gedit /usr/bin/setfastsources

2. 输入下面的内容:

#!/bin/bash
if [ $# != 1 ] | \
[ "$1" != "hoary" -a "$1" != "breezy" ]; then
echo "Use: sudo $0 (hoary|breezy)";
echo "Example: sudo $0 hoary";
exit 1;
fi

if [ !$USER = "root" ]; then
echo "$0 must run by sudo";
exit 1;
fi

echo "Seting $1...";
MIRRORS="http://mirror.isp.net.au/ftp/pub/ubuntu/ \
ftp://linux.xjtu.edu.cn/mirror/ubuntu/ubuntu/ \
http://mirror.lupaworld.com/ubuntu/archive/ \
http://ubuntu.cn99.com/ubuntu/ \
ftp://mirror.isp.net.au/pub/ubuntu/ \
ftp://ftp.filearena.net/pub/ubuntu/ \
http://mirror.optus.net/ubuntu/ \
http://ubuntu.inode.at/ubuntu/ \
ftp://ubuntu.inode.at/ubuntu/ \
http://ubuntu.uni-klu.ac.at/ubuntu/ \
ftp://ftp.uni-klu.ac.at/linux/ubuntu/ \
ftp://gd.tuwien.ac.at/opsys/linux/ubuntu/archive/ \
http://gd.tuwien.ac.at/opsys/linux/ubuntu/archive/ \
http://ftp.belnet.be/pub/mirror/ubuntu.com/ \
ftp://ftp.belnet.be/pub/mirror/ubuntu.com/ \
http://ubuntu.mirrors.skynet.be/pub/ubuntu.com/ \
ftp://ubuntu.mirrors.skynet.be/pub/ubuntu.com/ \
http://mirror.freax.be/ubuntu/archive.ubuntu.com/ \
http://ftp.interlegis.gov.br/pub/ubuntu/archive/ \
http://ubuntu.c3sl.ufpr.br/ubuntu/ \
ftp://ftp.cs.mun.ca/pub/mirror/ubuntu/ \
http://archive.ubuntu.org.cn/ubuntu/ \
http://archive.ubuntu.cz/ubuntu/ \
ftp://archive.ubuntu.cz/ubuntu/ \
http://mirrors.dk.telia.net/ubuntu/ \
ftp://mirrors.dk.telia.net/ubuntu/ \
http://mirrors.dotsrc.org/ubuntu/ \
ftp://mirrors.dotsrc.org/ubuntu/ \
http://klid.dk/homeftp/ubuntu/ \
ftp://klid.dk/ubuntu/ \
http://ubuntu.mirror.mmd.net/ubuntu/ \
ftp://ubuntu.mirror.mmd.net/ubuntu/ \
http://mir1.ovh.net/ubuntu/ubuntu/ \
ftp://mir1.ovh.net/ubuntu/ubuntu/ \
ftp://debian.charite.de/ubuntu/ \
http://debian.charite.de/ubuntu/ \
http://ftp.inf.tu-dresden.de/os/linux/dists/ubuntu/ \
http://www.artfiles.org/ubuntu.com/ \
http://ftp.rz.tu-bs.de/pub/mirror/ubuntu-packages/ \
ftp://ftp.rz.tu-bs.de/pub/mirror/ubuntu-packages/ \
ftp://ftp.join.uni-muenster.de/pub/mirr ... om/ubuntu/ \
http://ftp.join.uni-muenster.de/pub/mir ... om/ubuntu/ \
http://ftp.kfki.hu/linux/ubuntu/ \
ftp://ftp.kfki.hu/pub/linux/ubuntu/ \
ftp://ftp.fsn.hu/pub/linux/distributions/ubuntu/ \
http://komo.vlsm.org/ubuntu/ \
http://kambing.vlsm.org/ubuntu/ \
http://ubuntu.odg.cc/ \
http://ftp.esat.net/mirrors/archive.ubuntu.com/ \
ftp://ftp.esat.net/mirrors/archive.ubuntu.com/ \
http://ftp.heanet.ie/pub/ubuntu/ \
ftp://ftp.heanet.ie/pub/ubuntu/ \
http://ftp.linux.it/ubuntu/ \
ftp://ftp.linux.it/ubuntu/ \
http://na.mirror.garr.it/mirrors/ubuntu-archive/ \
ftp://na.mirror.garr.it/mirrors/ubuntu-archive/ \
http://ubuntu.mithril-linux.org/archives/ \
http://ftp.litnet.lt/pub/ubuntu/ \
ftp://ftp.litnet.lt/pub/ubuntu/ \
ftp://ftp.polytechnic.edu.na/pub/ubuntulinux/ \
ftp://ftp.bit.nl/ubuntu/ \
http://ftp.bit.nl/ubuntu/ \
http://ubuntu.synssans.nl/ \
ftp://ftp.uninett.no/linux/ubuntu/ \
http://ubuntulinux.mainseek.com/ubuntu/ \
ftp://ftp.rnl.ist.utl.pt/ubuntu/ \
http://darkstar.ist.utl.pt/ubuntu/archive/ \
http://ftp.lug.ro/ubuntu/ \
ftp://ftp.lug.ro/ubuntu/ \
http://ftp.roedu.net/mirrors/ubuntu/ \
http://ftp.iasi.roedu.net/mirrors/ubuntu/ \
ftp://ftp.um.es/mirror/ubuntu/ \
ftp://ftp.ubuntu-es.org/ubuntu/ \
http://ftp.acc.umu.se/mirror/ubuntu/ \
ftp://ftp.se.linux.org/pub/Linux/distributions/ubuntu/ \
http://mirror.switch.ch/ftp/mirror/ubuntu/ \
ftp://mirror.switch.ch/mirror/ubuntu/ \
http://apt.nc.hcc.edu.tw/pub/ubuntu/ \
ftp://apt.nc.hcc.edu.tw/pub/ubuntu/ \
ftp://os.nchc.org.tw/ubuntu/ \
ftp://ftp.ee.ncku.edu.tw/pub/ubuntu/ \
http://ubuntu.csie.ntu.edu.tw/ubuntu/ \
http://www.mirrorservice.org/sites/arch ... om/ubuntu/ \
ftp://ftp.mirrorservice.org/sites/archi ... om/ubuntu/ \
http://ftp.cs.umn.edu/pub/ubuntu/ \
http://mirror.clarkson.edu/pub/distributions/ubuntu/ \
ftp://mirror.clarkson.edu/pub/distributions/ubuntu/ \
http://ubuntu.mirrors.tds.net/ubuntu/ \
ftp://ubuntu.mirrors.tds.net/ubuntu/ \
http://itanix.rutgers.edu/ubuntu/ \
http://www.opensourcemirrors.org/ubuntu/ \
http://ftp.ale.org/pub/mirrors/ubuntu/ \
http://ubuntu.secs.oakland.edu/ \
http://mirror.mcs.anl.gov/pub/ubuntu/ \
ftp://mirror.mcs.anl.gov/pub/ubuntu/ \
http://debian.okey.net/ubuntu/ \
ftp://ftp.sjtu.edu.cn/sites/archive.ubuntu.com/"

TIME="/usr/bin/time -o timer.txt -f %e";
URL="dists/$1/main/binary-i386/Packages.gz";
WGET="wget --cache=off -T 20 -t 1 -w 0 -O /dev/null"
PAYTIME=1000;
TEMPTIME=1000;
SITE="http://cn.archive.ubuntu.com/ubuntu/";
for mirror in $MIRRORS ; do
echo "Testing $mirror..."
TEMPTIME=`$TIME $WGET $mirror$URL`;
if [ "$?" = 0 ] ; then
TEMPTIME=`cat timer.txt`;
echo "wget $1 : $TEMPTIME CurrMinTime : $PAYTIME";
TEMPTIME2=`echo "$PAYTIME > $TEMPTIME"|bc`;
if [ $TEMPTIME2 = 1 ] ; then
PAYTIME="$TEMPTIME";
SITE="$mirror";
echo -e "\033[37;41;1mSet best site ($PAYTIME): $SITE\033[0m"
fi
fi
rm timer.txt;
done
echo "Best site ($PAYTIME): $SITE";
echo "Backup your sources.list."
declare -i num;
num=0;
while [ -e /etc/apt/sources.list.$num ];do
num=$num+1;
done
mv /etc/apt/sources.list /etc/apt/sources.list.$num
COMP="main restricted universe multiverse";
MAINSITE="http://archive.ubuntu.org.cn"
echo "deb $SITE $1 $COMP" > /etc/apt/sources.list

echo "deb $SITE $1-security $COMP" >> /etc/apt/sources.list
echo "deb $SITE $1-updates $COMP" >> /etc/apt/sources.list
if [ $1 = "hoary" ]; then
echo "deb $MAINSITE/ubuntu-cn ubuntu.org.cn $COMP" >> /etc/apt/sources.list
echo "deb $MAINSITE/ubuntu hoary-backports $COMP" >> /etc/apt/sources.list
echo "deb $MAINSITE/backports hoary-extras $COMP" >> /etc/apt/sources.list
fi
echo "Finlish setting sources.list,Run apt-get update now!";
exit 0

3. 保存并脚本
4. 设置脚本文件为可执行。

sudo chmod +x /usr/bin/setfastsources

5. 执行脚本
hoary:

sudo setfastsources hoary

breezy:

sudo setfastsources breezy







创建于:2006-03-23 10:01:29,修改于: 2006-03-23 10:01:29,已浏览29次,有评论0条

http://www.cublog.cn/opera/showart.php? ... 1&id=89554 :)
newx
帖子: 146
注册时间: 2006-02-28 19:05
送出感谢: 0
接收感谢: 0

#2

帖子 newx » 2006-04-07 23:10

windtrue
帖子: 68
注册时间: 2006-01-08 19:24
来自: 广州
送出感谢: 0
接收感谢: 0
联系:

#3

帖子 windtrue » 2006-04-08 13:32

不错的贴
收藏先
呵呵
xautofzx
帖子: 315
注册时间: 2005-05-11 20:14
来自: 西安理工大学
送出感谢: 0
接收感谢: 0

#4

帖子 xautofzx » 2006-09-21 16:09

这个脚本原来就是www.ubuntu.org.cn上的,但是却一直没有添加到wiki.ubuntu.com.cn中。
回复

回到 “老旧版本支持”