├── LICENSE ├── README.md ├── tunasync ├── conf │ ├── manager.conf │ ├── worker-centos.conf │ ├── worker-epel.conf │ ├── worker-pypi.conf │ └── worker-ubuntu.conf └── scripts │ └── updateTunasync.sh └── web ├── .help ├── CentOS6-Base.repo ├── CentOS7-Base.repo ├── UpgradePython.pdf ├── centos.html ├── epel.html ├── pypi.html └── ubuntu.html ├── .resource ├── css │ └── mirror.css ├── img │ ├── pip.png │ └── setuptools.png └── js │ ├── helptool.js │ ├── jquery-1.11.3.min.js │ ├── main.js │ └── mirror.js └── index.html /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 Yong Wei 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # 开源镜像站 2 | 3 | ## 说明 4 | 5 | 本项目是镜像服务器的前端与后台维护脚本源码。 6 | 7 | 前端页面会定时(本项目默认为1分钟,注:定时刷新功能不支持 IE8 及以下浏览器)从后台获取各同步源数据状态,并刷新至浏览器。 8 | 9 | ### 默认配置 10 | 11 | - 源列表:CentOS,EPEL,Ubuntu,Pypi 12 | - 镜像路径:/mirrors/ 13 | - 程序路径:/home/mirrors/tunasync/ 14 | - 日志路径:/mirrors/log/ 15 | 16 | ### 其他 17 | 18 | 更多信息可参阅博客 [使用 tunasync 搭建开源镜像站](http://weyo.me/pages/techs/how-to-make-a-mirror-site)。 19 | 20 | ## 致谢 21 | 22 | 本项目前端页面样式参考自[网易开源镜像站](http://mirrors.163.com/),镜像使用帮助内容参考自[网易开源镜像站](http://mirrors.163.com/)、[清华大学开源软件镜像站](https://mirrors.tuna.tsinghua.edu.cn/)、[USTC open source software mirror](https://mirrors.ustc.edu.cn/),在此一并表示感谢! -------------------------------------------------------------------------------- /tunasync/conf/manager.conf: -------------------------------------------------------------------------------- 1 | debug = false 2 | 3 | [server] 4 | addr = "127.0.0.1" 5 | port = 14242 6 | ssl_cert = "" 7 | ssl_key = "" 8 | 9 | [files] 10 | db_type = "bolt" 11 | db_file = "/home/mirrors/tunasync/db/manager.db" 12 | ca_cert = "" 13 | -------------------------------------------------------------------------------- /tunasync/conf/worker-centos.conf: -------------------------------------------------------------------------------- 1 | [global] 2 | name = "centos_worker" 3 | log_dir = "/mirrors/log/tunasync/{{.Name}}" 4 | mirror_dir = "/mirrors" 5 | concurrent = 10 6 | interval = 1440 7 | 8 | [manager] 9 | api_base = "http://localhost:14242" 10 | token = "some_token" 11 | ca_cert = "" 12 | 13 | [cgroup] 14 | enable = false 15 | base_path = "/sys/fs/cgroup" 16 | group = "tunasync" 17 | 18 | [server] 19 | hostname = "localhost" 20 | listen_addr = "127.0.0.1" 21 | listen_port = 16010 22 | ssl_cert = "" 23 | ssl_key = "" 24 | 25 | [[mirrors]] 26 | name = "centos" 27 | provider = "rsync" 28 | upstream = "rsync://mirrors.tuna.tsinghua.edu.cn/centos/" 29 | use_ipv6 = false 30 | 31 | -------------------------------------------------------------------------------- /tunasync/conf/worker-epel.conf: -------------------------------------------------------------------------------- 1 | [global] 2 | name = "epel_worker" 3 | log_dir = "/mirrors/log/tunasync/{{.Name}}" 4 | mirror_dir = "/mirrors" 5 | concurrent = 3 6 | interval = 1680 7 | 8 | [manager] 9 | api_base = "http://localhost:14242" 10 | token = "some_token" 11 | ca_cert = "" 12 | 13 | [cgroup] 14 | enable = false 15 | base_path = "/sys/fs/cgroup" 16 | group = "tunasync" 17 | 18 | [server] 19 | hostname = "localhost" 20 | listen_addr = "127.0.0.1" 21 | listen_port = 16030 22 | ssl_cert = "" 23 | ssl_key = "" 24 | 25 | [[mirrors]] 26 | name = "epel" 27 | provider = "rsync" 28 | upstream = "rsync://rsync.mirrors.ustc.edu.cn/epel/" 29 | use_ipv6 = false 30 | -------------------------------------------------------------------------------- /tunasync/conf/worker-pypi.conf: -------------------------------------------------------------------------------- 1 | [global] 2 | name = "pypi_worker" 3 | log_dir = "/mirrors/log/tunasync/{{.Name}}" 4 | mirror_dir = "/mirrors" 5 | concurrent = 5 6 | interval = 1920 7 | 8 | [manager] 9 | api_base = "http://localhost:14242" 10 | token = "some_token" 11 | ca_cert = "" 12 | 13 | [cgroup] 14 | enable = false 15 | base_path = "/sys/fs/cgroup" 16 | group = "tunasync" 17 | 18 | [server] 19 | hostname = "localhost" 20 | listen_addr = "127.0.0.1" 21 | listen_port = 16050 22 | ssl_cert = "" 23 | ssl_key = "" 24 | 25 | [[mirrors]] 26 | name = "pypi" 27 | provider = "rsync" 28 | upstream = "rsync://rsync.mirrors.ustc.edu.cn/pypi/" 29 | use_ipv6 = false 30 | -------------------------------------------------------------------------------- /tunasync/conf/worker-ubuntu.conf: -------------------------------------------------------------------------------- 1 | [global] 2 | name = "ubuntu_worker" 3 | log_dir = "/mirrors/log/tunasync/{{.Name}}" 4 | mirror_dir = "/mirrors" 5 | concurrent = 10 6 | interval = 540 7 | 8 | [manager] 9 | api_base = "http://localhost:14242" 10 | token = "some_token" 11 | ca_cert = "" 12 | 13 | [cgroup] 14 | enable = false 15 | base_path = "/sys/fs/cgroup" 16 | group = "tunasync" 17 | 18 | [server] 19 | hostname = "localhost" 20 | listen_addr = "127.0.0.1" 21 | listen_port = 16020 22 | ssl_cert = "" 23 | ssl_key = "" 24 | 25 | [[mirrors]] 26 | name = "ubuntu" 27 | provider = "rsync" 28 | upstream = "rsync://mirrors.yun-idc.com/ubuntu/" 29 | use_ipv6 = false 30 | 31 | -------------------------------------------------------------------------------- /tunasync/scripts/updateTunasync.sh: -------------------------------------------------------------------------------- 1 | #! /bin/bash 2 | source ~/.bash_profile 3 | 4 | centos_size=`du -sh /mirrors/centos/ | awk '{print $1}'` 5 | epel_size=`du -sh /mirrors/epel/ | awk '{print $1}'` 6 | ubuntu_size=`du -sh /mirrors/ubuntu/ | awk '{print $1}'` 7 | pypi_size=`du -sh /mirrors/pypi/ | awk '{print $1}'` 8 | 9 | tunasynctl set-size -w centos_worker centos $centos_size 10 | tunasynctl set-size -w epel_worker epel $epel_size 11 | tunasynctl set-size -w ubuntu_worker ubuntu $ubuntu_size 12 | tunasynctl set-size -w pypi_worker pypi $pypi_size 13 | 14 | sleep 5 15 | 16 | mv /mirrors/jobs.json /mirrors/jobs.json.bak 17 | wget -c http://localhost:14242/jobs -O /mirrors/jobs.json -o /mirrors/log/plog/wget.log 18 | -------------------------------------------------------------------------------- /web/.help/CentOS6-Base.repo: -------------------------------------------------------------------------------- 1 | # CentOS-Base.repo 2 | # 3 | # The mirror system uses the connecting IP address of the client and the 4 | # update status of each mirror to pick mirrors that are updated to and 5 | # geographically close to the client. You should use this for CentOS updates 6 | # unless you are manually picking other mirrors. 7 | # 8 | # If the mirrorlist= does not work for you, as a fall back you can try the 9 | # remarked out baseurl= line instead. 10 | # 11 | # 12 | 13 | [base] 14 | name=CentOS-6 - Base 15 | baseurl=http://mymirrorsite/centos/6/os/$basearch/ 16 | #mirrorlist=http://mirrorlist.centos.org/?release=6&arch=$basearch&repo=os 17 | gpgcheck=1 18 | gpgkey=http://mymirrorsite/centos/RPM-GPG-KEY-CentOS-6 19 | 20 | #released updates 21 | [updates] 22 | name=CentOS-6 - Updates 23 | baseurl=http://mymirrorsite/centos/6/updates/$basearch/ 24 | #mirrorlist=http://mirrorlist.centos.org/?release=6&arch=$basearch&repo=updates 25 | gpgcheck=1 26 | gpgkey=http://mymirrorsite/centos/RPM-GPG-KEY-CentOS-6 27 | 28 | #additional packages that may be useful 29 | [extras] 30 | name=CentOS-6 - Extras 31 | baseurl=http://mymirrorsite/centos/6/extras/$basearch/ 32 | #mirrorlist=http://mirrorlist.centos.org/?release=6&arch=$basearch&repo=extras 33 | gpgcheck=1 34 | gpgkey=http://mymirrorsite/centos/RPM-GPG-KEY-CentOS-6 35 | 36 | #additional packages that extend functionality of existing packages 37 | [centosplus] 38 | name=CentOS-6 - Plus 39 | baseurl=http://mymirrorsite/centos/6/centosplus/$basearch/ 40 | #mirrorlist=http://mirrorlist.centos.org/?release=6&arch=$basearch&repo=centosplus 41 | gpgcheck=1 42 | enabled=0 43 | gpgkey=http://mymirrorsite/centos/RPM-GPG-KEY-CentOS-6 44 | 45 | #contrib - packages by Centos Users 46 | [contrib] 47 | name=CentOS-6 - Contrib 48 | baseurl=http://mymirrorsite/centos/6/contrib/$basearch/ 49 | #mirrorlist=http://mirrorlist.centos.org/?release=6&arch=$basearch&repo=contrib 50 | gpgcheck=1 51 | enabled=0 52 | gpgkey=http://mymirrorsite/centos/RPM-GPG-KEY-CentOS-6 -------------------------------------------------------------------------------- /web/.help/CentOS7-Base.repo: -------------------------------------------------------------------------------- 1 | # CentOS-Base.repo 2 | # 3 | # The mirror system uses the connecting IP address of the client and the 4 | # update status of each mirror to pick mirrors that are updated to and 5 | # geographically close to the client. You should use this for CentOS updates 6 | # unless you are manually picking other mirrors. 7 | # 8 | # If the mirrorlist= does not work for you, as a fall back you can try the 9 | # remarked out baseurl= line instead. 10 | # 11 | # 12 | 13 | [base] 14 | name=CentOS-7 - Base 15 | baseurl=http://mymirrorsite/centos/7/os/$basearch/ 16 | #mirrorlist=http://mirrorlist.centos.org/?release=7&arch=$basearch&repo=os 17 | gpgcheck=1 18 | gpgkey=http://mymirrorsite/centos/RPM-GPG-KEY-CentOS-7 19 | 20 | #released updates 21 | [updates] 22 | name=CentOS-7 - Updates 23 | baseurl=http://mymirrorsite/centos/7/updates/$basearch/ 24 | #mirrorlist=http://mirrorlist.centos.org/?release=7&arch=$basearch&repo=updates 25 | gpgcheck=1 26 | gpgkey=http://mymirrorsite/centos/RPM-GPG-KEY-CentOS-7 27 | 28 | #additional packages that may be useful 29 | [extras] 30 | name=CentOS-7 - Extras 31 | baseurl=http://mymirrorsite/centos/7/extras/$basearch/ 32 | #mirrorlist=http://mirrorlist.centos.org/?release=7&arch=$basearch&repo=extras 33 | gpgcheck=1 34 | gpgkey=http://mymirrorsite/centos/RPM-GPG-KEY-CentOS-7 35 | 36 | #additional packages that extend functionality of existing packages 37 | [centosplus] 38 | name=CentOS-7 - Plus 39 | baseurl=http://mymirrorsite/centos/7/centosplus/$basearch/ 40 | #mirrorlist=http://mirrorlist.centos.org/?release=7&arch=$basearch&repo=centosplus 41 | gpgcheck=1 42 | enabled=0 43 | gpgkey=http://mymirrorsite/centos/RPM-GPG-KEY-CentOS-7 44 | 45 | #contrib - packages by Centos Users 46 | [contrib] 47 | name=CentOS-7 - Contrib 48 | baseurl=http://mymirrorsite/centos/7/contrib/$basearch/ 49 | #mirrorlist=http://mirrorlist.centos.org/?release=7&arch=$basearch&repo=contrib 50 | gpgcheck=1 51 | enabled=0 52 | gpgkey=http://mymirrorsite/centos/RPM-GPG-KEY-CentOS-7 -------------------------------------------------------------------------------- /web/.help/UpgradePython.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/weyo/mirrors/3bab6c3c3eb04ccdca6aeadb70666fd40b207bcd/web/.help/UpgradePython.pdf -------------------------------------------------------------------------------- /web/.help/centos.html: -------------------------------------------------------------------------------- 1 | 3 | 4 |
5 | 6 |首先备份 /etc/yum.repos.d/
下的所有 repo 文件(使用root用户)
30 | mkdir /etc/yum.repos.d/bak 31 | mv /etc/yum.repos.d/*.repo /etc/yum.repos.d/bak32 |
然后根据系统版本下载对应版本repo文件, 放入/etc/yum.repos.d/
33 |运行以下命令更新软件包缓存
38 |39 | yum clean all 40 | yum makecache41 | 42 | 43 |
17 | EPEL (Extra Packages for Enterprise Linux) 是由 Fedora Special Interest Group 为企业 Linux 创建、维护和管理的一个高质量附加包集合,适用于但不仅限于 Red Hat Enterprise Linux (RHEL), CentOS, Scientific Linux (SL), Oracle Linux (OL)等。 18 |
19 |21 | 官方支持的所有架构 22 |
23 |25 | 官方支持的所有版本 26 |
27 |首先执行以下命令安装epel
32 |yum install -y epel-release33 |
然后运行以下命令更新repo文件
34 |35 | sed -e39 | 40 | 41 | 42 |'s!^mirrorlist=!#mirrorlist=!g'
\ 36 | -e's!^#baseurl=!baseurl=!g'
\ 37 | -e's!//download\.fedoraproject\.org/pub!//mymirrorsite!g'
\ 38 | -i /etc/yum.repos.d/epel.repo /etc/yum.repos.d/epel-testing.repo
20 | 本镜像为 Python 软件包(PIP)镜像,详细信息可参考 PyPI 官网。 21 |
22 |执行以下命令查看 Python 版本:
28 |python -V29 |
如果所安装的 Python 为 2.7.x 或者 3.x.x 版本,则不需要升级。如果 Python 版本较低(2.6.x 及以下版本),请参阅 Python 升级说明.pdf 完成 Python 升级。
30 |执行以下命令查看是否安装有 pip
32 |pip -V33 |
如果未安装 pip,需要按照以下方式进行安装。
34 |2.1 在线安装
35 |按照官网(https://pip.pypa.io/en/stable/installing/)所述方法安装 get-pip.py。
36 | 2.2 离线安装 37 |首先安装setuptools
,在官网(https://pypi.python.org/pypi/setuptools)下载 setuptools-<版本号>.zip:
解压zip包后,进入目录运行
40 |python setup.py install41 |
即可完成 setuptools 安装。
42 |然后安装pip
,在官网(https://pypi.python.org/pypi/pip)下载 pip-<版本号>.tar.gz:
解压tar包后,进入目录运行
45 |python setup.py install46 |
即可完成 pip 安装。
47 |编辑 pip 的配置文件 pip.conf,将 index-url 修改为镜像站的地址。
49 |pip 的配置文件一般位于(如果没有该文件,请直接创建):
50 |51 | · Unix/Linux:55 |$HOME/.config/pip/pip.conf
52 | · macOS:$HOME/Library/Application Support/pip/pip.conf
53 | · Windows:%APPDATA%\pip\pip.ini
54 |
修改后的 pip 配置文件示例如下:
56 |[global] 57 | index-url = http://mymirrorsite/pypi/web/simple 58 | format = columns59 |
当 pip 和 pip3 并存时,只需修改 ~/.pip/pip.conf。
60 |使用 pip 时如果出现 configparser.MissingSectionHeaderError: File contains no section headers.
,说明 pip.conf 没有加上 [global]
这一行。
新版 pip 需要使用安全地址,由于镜像站暂不支持 https 服务,使用 pip 时需要添加 --trusted-host mymirrorsite
参数,例如:
pip install [SomePackage] --trusted-host mymirrorsite64 | 65 | 66 |
Ubuntu 的软件源配置文件是
37 | /etc/apt/sources.list
。将该文件替换为下面内容(替换前做好备份),即可使用软件源镜像。
# 默认注释了源码镜像以提高 apt update 速度,如有需要可自行取消注释 56 | deb http://mymirrorsite/ubuntu/68 | 69 | 70 | 71 |xenial
main restricted universe multiverse 57 | # deb-src http://mymirrorsite/ubuntu/xenial
main restricted universe multiverse 58 | deb http://mymirrorsite/ubuntu/xenial
-updates main restricted universe multiverse 59 | # deb-src http://mymirrorsite/ubuntu/xenial
-updates main restricted universe multiverse 60 | deb http://mymirrorsite/ubuntu/xenial
-backports main restricted universe multiverse 61 | # deb-src http://mymirrorsite/ubuntu/xenial
-backports main restricted universe multiverse 62 | deb http://mymirrorsite/ubuntu/xenial
-security main restricted universe multiverse 63 | # deb-src http://mymirrorsite/ubuntu/xenial
-security main restricted universe multiverse 64 | 65 | # 预发布软件源,不建议启用 66 | # deb http://mymirrorsite/ubuntu/xenial
-proposed main restricted universe multiverse 67 | # deb-src http://mymirrorsite/ubuntu/xenial
-proposed main restricted universe multiverse
t |
镜像名 | 29 |上次更新时间 | 30 |更新源 | 31 |状态 | 32 |镜像大小 | 33 |使用帮助 | 34 |
---|---|---|---|---|---|
centos/ | 40 |N/A | 41 |N/A | 42 |N/A | 43 |N/A | 44 |Centos/Redhat 使用帮助 | 45 |
pypi/ | 48 |N/A | 49 |N/A | 50 |N/A | 51 |N/A | 52 |PyPI 使用帮助 | 53 |
epel/ | 56 |N/A | 57 |N/A | 58 |N/A | 59 |N/A | 60 |EPEL 使用帮助 | 61 |
ubuntu/ | 64 |N/A | 65 |N/A | 66 |N/A | 67 |N/A | 68 |Ubuntu 使用帮助 | 69 |