├── logo.png ├── ubuntu ├── 20.04 │ ├── 163 │ │ └── sources.list │ ├── aliyun │ │ └── sources.list │ └── tsinghua │ │ └── sources.list ├── 16.04 │ ├── 163 │ │ └── sources.list │ ├── tsinghua │ │ └── sources.list │ └── aliyun │ │ └── sources.list └── 18.04 │ ├── 163 │ └── sources.list │ ├── aliyun │ └── sources.list │ └── tsinghua │ └── sources.list ├── LICENSE ├── README.md └── apt-select.sh /logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iHunterDev/apt-select/master/logo.png -------------------------------------------------------------------------------- /ubuntu/20.04/163/sources.list: -------------------------------------------------------------------------------- 1 | deb http://mirrors.163.com/ubuntu/ focal main restricted universe multiverse 2 | deb http://mirrors.163.com/ubuntu/ focal-security main restricted universe multiverse 3 | deb http://mirrors.163.com/ubuntu/ focal-updates main restricted universe multiverse 4 | deb http://mirrors.163.com/ubuntu/ focal-backports main restricted universe multiverse 5 | deb-src http://mirrors.163.com/ubuntu/ focal main restricted universe multiverse 6 | deb-src http://mirrors.163.com/ubuntu/ focal-security main restricted universe multiverse 7 | deb-src http://mirrors.163.com/ubuntu/ focal-updates main restricted universe multiverse 8 | deb-src http://mirrors.163.com/ubuntu/ focal-backports main restricted universe multiverse -------------------------------------------------------------------------------- /ubuntu/16.04/163/sources.list: -------------------------------------------------------------------------------- 1 | deb http://mirrors.163.com/ubuntu/ xenial main restricted universe multiverse 2 | deb http://mirrors.163.com/ubuntu/ xenial-security main restricted universe multiverse 3 | deb http://mirrors.163.com/ubuntu/ xenial-updates main restricted universe multiverse 4 | deb http://mirrors.163.com/ubuntu/ xenial-proposed main restricted universe multiverse 5 | deb http://mirrors.163.com/ubuntu/ xenial-backports main restricted universe multiverse 6 | deb-src http://mirrors.163.com/ubuntu/ xenial main restricted universe multiverse 7 | deb-src http://mirrors.163.com/ubuntu/ xenial-security main restricted universe multiverse 8 | deb-src http://mirrors.163.com/ubuntu/ xenial-updates main restricted universe multiverse 9 | deb-src http://mirrors.163.com/ubuntu/ xenial-proposed main restricted universe multiverse 10 | deb-src http://mirrors.163.com/ubuntu/ xenial-backports main restricted universe multiverse -------------------------------------------------------------------------------- /ubuntu/18.04/163/sources.list: -------------------------------------------------------------------------------- 1 | deb http://mirrors.163.com/ubuntu/ bionic main restricted universe multiverse 2 | deb http://mirrors.163.com/ubuntu/ bionic-security main restricted universe multiverse 3 | deb http://mirrors.163.com/ubuntu/ bionic-updates main restricted universe multiverse 4 | deb http://mirrors.163.com/ubuntu/ bionic-proposed main restricted universe multiverse 5 | deb http://mirrors.163.com/ubuntu/ bionic-backports main restricted universe multiverse 6 | deb-src http://mirrors.163.com/ubuntu/ bionic main restricted universe multiverse 7 | deb-src http://mirrors.163.com/ubuntu/ bionic-security main restricted universe multiverse 8 | deb-src http://mirrors.163.com/ubuntu/ bionic-updates main restricted universe multiverse 9 | deb-src http://mirrors.163.com/ubuntu/ bionic-proposed main restricted universe multiverse 10 | deb-src http://mirrors.163.com/ubuntu/ bionic-backports main restricted universe multiverse -------------------------------------------------------------------------------- /ubuntu/20.04/aliyun/sources.list: -------------------------------------------------------------------------------- 1 | deb http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse 2 | deb-src http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse 3 | deb http://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse 4 | deb-src http://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse 5 | deb http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse 6 | deb-src http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse 7 | deb http://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse 8 | deb-src http://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse 9 | deb http://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse 10 | deb-src http://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse -------------------------------------------------------------------------------- /ubuntu/18.04/aliyun/sources.list: -------------------------------------------------------------------------------- 1 | deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse 2 | deb-src http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse 3 | 4 | deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse 5 | deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse 6 | 7 | deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse 8 | deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse 9 | 10 | deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse 11 | deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse 12 | 13 | deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse 14 | deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse -------------------------------------------------------------------------------- /ubuntu/20.04/tsinghua/sources.list: -------------------------------------------------------------------------------- 1 | # 默认注释了源码镜像以提高 apt update 速度,如有需要可自行取消注释 2 | deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal main restricted universe multiverse 3 | # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal main restricted universe multiverse 4 | deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-updates main restricted universe multiverse 5 | # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-updates main restricted universe multiverse 6 | deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-backports main restricted universe multiverse 7 | # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-backports main restricted universe multiverse 8 | deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-security main restricted universe multiverse 9 | # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-security main restricted universe multiverse 10 | 11 | # 预发布软件源,不建议启用 12 | # deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-proposed main restricted universe multiverse 13 | # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-proposed main restricted universe multiverse -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 WZBLOG 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 | -------------------------------------------------------------------------------- /ubuntu/16.04/tsinghua/sources.list: -------------------------------------------------------------------------------- 1 | # 默认注释了源码镜像以提高 apt update 速度,如有需要可自行取消注释 2 | deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial main restricted universe multiverse 3 | # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial main restricted universe multiverse 4 | deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-updates main restricted universe multiverse 5 | # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-updates main restricted universe multiverse 6 | deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-backports main restricted universe multiverse 7 | # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-backports main restricted universe multiverse 8 | deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-security main restricted universe multiverse 9 | # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-security main restricted universe multiverse 10 | 11 | # 预发布软件源,不建议启用 12 | # deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-proposed main restricted universe multiverse 13 | # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-proposed main restricted universe multiverse -------------------------------------------------------------------------------- /ubuntu/18.04/tsinghua/sources.list: -------------------------------------------------------------------------------- 1 | # 默认注释了源码镜像以提高 apt update 速度,如有需要可自行取消注释 2 | deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic main restricted universe multiverse 3 | # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic main restricted universe multiverse 4 | deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse 5 | # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse 6 | deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse 7 | # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse 8 | deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-security main restricted universe multiverse 9 | # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-security main restricted universe multiverse 10 | 11 | # 预发布软件源,不建议启用 12 | # deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse 13 | # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse -------------------------------------------------------------------------------- /ubuntu/16.04/aliyun/sources.list: -------------------------------------------------------------------------------- 1 | # deb cdrom:[Ubuntu 16.04 LTS _Xenial Xerus_ - Release amd64 (20160420.1)]/ xenial main restricted 2 | deb-src http://archive.ubuntu.com/ubuntu xenial main restricted #Added by software-properties 3 | deb http://mirrors.aliyun.com/ubuntu/ xenial main restricted 4 | deb-src http://mirrors.aliyun.com/ubuntu/ xenial main restricted multiverse universe #Added by software-properties 5 | deb http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted 6 | deb-src http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted multiverse universe #Added by software-properties 7 | deb http://mirrors.aliyun.com/ubuntu/ xenial universe 8 | deb http://mirrors.aliyun.com/ubuntu/ xenial-updates universe 9 | deb http://mirrors.aliyun.com/ubuntu/ xenial multiverse 10 | deb http://mirrors.aliyun.com/ubuntu/ xenial-updates multiverse 11 | deb http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse 12 | deb-src http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse #Added by software-properties 13 | deb http://archive.canonical.com/ubuntu xenial partner 14 | deb-src http://archive.canonical.com/ubuntu xenial partner 15 | deb http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted 16 | deb-src http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted multiverse universe #Added by software-properties 17 | deb http://mirrors.aliyun.com/ubuntu/ xenial-security universe 18 | deb http://mirrors.aliyun.com/ubuntu/ xenial-security multiverse -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | ![logo][1] 3 | 4 | # apt-select 5 | 6 | > Linux 快速换源工具 7 | 8 | ![版本][2] ![许可协议][3] 9 | 10 | 11 | 12 | ## 功能列表 13 | 14 | - [x] 自动检测系统版本 15 | - [x] Ubuntu 换源 16 | 17 | 18 | 19 | 20 | ## 源兼容 21 | 22 | - Ubuntu 23 | - 20.04 TLS 24 | - [x] 阿里源 25 | - [x] 清华源 26 | - [x] 网易源 27 | - 18.04 TLS 28 | - [x] 阿里源 29 | - [x] 清华源 30 | - [x] 网易源 31 | - 16.04 TLS 32 | - [x] 阿里源 33 | - [x] 清华源 34 | - [x] 网易源 35 | - 14.04 TLS 36 | - [ ] 阿里源 37 | - [ ] 清华源 38 | - [ ] 网易源 39 | 40 | 41 | ## 版本识别支持 42 | 43 | - Ubuntu 44 | - [x] ubuntu 20.04 LTS 45 | - [x] ubuntu 18.04 LTS 46 | - [x] ubuntu 16.04 LTS 47 | 48 | 49 | ## 版本历史 50 | 51 | ### v0.0.7(2020/10/22 22:00 +08:00) 52 | 53 | - 优化部分代码写法 54 | 55 | ### v0.0.6(2020/10/22 22:00 +08:00) 56 | 57 | - 添加 `ubuntu 20.04 LTS` 阿里源设置功能 58 | - 添加 `ubuntu 20.04 LTS` 清华源设置功能 59 | - 添加 `ubuntu 20.04 LTS` 网易源设置功能 60 | - 优化部分代码写法 61 | - 修复已知BUG 62 | 63 | ### v0.0.5(2019/07/26 14:00 +08:00) 64 | 65 | - 添加 `ubuntu 16.04 LTS` 阿里源设置功能 66 | - 添加 `ubuntu 16.04 LTS` 清华源设置功能 67 | - 添加 `ubuntu 16.04 LTS` 网易源设置功能 68 | 69 | ### v0.0.4(2019/07/21 10:35 +08:00) 70 | 71 | - 添加 `ubuntu 18.04 LTS` 网易源设置功能 72 | 73 | ### v0.0.3(2019/07/10 10:35 +08:00) 74 | 75 | - 添加系统和版本检测功能(理论上 ubuntu 系统通用,16.04起,之前的版本没测过) 76 | 77 | ### v0.0.2(2019/07/09 11:44 +08:00) 78 | 79 | - 添加 `ubuntu 18.04 LTS` 清华源设置功能 80 | 81 | ### v0.0.1(2019/07/08 21:30 +08:30) 82 | 83 | - 初步实现整体框架 84 | - 添加 `ubuntu 18.04 LTS` 阿里源设置功能 85 | 86 | ### v0.0.0(2019/07/08 13:14 +08:00) 87 | 88 | - 初始化项目 89 | 90 | 91 | 92 | ## 为什么会有这个项目? 93 | 94 | 作者喜欢折腾, 经常需要重装系统, 所以日常换源. 95 | 96 | 97 | 98 | ## 使用方法 99 | 100 | ```sh 101 | # 如果出现 git : 找不到该命令 则运行 sudo apt-get install git 102 | git clone https://github.com/wzblog/apt-select.git 103 | 104 | cd ./apt-select 105 | 106 | sudo chmod +x ./apt-select.sh 107 | 108 | sudo ./apt-select.sh ali # 阿里源 109 | sudo ./apt-select.sh thu # 清华源 110 | sudo ./apt-select.sh thu # 网易源 111 | ``` 112 | 113 | ### 手动指定系统与版本 114 | 115 | > 系统名称统一为小写 116 | > 117 | > 系统版本只取 `x.y.z` 的 `x.y` 位 118 | 119 | ```sh 120 | # 语法 sudo ./apt-select.sh ali [系统名称 系统版本] 121 | sudo ./apt-select.sh ali ubuntu 18.04 122 | ``` 123 | 124 | 125 | 126 | ## 关于 127 | 128 | - [作者博客 : https://blog.wz52.cn](https://blog.wz52.cn) 129 | - [邮箱 : WCGcodes@gmail.com](mailto:wcgcodes@gmail.com) 130 | - [提交 BUG 或建议](https://github.com/wzblog/apt-select/issues) 131 | 132 | [1]: ./logo.png 133 | [2]: https://img.shields.io/badge/apt--select-v0.0.6-blue.svg 134 | [3]: https://img.shields.io/badge/license-MIT-blue.svg 135 | 136 | -------------------------------------------------------------------------------- /apt-select.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | _github="https://github.com/wzblog/apt-select" 4 | _app="apt-select" 5 | _system=${2} 6 | _version=${3} 7 | 8 | function e() 9 | { 10 | echo -e "\033[${1}m${2}\033[0m" 11 | } 12 | 13 | # Backup source 14 | function backup() 15 | { 16 | echo -e "\033[32m* 开始备份源\033[0m" 17 | cp /etc/apt/sources.list /etc/apt/sources.list.backup 18 | 19 | if [[ -e /etc/apt/sources.list.backup ]] 20 | then 21 | e 32 "* 备份源成功" 22 | else 23 | e 31 "* 备份源失败" 24 | exit 1 25 | fi 26 | } 27 | 28 | 29 | function update() 30 | { 31 | e 32 "* 开始清除旧软件源" 32 | apt-get clean 33 | apt-get autoclean 34 | e 32 "* 结束清除旧软件源" 35 | e 32 "* 开始更新软件源" 36 | apt-get update 37 | e 32 "* 结束更新软件源" 38 | } 39 | 40 | 41 | function setSource() 42 | { 43 | e 32 "* 开始修改源" 44 | echo "----------" 45 | echo "+ System: ${1}" 46 | echo "+ Version: ${2}" 47 | echo "+ Server: ${3}" 48 | echo "----------" 49 | e 32 "* 开始复制指定源文件" 50 | 51 | _path=$(pwd)/${1}/${2}/${3}/sources.list 52 | 53 | if [[ -e ${_path} ]] 54 | then 55 | cp $(pwd)/${1}/${2}/${3}/sources.list /etc/apt/sources.list 56 | e 32 "* 复制完成" 57 | 58 | # update software sources 59 | update 60 | else 61 | e 31 "* ${_path} 文件未找到" 62 | exit 1 63 | fi 64 | } 65 | 66 | 67 | # 系统类型与版本检查函数 68 | function checkSystem() 69 | { 70 | # 系统类型与版本检查 71 | _system=$(lsb_release -i | awk '{ print tolower($3) }') 72 | _version=$(lsb_release -r | awk '{ print tolower($2) }') 73 | 74 | echo "系统:"${_system} 75 | echo "版本:"${_version} 76 | 77 | printf "系统类型与版本是否与你的系统所匹配(Y/n):" 78 | read _mark 79 | 80 | _mark=${_mark:-'Y'} 81 | 82 | if [[ ${_mark} != 'Y' && ${_mark} != 'y' ]] 83 | then 84 | printHelp 85 | e 31 "请手动指定你的系统版本" 86 | exit 1 87 | fi 88 | } 89 | 90 | 91 | 92 | # 输出帮助信息 93 | function printHelp() 94 | { 95 | echo "----------" 96 | echo "+-------------------------------+" 97 | echo "| Manager for ${_app} |" 98 | echo "+-------------------------------+" 99 | echo "${_app} [system version] ali (阿里源)" 100 | echo "${_app} [system version] thu (清华源)" 101 | echo "${_app} [system version] 163 (163源)" 102 | echo "----------" 103 | } 104 | 105 | # 如果没有手动指定则自动获取 106 | if [[ -z ${_system} || -z ${_version} ]] 107 | then 108 | checkSystem 109 | fi 110 | 111 | 112 | 113 | if [[ ${1} = "ali" || ${1} = "thu" || ${1} = "163" ]] 114 | then 115 | # start backup 116 | backup 117 | fi 118 | 119 | 120 | case ${1} in 121 | ali ) 122 | setSource ${_system} ${_version} aliyun 123 | ;; 124 | thu ) 125 | setSource ${_system} ${_version} tsinghua 126 | ;; 127 | 163 ) 128 | setSource ${_system} ${_version} 163 129 | ;; 130 | * ) 131 | printHelp 132 | ;; 133 | esac 134 | 135 | e 33 "* ${_github}" 136 | --------------------------------------------------------------------------------