重构脚本镜像选择逻辑 & 一些优化

This commit is contained in:
SuperManito
2023-05-02 18:22:44 +08:00
parent b6495c16a3
commit 45451e0b2a
7 changed files with 302 additions and 568 deletions

View File

@@ -1,9 +1,46 @@
#!/bin/bash
## Author: SuperManito
## Modified: 2023-05-01
## License: GPL-2.0
## Modified: 2023-05-02
## License: MIT
## Github: https://github.com/SuperManito/LinuxMirrors
## Gitee: https://gitee.com/SuperManito/LinuxMirrors
## 国内镜像站列表
# 格式:"镜像站名称@镜像站地址"
mirror_list_default=(
"阿里云@mirrors.aliyun.com"
"腾讯云@mirrors.tencent.com"
"华为云@repo.huaweicloud.com"
"网易@mirrors.163.com"
"搜狐@mirrors.sohu.com"
"清华大学@mirrors.tuna.tsinghua.edu.cn"
"北京大学@mirrors.pku.edu.cn"
"浙江大学@mirrors.zju.edu.cn"
"南京大学@mirrors.nju.edu.cn"
"重庆大学@mirrors.cqu.edu.cn"
"兰州大学@mirror.lzu.edu.cn"
"上海交通大学@mirror.sjtu.edu.cn"
"哈尔滨工业大学@mirrors.hit.edu.cn"
"中国科学技术大学@mirrors.ustc.edu.cn"
"中国科学院软件研究所@mirror.iscas.ac.cn"
)
## 配置需要区分公网地址和内网地址的镜像站(不分地域)
# 配置方法:需要同时在两个数组变量中分别定义镜像站地址,并且保证排列顺序一致
# 工作原理:当检测到用户所选择的镜像站地址在 “镜像站公网地址列表” 中时就会询问是否切换为内网地址,然后从 “镜像站内网地址列表” 相同的位置提取内网地址
# 镜像站公网地址列表
mirror_list_extranet=(
"mirrors.aliyun.com"
"mirrors.tencent.com"
"repo.huaweicloud.com"
)
# 镜像站内网地址列表
mirror_list_intranet=(
"mirrors.cloud.aliyuncs.com"
"mirrors.tencentyun.com"
"mirrors.myhuaweicloud.com"
)
##############################################################################
## 定义系统判定变量
SYSTEM_DEBIAN="Debian"
@@ -219,7 +256,7 @@ function BackupMirrors() {
## /etc/apt/sources.list
if [ -s $File_DebianSourceList ]; then
if [ -s $File_DebianSourceListBackup ]; then
local CHOICE_BACKUP1=$(echo -e "\n${BOLD}└─ 检测到系统存在已备份的 list 源文件,是否跳过覆盖备份? [Y/n] ${PLAIN}")
local CHOICE_BACKUP1=$(echo -e "\n${BOLD}└─ 检测到系统存在已备份的 list 源文件,是否跳过覆盖备份? [Y/n] ${PLAIN}")
read -p "${CHOICE_BACKUP1}" INPUT
[ -z ${INPUT} ] && INPUT=Y
case $INPUT in
@@ -246,7 +283,7 @@ function BackupMirrors() {
## /etc/apt/sources.list.d
if [ -d $Dir_DebianExtendSource ] && [ ${VERIFICATION_FILES} -eq 0 ]; then
if [ -d $Dir_DebianExtendSourceBackup ] && [ ${VERIFICATION_BACKUPFILES} -eq 0 ]; then
local CHOICE_BACKUP2=$(echo -e "\n${BOLD}└─ 检测到系统存在已备份的 list 第三方源文件,是否跳过覆盖备份? [Y/n] ${PLAIN}")
local CHOICE_BACKUP2=$(echo -e "\n${BOLD}└─ 检测到系统存在已备份的 list 第三方源文件,是否跳过覆盖备份? [Y/n] ${PLAIN}")
read -p "${CHOICE_BACKUP2}" INPUT
[ -z ${INPUT} ] && INPUT=Y
case $INPUT in
@@ -272,7 +309,7 @@ function BackupMirrors() {
## /etc/yum.repos.d
if [ ${VERIFICATION_FILES} -eq 0 ]; then
if [ -d $Dir_RedHatReposBackup ] && [ ${VERIFICATION_BACKUPFILES} -eq 0 ]; then
local CHOICE_BACKUP3=$(echo -e "\n${BOLD}└─ 检测到系统存在已备份的 repo 源文件,是否跳过覆盖备份? [Y/n] ${PLAIN}")
local CHOICE_BACKUP3=$(echo -e "\n${BOLD}└─ 检测到系统存在已备份的 repo 源文件,是否跳过覆盖备份? [Y/n] ${PLAIN}")
read -p "${CHOICE_BACKUP3}" INPUT
[ -z ${INPUT} ] && INPUT=Y
case $INPUT in
@@ -300,7 +337,7 @@ function BackupMirrors() {
## /etc/yum.repos.d
if [ ${VERIFICATION_FILES} -eq 0 ]; then
if [ -d $Dir_openEulerReposBackup ] && [ ${VERIFICATION_BACKUPFILES} -eq 0 ]; then
local CHOICE_BACKUP4=$(echo -e "\n${BOLD}└─ 检测到系统存在已备份的 repo 源文件,是否跳过覆盖备份? [Y/n] ${PLAIN}")
local CHOICE_BACKUP4=$(echo -e "\n${BOLD}└─ 检测到系统存在已备份的 repo 源文件,是否跳过覆盖备份? [Y/n] ${PLAIN}")
read -p "${CHOICE_BACKUP4}" INPUT
[ -z ${INPUT} ] && INPUT=Y
case $INPUT in
@@ -328,7 +365,7 @@ function BackupMirrors() {
## /etc/zypp/repos.d
if [ ${VERIFICATION_FILES} -eq 0 ]; then
if [ -d $Dir_openSUSEReposBackup ] && [ ${VERIFICATION_BACKUPFILES} -eq 0 ]; then
local CHOICE_BACKUP4=$(echo -e "\n${BOLD}└─ 检测到系统存在已备份的 repo 源文件,是否跳过覆盖备份? [Y/n] ${PLAIN}")
local CHOICE_BACKUP4=$(echo -e "\n${BOLD}└─ 检测到系统存在已备份的 repo 源文件,是否跳过覆盖备份? [Y/n] ${PLAIN}")
read -p "${CHOICE_BACKUP4}" INPUT
[ -z ${INPUT} ] && INPUT=Y
case $INPUT in
@@ -476,47 +513,63 @@ function UpgradeSoftware() {
esac
}
## 更换基于 Debian 系 Linux 发行版的国内
## 更换基于 Debian 系 Linux 发行版的软件
function DebianMirrors() {
## 修改国内源
local source_suffix
local TIPS="## 默认禁用源码镜像以提高速度,如需启用请自行取消注释"
local basic_url="${WEB_PROTOCOL}://${SOURCE}/${SOURCE_BRANCH}"
case "${SYSTEM_JUDGMENT}" in
"${SYSTEM_UBUNTU}")
echo "## 默认禁用源码镜像以提高速度,如需启用请自行取消注释
deb ${WEB_PROTOCOL}://${SOURCE}/${SOURCE_BRANCH} ${SYSTEM_VERSION_CODENAME} main restricted universe multiverse
# deb-src ${WEB_PROTOCOL}://${SOURCE}/${SOURCE_BRANCH} ${SYSTEM_VERSION_CODENAME} main restricted universe multiverse
deb ${WEB_PROTOCOL}://${SOURCE}/${SOURCE_BRANCH} ${SYSTEM_VERSION_CODENAME}-security main restricted universe multiverse
# deb-src ${WEB_PROTOCOL}://${SOURCE}/${SOURCE_BRANCH} ${SYSTEM_VERSION_CODENAME}-security main restricted universe multiverse
deb ${WEB_PROTOCOL}://${SOURCE}/${SOURCE_BRANCH} ${SYSTEM_VERSION_CODENAME}-updates main restricted universe multiverse
# deb-src ${WEB_PROTOCOL}://${SOURCE}/${SOURCE_BRANCH} ${SYSTEM_VERSION_CODENAME}-updates main restricted universe multiverse
deb ${WEB_PROTOCOL}://${SOURCE}/${SOURCE_BRANCH} ${SYSTEM_VERSION_CODENAME}-backports main restricted universe multiverse
# deb-src ${WEB_PROTOCOL}://${SOURCE}/${SOURCE_BRANCH} ${SYSTEM_VERSION_CODENAME}-backports main restricted universe multiverse
## 预发布软件源(不建议启用)
# deb ${WEB_PROTOCOL}://${SOURCE}/${SOURCE_BRANCH} ${SYSTEM_VERSION_CODENAME}-proposed main restricted universe multiverse
# deb-src ${WEB_PROTOCOL}://${SOURCE}/${SOURCE_BRANCH} ${SYSTEM_VERSION_CODENAME}-proposed main restricted universe multiverse" >>$File_DebianSourceList
;;
"${SYSTEM_DEBIAN}")
echo "## 默认禁用源码镜像以提高速度,如需启用请自行取消注释
deb ${WEB_PROTOCOL}://${SOURCE}/${SOURCE_BRANCH} ${SYSTEM_VERSION_CODENAME} main contrib non-free
# deb-src ${WEB_PROTOCOL}://${SOURCE}/${SOURCE_BRANCH} ${SYSTEM_VERSION_CODENAME} main contrib non-free
deb ${WEB_PROTOCOL}://${SOURCE}/${SOURCE_BRANCH} ${SYSTEM_VERSION_CODENAME}-updates main contrib non-free
# deb-src ${WEB_PROTOCOL}://${SOURCE}/${SOURCE_BRANCH} ${SYSTEM_VERSION_CODENAME}-updates main contrib non-free
deb ${WEB_PROTOCOL}://${SOURCE}/${SOURCE_BRANCH} ${SYSTEM_VERSION_CODENAME}-backports main contrib non-free
# deb-src ${WEB_PROTOCOL}://${SOURCE}/${SOURCE_BRANCH} ${SYSTEM_VERSION_CODENAME}-backports main contrib non-free
case "${SYSTEM_VERSION_NUMBER}" in
12)
source_suffix="main contrib non-free non-free-firmware"
;;
*)
source_suffix="main contrib non-free"
;;
esac
echo "${TIPS}
deb ${basic_url} ${SYSTEM_VERSION_CODENAME} ${source_suffix}
# deb-src ${basic_url} ${SYSTEM_VERSION_CODENAME} ${source_suffix}
deb ${basic_url} ${SYSTEM_VERSION_CODENAME}-updates ${source_suffix}
# deb-src ${basic_url} ${SYSTEM_VERSION_CODENAME}-updates ${source_suffix}
deb ${basic_url} ${SYSTEM_VERSION_CODENAME}-backports ${source_suffix}
# deb-src ${basic_url} ${SYSTEM_VERSION_CODENAME}-backports ${source_suffix}
deb ${basic_url}-security ${SYSTEM_VERSION_CODENAME}-security ${source_suffix}
# deb-src ${basic_url}-security ${SYSTEM_VERSION_CODENAME}-security ${source_suffix}
# deb https://security.debian.org/debian-security ${SYSTEM_VERSION_CODENAME}-security ${source_suffix}
# # deb-src https://security.debian.org/debian-security ${SYSTEM_VERSION_CODENAME}-security ${source_suffix}" >>$File_DebianSourceList
;;
"${SYSTEM_UBUNTU}")
source_suffix="main restricted universe multiverse"
echo "${TIPS}
deb ${basic_url} ${SYSTEM_VERSION_CODENAME} ${source_suffix}
# deb-src ${basic_url} ${SYSTEM_VERSION_CODENAME} ${source_suffix}
deb ${basic_url} ${SYSTEM_VERSION_CODENAME}-updates ${source_suffix}
# deb-src ${basic_url} ${SYSTEM_VERSION_CODENAME}-updates ${source_suffix}
deb ${basic_url} ${SYSTEM_VERSION_CODENAME}-backports ${source_suffix}
# deb-src ${basic_url} ${SYSTEM_VERSION_CODENAME}-backports ${source_suffix}
deb ${basic_url} ${SYSTEM_VERSION_CODENAME}-security ${source_suffix}
# deb-src ${basic_url} ${SYSTEM_VERSION_CODENAME}-security ${source_suffix}
# deb http://security.ubuntu.com/ubuntu ${SYSTEM_VERSION_CODENAME}-security ${source_suffix}
# # deb-src http://security.ubuntu.com/ubuntu ${SYSTEM_VERSION_CODENAME}-security ${source_suffix}
## 预发布软件源(不建议启用)
# deb ${WEB_PROTOCOL}://${SOURCE}/${SOURCE_BRANCH}-security ${SYSTEM_VERSION_CODENAME}/updates main contrib non-free
# deb-src ${WEB_PROTOCOL}://${SOURCE}/${SOURCE_BRANCH}-security ${SYSTEM_VERSION_CODENAME}/updates main contrib non-free" >>$File_DebianSourceList
# deb ${basic_url} ${SYSTEM_VERSION_CODENAME}-proposed ${source_suffix}
# deb-src ${basic_url} ${SYSTEM_VERSION_CODENAME}-proposed ${source_suffix}" >>$File_DebianSourceList
;;
"${SYSTEM_KALI}")
echo "## 默认禁用源码镜像以提高速度,如需启用请自行取消注释
deb ${WEB_PROTOCOL}://${SOURCE}/${SOURCE_BRANCH} ${SYSTEM_VERSION_CODENAME} main non-free contrib
# deb-src ${WEB_PROTOCOL}://${SOURCE}/${SOURCE_BRANCH} ${SYSTEM_VERSION_CODENAME} main non-free contrib" >>$File_DebianSourceList
source_suffix="main non-free contrib"
echo "${TIPS}
deb ${basic_url} ${SYSTEM_VERSION_CODENAME} ${source_suffix}
# deb-src ${basic_url} ${SYSTEM_VERSION_CODENAME} ${source_suffix}" >>$File_DebianSourceList
;;
esac
}
## 更换基于 RedHat 系 Linux 发行版的国内
## 更换基于 RedHat 系 Linux 发行版软件
function RedHatMirrors() {
## 生成基于 RedHat 发行版和及其衍生发行版的官方 repo 源文件
case "${SYSTEM_JUDGMENT}" in
@@ -663,7 +716,7 @@ function RedHatMirrors() {
esac
}
## 更换基于 openEuler 系 Linux 发行版的国内
## 更换基于 openEuler 系 Linux 发行版的软件
function openEulerMirrors() {
GenRepoFiles_openEuler
cd $Dir_openEulerRepos
@@ -674,7 +727,7 @@ function openEulerMirrors() {
sed -i "s|repo.openeuler.org|${SOURCE}/${SOURCE_BRANCH}|g" openEuler.repo
}
## 更换基于 openSUSE 系 Linux 发行版的国内
## 更换基于 openSUSE 系 Linux 发行版的软件
function openSUSEMirrors() {
case "${SYSTEM_ID}" in
"opensuse-leap")
@@ -750,7 +803,7 @@ function ChooseInstallEPEL() {
VERIFICATION_EPELBACKUPFILES=$?
if [ ${VERIFICATION_EPEL} -eq 0 ]; then
local CHOICE=$(echo -e "\n ${BOLD}└─ 检测到系统已安装 EPEL 附加软件包,是否替换/覆盖为国内源? [Y/n] ${PLAIN}")
local CHOICE=$(echo -e "\n ${BOLD}└─ 检测到系统已安装 EPEL 附加软件包,是否替换/覆盖软件源? [Y/n] ${PLAIN}")
else
local CHOICE=$(echo -e "\n ${BOLD}└─ 是否安装 EPEL 附加软件包? [Y/n] ${PLAIN}")
fi
@@ -772,17 +825,17 @@ function ChooseInstallEPEL() {
esac
}
## 安装/更换基于 RHEL/CentOS 等红帽系 Linux 的 EPEL (Extra Packages for Enterprise Linux) 附加软件包国内
## 安装/更换 EPEL (Extra Packages for Enterprise Linux) 附加软件包软件
function EPELMirrors() {
## 安装 EPEL 软件包
if [ ${VERIFICATION_EPEL} -ne 0 ]; then
echo -e "\n${WORKING} 安装 epel-release 软件包...\n"
yum install -y https://mirrors.cloud.tencent.com/epel/epel-release-latest-${SYSTEM_VERSION_NUMBER:0:1}.noarch.rpm
fi
## 删除原有 EPEL 附加软件包 repo 源文件
## 删除原有 repo 源文件
[ ${VERIFICATION_EPELFILES} -eq 0 ] && rm -rf $Dir_RedHatRepos/epel*
[ ${VERIFICATION_EPELBACKUPFILES} -eq 0 ] && rm -rf $Dir_RedHatReposBackup/epel*
## 生成官方 EPEL 附加软件包 repo 源文件
## 生成 repo 源文件
GenRepoFiles_EPEL
sed -i 's|^metalink=|#metalink=|g' $Dir_RedHatRepos/epel*
@@ -809,136 +862,132 @@ function EPELMirrors() {
rm -rf $Dir_RedHatRepos/epel*rpmnew
}
## 选择国内
## 选择软件
function ChooseMirrors() {
## 云计算厂商的软件源
# 分外网(公网)地址和内网地址,内网地址仅面向云计算厂商云服务器用户使用
# 内网地址不支持使用 HTTPS 协议
function Cloud_Computing_Vendors_Mirrors() {
local Extranet Intranet
## 公网地址
case $1 in
1)
Extranet="mirrors.aliyun.com"
;;
2)
Extranet="mirrors.tencent.com"
;;
3)
Extranet="repo.huaweicloud.com"
;;
esac
## 内网地址
case $1 in
1)
Intranet="mirrors.cloud.aliyuncs.com"
;;
2)
Intranet="mirrors.tencentyun.com"
;;
3)
Intranet="mirrors.myhuaweicloud.com"
;;
esac
## 打印软件源/镜像站列表
function PrintMirrorsList() {
local tmp_mirror_name tmp_mirror_url arr_num default_mirror_name_length tmp_mirror_name_length tmp_spaces_nums i j
CHOICE_A_TMP=$(echo -e "\n ${BOLD}└─ 默认使用镜像站的公网地址,是否继续? [Y/n] ${PLAIN}")
read -p "${CHOICE_A_TMP}" INPUT
## 计算字符串长度
function StringLength() {
local text=$1
echo "${#text}"
}
local list_arr=($(eval echo \${$1[*]}))
if [ -x /usr/bin/printf ]; then
for ((i = 0; i < ${#list_arr[@]}; i++)); do
tmp_mirror_name=$(echo ${list_arr[i]} | awk -F '@' '{print$1}') # 镜像站名称
# tmp_mirror_url=$(echo ${list_arr[i]} | awk -F '@' '{print$2}') # 镜像站地址
arr_num=$((i + 1))
default_mirror_name_length=${2:-"30"} # 默认镜像站名称打印长度
## 补齐长度差异中文的引号在等宽字体中占1格而非2格
[[ $(echo "${tmp_mirror_name}" | grep -c "“") -gt 0 ]] && let default_mirror_name_length+=$(echo "${tmp_mirror_name}" | grep -c "“")
[[ $(echo "${tmp_mirror_name}" | grep -c "”") -gt 0 ]] && let default_mirror_name_length+=$(echo "${tmp_mirror_name}" | grep -c "”")
[[ $(echo "${tmp_mirror_name}" | grep -c "") -gt 0 ]] && let default_mirror_name_length+=$(echo "${tmp_mirror_name}" | grep -c "")
[[ $(echo "${tmp_mirror_name}" | grep -c "") -gt 0 ]] && let default_mirror_name_length+=$(echo "${tmp_mirror_name}" | grep -c "")
tmp_mirror_name_length=$(StringLength $(echo "${tmp_mirror_name}" | sed "s| ||g" | sed "s|[0-9a-zA-Z\.\=\:\_\(\)\'\"-\/\!]||g;"))
## 填充空格
tmp_spaces_nums=$(($(($default_mirror_name_length - ${tmp_mirror_name_length} - $(StringLength "${tmp_mirror_name}"))) / 2))
for ((j = 1; j <= ${tmp_spaces_nums}; j++)); do
tmp_mirror_name="${tmp_mirror_name} "
done
printf " ❖ %-$(($default_mirror_name_length + ${tmp_mirror_name_length}))s %4s\n" "${tmp_mirror_name}" "$arr_num)"
done
else
for ((i = 0; i < ${#list_arr[@]}; i++)); do
tmp_mirror_name=$(echo ${list_arr[i]} | awk -F '@' '{print$1}') # 镜像站名称
tmp_mirror_url=$(echo ${list_arr[i]} | awk -F '@' '{print$2}') # 镜像站地址
arr_num=$((i + 1))
echo -e "$arr_num. ${tmp_mirror_url} | ${tmp_mirror_name}"
done
fi
}
## 选择镜像站内网地址
# 部分云计算厂商的镜像站区分外网(公网)地址和内网地址,内网地址仅面向云计算厂商云服务器用户使用
# 内网地址一般不支持使用 HTTPS 协议,所以默认设置为 HTTP 协议
function ChooseMirrorIntranetAddress() {
local CHOICE=$(echo -e "\n ${BOLD}└─ 默认使用镜像站的公网地址,是否继续? [Y/n] ${PLAIN}")
read -p "${CHOICE}" INPUT
[ -z ${INPUT} ] && INPUT=Y
case $INPUT in
[Yy] | [Yy][Ee][Ss])
SOURCE=${Extranet}
;;
[Yy] | [Yy][Ee][Ss]) ;;
[Nn] | [Nn][Oo])
SOURCE=${Intranet}
echo -e "\n $WARN 已切换至云计算厂商镜像站的内网访问地址,仅限对应厂商云服务器用户使用!"
ONLY_HTTP="True"
for ((i = 0; i < ${#mirror_list_extranet[@]}; i++)); do
if [[ "${SOURCE}" == "${mirror_list_extranet[i]}" ]]; then
# echo "${SOURCE}"
SOURCE="${mirror_list_intranet[i]}"
# echo "${SOURCE}"
# exit
echo -e "\n $WARN 已切换至内网专用地址,仅限在特定环境下使用!"
ONLY_HTTP="True"
break
else
continue
fi
done
;;
*)
SOURCE=${Extranet}
echo -e "\n$WARN 输入错误,默认使用网地址!"
echo -e "\n$WARN 输入错误,默认使用网地址!"
;;
esac
}
function WelcomeTitle() {
echo -e '+-------------------------------------+'
echo -e '| |'
echo -e '| 欢迎使用 Linux 一键更换国内软件源 |'
echo -e '| |'
echo -e '+-------------------------------------+'
local system_name="${SYSTEM_PRETTY_NAME:-"${SYSTEM_NAME} ${SYSTEM_VERSION_NUMBER}"}"
local arch="${SYSTEM_ARCH}"
local date="$(date "+%Y-%m-%d %H:%M:%S")"
local timezone="$(timedatectl status 2>/dev/null | grep "Time zone" | awk -F ':' '{print$2}' | awk -F ' ' '{print$1}')"
echo -e '+-----------------------------------------+'
echo -e '| |'
echo -e '| LinuxMirrors MIT |'
echo -e '| |'
echo -e '| 欢迎使用 GNU/Linux 一键更换软件源脚本 |'
echo -e '| |'
echo -e '+-----------------------------------------+'
echo -e ''
echo -e " 运行环境 ${BLUE}${SYSTEM_PRETTY_NAME:-"${SYSTEM_NAME} ${SYSTEM_VERSION_NUMBER}"} ${SYSTEM_ARCH}${PLAIN}"
echo -e " 系统时间 ${BLUE}$(date "+%Y-%m-%d %H:%M:%S") $(timedatectl status | grep "Time zone" | awk -F ':' '{print$2}' | awk -F ' ' '{print$1}')${PLAIN}"
echo -e " 运行环境 ${BLUE}${system_name} ${arch}${PLAIN}"
echo -e " 系统时间 ${BLUE}${date} ${timezone}${PLAIN}"
echo -e ''
}
clear
WelcomeTitle
if [ -z ${SOURCE} ]; then
local mirror_list_name="mirror_list_default"
PrintMirrorsList "${mirror_list_name}" 31
echo -e ' ❖ 阿里云 1)'
echo -e ' ❖ 腾讯云 2)'
echo -e ' ❖ 华为云 3)'
echo -e ' ❖ 网易 4)'
echo -e ' ❖ 搜狐 5)'
echo -e ' ❖ 清华大学 6)'
echo -e ' ❖ 北京大学 7)'
echo -e ' ❖ 浙江大学 8)'
echo -e ' ❖ 南京大学 9)'
echo -e ' ❖ 重庆大学 10)'
echo -e ' ❖ 兰州大学 11)'
echo -e ' ❖ 上海交通大学 12)'
echo -e ' ❖ 哈尔滨工业大学 13)'
echo -e ' ❖ 中国科学技术大学 14)'
echo -e ' ❖ 中国科学院软件研究所 15)'
local CHOICE=$(echo -e "\n${BOLD}└─ 请选择并输入你想使用的软件源 [ 1-15 ]${PLAIN}")
read -p "${CHOICE}" INPUT
case $INPUT in
1 | 2 | 3)
Cloud_Computing_Vendors_Mirrors $INPUT
;;
4)
SOURCE="mirrors.163.com"
;;
5)
SOURCE="mirrors.sohu.com"
;;
6)
SOURCE="mirrors.tuna.tsinghua.edu.cn"
;;
7)
SOURCE="mirrors.pku.edu.cn"
;;
8)
SOURCE="mirrors.zju.edu.cn"
;;
9)
SOURCE="mirrors.nju.edu.cn"
;;
10)
SOURCE="mirrors.cqu.edu.cn"
;;
11)
SOURCE="mirror.lzu.edu.cn"
;;
12)
SOURCE="mirror.sjtu.edu.cn"
;;
13)
SOURCE="mirrors.hit.edu.cn"
;;
14)
SOURCE="mirrors.ustc.edu.cn"
;;
15)
SOURCE="mirror.iscas.ac.cn"
;;
*)
SOURCE="mirrors.aliyun.com"
echo -e "\n$WARN 输入错误,将默认使用 ${BLUE}阿里云${PLAIN} 作为国内源!"
sleep 2s
;;
esac
local CHOICE=$(echo -e "\n${BOLD}└─ 请选择并输入你想使用的软件源 [ 1-$(eval echo \${#$mirror_list_name[@]}) ]${PLAIN}")
while true; do
read -p "${CHOICE}" INPUT
case $INPUT in
[1-9] | [1-9][0-9] | [1-9][0-9][0-9])
local tmp_source="$(eval echo \${${mirror_list_name}[$(($INPUT - 1))]})"
if [ -z $tmp_source ]; then
echo -e "\n$WARN 请输入有效的数字序号!"
else
SOURCE="$(eval echo \${${mirror_list_name}[$(($INPUT - 1))]} | awk -F '@' '{print$2}')"
# echo "${SOURCE}"
# exit
break
fi
;;
*)
echo -e "\n$WARN 请输入数字序号以选择你想使用的软件源!"
;;
esac
done
## 选择镜像站内网地址
if [[ "${mirror_list_extranet[*]}" =~ (^|[^[:alpha:]])"${SOURCE}"([^[:alpha:]]|$) ]]; then
ChooseMirrorIntranetAddress
fi
fi
}
## 选择同步软件源所使用的 WEB 协议( HTTP80 端口HTTPS443 端口)

View File

@@ -1,9 +1,8 @@
#!/bin/bash
## Author: SuperManito
## Modified: 2023-05-01
## License: GPL-2.0
## Modified: 2023-05-02
## License: MIT
## Github: https://github.com/SuperManito/LinuxMirrors
## Gitee: https://gitee.com/SuperManito/LinuxMirrors
function AuthorSignature() {
echo -e "\n$COMPLETE 脚本执行结束\n"
@@ -471,14 +470,19 @@ function ShowVersion() {
function ChooseMirrors() {
function WelcomeTitle() {
local system_name="${SYSTEM_PRETTY_NAME:-"${SYSTEM_NAME} ${SYSTEM_VERSION_NUMBER}"}"
local arch="${SYSTEM_ARCH}"
local date="$(date "+%Y-%m-%d %H:%M:%S")"
local timezone="$(timedatectl status 2>/dev/null | grep "Time zone" | awk -F ':' '{print$2}' | awk -F ' ' '{print$1}')"
echo -e '+------------------------------------+'
echo -e '| |'
echo -e '| 欢迎使用 Docker 一键安装脚本 |'
echo -e '| |'
echo -e '+------------------------------------+'
echo -e ''
echo -e " 运行环境 ${BLUE}${SYSTEM_PRETTY_NAME:-"${SYSTEM_NAME} ${SYSTEM_VERSION_NUMBER}"} ${SYSTEM_ARCH}${PLAIN}"
echo -e " 系统时间 ${BLUE}$(date "+%Y-%m-%d %H:%M:%S") $(timedatectl status | grep "Time zone" | awk -F ':' '{print$2}' | awk -F ' ' '{print$1}')${PLAIN}"
echo -e " 运行环境 ${BLUE}${system_name} ${arch}${PLAIN}"
echo -e " 系统时间 ${BLUE}${date} ${timezone}${PLAIN}"
echo -e ''
}
clear

352
LICENSE
View File

@@ -1,339 +1,21 @@
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
MIT License
Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Copyright (c) 2023 SuperManito
Preamble
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
License is intended to guarantee your freedom to share and change free
software--to make sure the software is free for all its users. This
General Public License applies to most of the Free Software
Foundation's software and to any other program whose authors commit to
using it. (Some other Free Software Foundation software is covered by
the GNU Lesser General Public License instead.) You can apply it to
your programs, too.
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
this service if you wish), that you receive source code or can get it
if you want it, that you can change the software or use pieces of it
in new free programs; and that you know you can do these things.
To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if you
distribute copies of the software, or if you modify it.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must give the recipients all the rights that
you have. You must make sure that they, too, receive or can get the
source code. And you must show them these terms so they know their
rights.
We protect your rights with two steps: (1) copyright the software, and
(2) offer you this license which gives you legal permission to copy,
distribute and/or modify the software.
Also, for each author's protection and ours, we want to make certain
that everyone understands that there is no warranty for this free
software. If the software is modified by someone else and passed on, we
want its recipients to know that what they have is not the original, so
that any problems introduced by others will not reflect on the original
authors' reputations.
Finally, any free program is threatened constantly by software
patents. We wish to avoid the danger that redistributors of a free
program will individually obtain patent licenses, in effect making the
program proprietary. To prevent this, we have made it clear that any
patent must be licensed for everyone's free use or not licensed at all.
The precise terms and conditions for copying, distribution and
modification follow.
GNU GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License applies to any program or other work which contains
a notice placed by the copyright holder saying it may be distributed
under the terms of this General Public License. The "Program", below,
refers to any such program or work, and a "work based on the Program"
means either the Program or any derivative work under copyright law:
that is to say, a work containing the Program or a portion of it,
either verbatim or with modifications and/or translated into another
language. (Hereinafter, translation is included without limitation in
the term "modification".) Each licensee is addressed as "you".
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running the Program is not restricted, and the output from the Program
is covered only if its contents constitute a work based on the
Program (independent of having been made by running the Program).
Whether that is true depends on what the Program does.
1. You may copy and distribute verbatim copies of the Program's
source code as you receive it, in any medium, provided that you
conspicuously and appropriately publish on each copy an appropriate
copyright notice and disclaimer of warranty; keep intact all the
notices that refer to this License and to the absence of any warranty;
and give any other recipients of the Program a copy of this License
along with the Program.
You may charge a fee for the physical act of transferring a copy, and
you may at your option offer warranty protection in exchange for a fee.
2. You may modify your copy or copies of the Program or any portion
of it, thus forming a work based on the Program, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) You must cause the modified files to carry prominent notices
stating that you changed the files and the date of any change.
b) You must cause any work that you distribute or publish, that in
whole or in part contains or is derived from the Program or any
part thereof, to be licensed as a whole at no charge to all third
parties under the terms of this License.
c) If the modified program normally reads commands interactively
when run, you must cause it, when started running for such
interactive use in the most ordinary way, to print or display an
announcement including an appropriate copyright notice and a
notice that there is no warranty (or else, saying that you provide
a warranty) and that users may redistribute the program under
these conditions, and telling the user how to view a copy of this
License. (Exception: if the Program itself is interactive but
does not normally print such an announcement, your work based on
the Program is not required to print an announcement.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Program,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Program, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Program.
In addition, mere aggregation of another work not based on the Program
with the Program (or with a work based on the Program) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may copy and distribute the Program (or a work based on it,
under Section 2) in object code or executable form under the terms of
Sections 1 and 2 above provided that you also do one of the following:
a) Accompany it with the complete corresponding machine-readable
source code, which must be distributed under the terms of Sections
1 and 2 above on a medium customarily used for software interchange; or,
b) Accompany it with a written offer, valid for at least three
years, to give any third party, for a charge no more than your
cost of physically performing source distribution, a complete
machine-readable copy of the corresponding source code, to be
distributed under the terms of Sections 1 and 2 above on a medium
customarily used for software interchange; or,
c) Accompany it with the information you received as to the offer
to distribute corresponding source code. (This alternative is
allowed only for noncommercial distribution and only if you
received the program in object code or executable form with such
an offer, in accord with Subsection b above.)
The source code for a work means the preferred form of the work for
making modifications to it. For an executable work, complete source
code means all the source code for all modules it contains, plus any
associated interface definition files, plus the scripts used to
control compilation and installation of the executable. However, as a
special exception, the source code distributed need not include
anything that is normally distributed (in either source or binary
form) with the major components (compiler, kernel, and so on) of the
operating system on which the executable runs, unless that component
itself accompanies the executable.
If distribution of executable or object code is made by offering
access to copy from a designated place, then offering equivalent
access to copy the source code from the same place counts as
distribution of the source code, even though third parties are not
compelled to copy the source along with the object code.
4. You may not copy, modify, sublicense, or distribute the Program
except as expressly provided under this License. Any attempt
otherwise to copy, modify, sublicense or distribute the Program is
void, and will automatically terminate your rights under this License.
However, parties who have received copies, or rights, from you under
this License will not have their licenses terminated so long as such
parties remain in full compliance.
5. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Program or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Program (or any work based on the
Program), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Program or works based on it.
6. Each time you redistribute the Program (or any work based on the
Program), the recipient automatically receives a license from the
original licensor to copy, distribute or modify the Program subject to
these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties to
this License.
7. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Program at all. For example, if a patent
license would not permit royalty-free redistribution of the Program by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Program.
If any portion of this section is held invalid or unenforceable under
any particular circumstance, the balance of the section is intended to
apply and the section as a whole is intended to apply in other
circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system, which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
8. If the distribution and/or use of the Program is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Program under this License
may add an explicit geographical distribution limitation excluding
those countries, so that distribution is permitted only in or among
countries not thus excluded. In such case, this License incorporates
the limitation as if written in the body of this License.
9. The Free Software Foundation may publish revised and/or new versions
of the General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the Program
specifies a version number of this License which applies to it and "any
later version", you have the option of following the terms and conditions
either of that version or of any later version published by the Free
Software Foundation. If the Program does not specify a version number of
this License, you may choose any version ever published by the Free Software
Foundation.
10. If you wish to incorporate parts of the Program into other free
programs whose distribution conditions are different, write to the author
to ask for permission. For software which is copyrighted by the Free
Software Foundation, write to the Free Software Foundation; we sometimes
make exceptions for this. Our decision will be guided by the two goals
of preserving the free status of all derivatives of our free software and
of promoting the sharing and reuse of software generally.
NO WARRANTY
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
REPAIR OR CORRECTION.
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
Also add information on how to contact you by electronic and paper mail.
If the program is interactive, make it output a short notice like this
when it starts in an interactive mode:
Gnomovision version 69, Copyright (C) year name of author
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, the commands you use may
be called something other than `show w' and `show c'; they could even be
mouse-clicks or menu items--whatever suits your program.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the program, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
`Gnomovision' (which makes passes at compilers) written by James Hacker.
<signature of Ty Coon>, 1 April 1989
Ty Coon, President of Vice
This General Public License does not permit incorporating your program into
proprietary programs. If your program is a subroutine library, you may
consider it more useful to permit linking proprietary applications with the
library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View File

@@ -1,8 +1,7 @@
# ![LinuxMirrors](./docs/img/logo.png)
- __GNU/Linux 一键更换国内软件源脚本__
- __GNU/Linux 一键更换系统软件源脚本__
- __本项目旨在为从事计算机相关行业的朋友们提供便利__
- __理论支持所有架构的环境ARM64 环境已经过测试__
***
@@ -14,11 +13,11 @@
</tr>
<tr>
<td><a href="https://www.debian.org" target="_blank"><img src="./docs/img/icon/debian.svg" width="16" height="16" style="vertical-align: -0.15em"/></a>&nbsp;Debian</td>
<td align="center">8.0 ~ 11</td>
<td align="center">8.0 ~ 12</td>
</tr>
<tr>
<td><a href="https://cn.ubuntu.com" target="_blank"><img src="./docs/img/icon/ubuntu.svg" width="16" height="16" style="vertical-align: -0.15em"/></a>&nbsp;Ubuntu</td>
<td align="center">16.04 ~ 23</td>
<td align="center">14.04 ~ 23</td>
</tr>
<tr>
<td><a href="https://www.kali.org" target="_blank"><img src="./docs/img/icon/kali.svg" width="16" height="16" style="vertical-align: -0.15em"/></a>&nbsp;Kali Linux</td>
@@ -54,7 +53,7 @@
</tr>
</table>
当前支持上述基于 Debian、RedHat、openEuler、openSUSE 的发行版和及其部分衍生版本,不此支持范围内的操作系统请勿运行本脚本
当前支持上述基于 Debian、RedHat、openEuler、openSUSE 的发行版和及其部分衍生版本(点击列表中的图标可快速前往其官网),理论支持所有架构的环境,不此支持范围内的操作系统或版本请勿运行本脚本
- ### 使用方法
@@ -65,42 +64,41 @@
- #### 注意事项
1. 完整复制上面的命令到终端按回车键即可执行,若无法安装 `curl` 软件包可复制源码到本地后通过 `bash` 手动执行
2. 为了适配所有环境,需要使用 `Root` 用户执行脚本,切换命令为 `su root` ,如遇报错请查看常见问题与帮助
2. 为了适配所有环境,需要使用 `Root` 用户执行脚本,切换命令为 `su root`,如遇报错请查看常见问题与帮助
3. 如果您使用的环境没有安装或不支持简体中文环境,请通过 `SSH客户端工具` 使用,否则将无法正确选择交互内容
4. 执行脚本过程中会自动备份原有源无需手动备份,期间会在终端输出多个主观选择交互内容,可按回车键快速确定
5. 脚本支持在原有源配置错误或者不存在的情况下使用,并且可以重复使用;脚本变更的软件源默认使用 `HTTP` 协议
</br>
> __未启用的源__
> _Debian 系 Linux 默认禁用了**源码仓库**和**预发布软件源**,若需启用请将 `/etc/apt/sources.list` 文件中相关内容的所在行**取消注释**_
> _RedHat 系 Linux 部分仓库**默认没有启用**,若需启用请将 `/etc/yum.repos.d` 目录下相关 **repo** 文件中的 `enabled` 值修改为 `1`_
> _openEuler 系 Linux 部分仓库**默认没有启用**,若需启用请将 `/etc/yum.repos.d` 目录下相关 **repo** 文件中的 `enabled` 值修改为 `1`_
> _openSUSE 系 Linux 部分仓库**默认没有启用**,若需启用请将 `/etc/zypp/repos.d` 目录下相关 **repo** 文件中的 `enabled` 值修改为 `1`_
> __未启用的软件__
> _Debian 系 Linux 默认禁用了源码仓库预发布软件源,若需启用请将 `/etc/apt/sources.list` 文件中相关内容的所在行取消注释_
> _RedHat/openEuler 系 Linux 部分仓库默认没有启用,若需启用请将 `/etc/yum.repos.d` 目录下相关 repo 文件中的 `enabled` 值修改为 `1`_
> _openSUSE 系 Linux 部分仓库默认没有启用,若需启用请将 `/etc/zypp/repos.d` 目录下相关 repo 文件中的 `enabled` 值修改为 `1`_
- #### 软件源
| | 镜像站名称 | 镜像站地址 | IPv6 | Kali Linux | Rocky Linux | Fedora | openEuler | openSUSE | EPEL |
| :---: | :---------------: | :------------------------------------------------------------------: | :---: | :--------: | :---------: | :----: | :-------: | :------: | :---: |
| 1 | 阿里云 | [mirrors.aliyun.com](https://mirrors.aliyun.com) | ✓ | ✓ | | ✓ | ✓ | ✓ | ✓ |
| 2 | 腾讯云 | [mirrors.tencent.com](https://mirrors.tencent.com) | ✓ | ✓ | ✓ | ✓ | | ✓ | ✓ |
| 3 | 华为云 | [mirrors.huaweicloud.com](https://mirrors.huaweicloud.com) | ✓ | ✓ | | ✓ | ✓ | ✓ | ✓ |
| 4 | 网易 | [mirrors.163.com](https://mirrors.163.com) | | | | ✓ | ✓ | | |
| 5 | 搜狐 | [mirrors.sohu.com](https://mirrors.sohu.com) | | | | ✓ | | ✓ | |
| 6 | 清华大学 | [mirrors.tuna.tsinghua.edu.cn](https://mirrors.tuna.tsinghua.edu.cn) | ✓ | ✓ | | ✓ | ✓ | ✓ | ✓ |
| 7 | 北京大学 | [mirrors.pku.edu.cn](https://mirrors.pku.edu.cn/Mirrors) | ✓ | | | | ✓ | ✓ | ✓ |
| 8 | 浙江大学 | [mirrors.zju.edu.cn](https://mirrors.zju.edu.cn) | | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
| 9 | 南京大学 | [mirrors.nju.edu.cn](https://mirrors.nju.edu.cn) | | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
| 10 | 重庆大学 | [mirrors.cqu.edu.cn](https://mirrors.cqu.edu.cn) | | ✓ | | ✓ | | ✓ | ✓ |
| 11 | 兰州大学 | [mirror.lzu.edu.cn](https://mirror.lzu.edu.cn) | ✓ | | | ✓ | ✓ | ✓ | ✓ |
| 12 | 上海交通大学 | [mirror.sjtu.edu.cn](https://mirror.sjtu.edu.cn) | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
| 13 | 哈尔滨工业大学 | [mirrors.hit.edu.cn](https://mirrors.hit.edu.cn) | ✓ | ✓ | | | ✓ | ✓ | ✓ |
| 14 | 中国科学技术大学 | [mirrors.ustc.edu.cn](https://mirrors.ustc.edu.cn) | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
| 15 | 中国科学院软件研究所 | [mirror.iscas.ac.cn](https://mirror.iscas.ac.cn) | | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
| | 镜像站名称 | 镜像站地址 | IPv6 | Kali | Rocky | Fedora | openEuler | openSUSE | EPEL |
| :---: | :---------------: | :------------------------------------------------------------------: | :--: | :--: | :---: | :----: | :-------: | :------: | :--: |
| 1 | 阿里云 | [mirrors.aliyun.com](https://mirrors.aliyun.com) | ✓ | ✓ | | ✓ | ✓ | ✓ | ✓ |
| 2 | 腾讯云 | [mirrors.tencent.com](https://mirrors.tencent.com) | ✓ | ✓ | ✓ | ✓ | | ✓ | ✓ |
| 3 | 华为云 | [mirrors.huaweicloud.com](https://mirrors.huaweicloud.com) | ✓ | ✓ | | ✓ | ✓ | ✓ | ✓ |
| 4 | 网易 | [mirrors.163.com](https://mirrors.163.com) | | | | ✓ | ✓ | | |
| 5 | 搜狐 | [mirrors.sohu.com](https://mirrors.sohu.com) | | | | ✓ | | ✓ | |
| 6 | 清华大学 | [mirrors.tuna.tsinghua.edu.cn](https://mirrors.tuna.tsinghua.edu.cn) | ✓ | ✓ | | ✓ | ✓ | ✓ | ✓ |
| 7 | 北京大学 | [mirrors.pku.edu.cn](https://mirrors.pku.edu.cn/Mirrors) | ✓ | | | | ✓ | ✓ | ✓ |
| 8 | 浙江大学 | [mirrors.zju.edu.cn](https://mirrors.zju.edu.cn) | | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
| 9 | 南京大学 | [mirrors.nju.edu.cn](https://mirrors.nju.edu.cn) | | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
| 10 | 重庆大学 | [mirrors.cqu.edu.cn](https://mirrors.cqu.edu.cn) | | ✓ | | ✓ | | ✓ | ✓ |
| 11 | 兰州大学 | [mirror.lzu.edu.cn](https://mirror.lzu.edu.cn) | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
| 12 | 上海交通大学 | [mirror.sjtu.edu.cn](https://mirror.sjtu.edu.cn) | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
| 13 | 哈尔滨工业大学 | [mirrors.hit.edu.cn](https://mirrors.hit.edu.cn) | ✓ | ✓ | | | ✓ | ✓ | ✓ |
| 14 | 中国科学技术大学 | [mirrors.ustc.edu.cn](https://mirrors.ustc.edu.cn) | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
| 15 | 中国科学院软件研究所 | [mirror.iscas.ac.cn](https://mirror.iscas.ac.cn) | | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
以上为脚本当前使用的开源镜像站,所有镜像站均支持 `Debian` `Ubuntu` `CentOS` 软件源
以上为脚本默认使用的镜像站,上述所有镜像站均支持 `Debian` `Ubuntu` `CentOS` 软件源,列表根据单位性质、地理位置、名称长度进行排序,与实际速度无关
华北地区建议优先使用 `中科大`、`腾讯云`、`清华大学`,软件源的速度区分刷新速度和下载速度,具体请结合实际地理位置进行选择尝试
如果使用过程中脚本不能正常输出中文内容则可对照此列表使用,顺序与脚本一致,之后一路回车即可
华北地区建议优先使用 `中科大`、`腾讯云`、`清华大学`,软件源的速度区分刷新速度和下载速度,具体请结合实际地理位置进行选择尝试
- #### 常见问题与帮助
@@ -140,13 +138,13 @@
- #### 脚本执行流程
- └ 选择国内源 `交互`
- └ 检测如果是 RHEL或CentOS 系统选择是否安装/覆盖 EPEL 扩展国内源 `交互`
- └ 选择软件源 `交互`
- └ 检测如果是红帽系Linux选择是否安装/覆盖 EPEL 扩展软件源 `交互`
- └ 选择软件源使用的 WEB 协议 `交互`
- └ 检测 防火墙 和 SELINUX 如果开启并且系统是 RHEL或CentOS 选择是否关闭 `交互`
- └ 备份原有源
- └ 检测如果存在重复的备份文件选择是否覆盖 `交互`
- └ 更换国内
- └ 更换软件
- └ 选择是否更新软件包 `交互`
- └ 选择是否清理已下载的软件包缓存 `交互`
@@ -164,15 +162,15 @@
`Docker Hub` Docker Hub 镜像仓库,默认为官方提供的公共库,用于切换下载镜像时的来源仓库,又称镜像加速器
> __注意__
> 脚本集成安装 `Docker Engine`,可手动选择安装版本和下载源,还可手动选择镜像加速器,支持内外服务器环境和 `ARM`架构处理器环境使用。
> 脚本集成安装 `Docker Engine`,可手动选择安装版本和下载源,还可手动选择镜像加速器,支持内外服务器环境和 `ARM`架构处理器环境使用。
***
### LICENSE
Copyright © 2023, [SuperManito](https://github.com/SuperManito). Released under the [GPL-2.0](https://github.com/SuperManito/LinuxMirrors/blob/main/LICENSE).
Copyright © 2023, [SuperManito](https://github.com/SuperManito). Released under the [MIT](https://github.com/SuperManito/LinuxMirrors/blob/main/LICENSE).
项目已设立开源许可协议,传播时在显著位置标注来源和作者,请尊重作者的知识成果
建议通过命令直接调用脚本,如有意见与建议您可以提交至 [Issues](https://github.com/SuperManito/LinuxMirrors/issues)
项目已设立开源许可协议,传播时在显著位置标注来源和作者,请尊重作者的知识成果,建议通过命令直接调用脚本
如有意见与建议您可以提交至 [Issues](https://github.com/SuperManito/LinuxMirrors/issues),如果您需要提交您的代码,请前往 GitHub 仓库提交 [Pull Requests](https://github.com/SuperManito/LinuxMirrors/pulls)
__如果您觉得这个项目不错对您有所帮助的话方便在右上角给颗 ⭐ 并分享给更多的朋友吗__

View File

@@ -1,8 +1,7 @@
![](./img/logo.png)
- #### __GNU/Linux 一键更换国内软件源脚本__ <!-- {docsify-ignore} -->
- #### __GNU/Linux 一键更换系统软件源脚本__ <!-- {docsify-ignore} -->
- #### __本项目旨在为从事计算机相关行业的朋友们提供便利__ <!-- {docsify-ignore} -->
- #### __理论支持所有架构的环境ARM64 环境已经过测试__ <!-- {docsify-ignore} -->
## :fa-brands fa-linux: 适配系统
@@ -12,11 +11,11 @@
</tr>
<tr>
<td><a href="https://www.debian.org" target="_blank"><img src="./img/icon/debian.svg" width="16" height="16" style="vertical-align: -0.15em"/></a>&nbsp;Debian</td>
<td align="center">8.0 ~ 11</td>
<td align="center">8.0 ~ 12</td>
</tr>
<tr>
<td><a href="https://cn.ubuntu.com" target="_blank"><img src="./img/icon/ubuntu.svg" width="16" height="16" style="vertical-align: -0.15em"/></a>&nbsp;Ubuntu</td>
<td align="center">16.04 ~ 23</td>
<td align="center">14.04 ~ 23</td>
</tr>
<tr>
<td><a href="https://www.kali.org" target="_blank"><img src="./img/icon/kali.svg" width="16" height="16" style="vertical-align: -0.15em"/></a>&nbsp;Kali Linux</td>
@@ -53,7 +52,7 @@
</table>
> [!NOTE|label:说明]
> 当前支持上述基于 Debian、RedHat、openEuler、openSUSE 的发行版和及其部分衍生版本,不此支持范围内的操作系统请勿运行本脚本
> 当前支持上述基于 Debian、RedHat、openEuler、openSUSE 的发行版和及其部分衍生版本(点击列表中的图标可快速前往其官网),理论支持所有架构的环境,不此支持范围内的操作系统或版本请勿运行本脚本
## <i class="fa-solid fa-wheelchair-move fa-bounce" style=" --fa-bounce-start-scale-x: 1; --fa-bounce-start-scale-y: 1; --fa-bounce-jump-scale-x: 1; --fa-bounce-jump-scale-y: 1; --fa-bounce-land-scale-x: 1; --fa-bounce-land-scale-y: 1; " ></i> 使用方法
@@ -64,38 +63,37 @@ bash <(curl -sSL https://gitee.com/SuperManito/LinuxMirrors/raw/main/ChangeMirro
- ### 注意事项
1. 完整复制上面的命令到终端按回车键即可执行,若无法安装 `curl` 软件包可复制源码到本地后通过 `bash` 手动执行
2. 为了适配所有环境,需要使用 `Root` 用户执行脚本,切换命令为 `su root` ,如遇报错请查看常见问题与帮助
2. 为了适配所有环境,需要使用 `Root` 用户执行脚本,切换命令为 `su root`,如遇报错请查看常见问题与帮助
3. 如果您使用的环境没有安装或不支持简体中文环境,请通过 `SSH客户端工具` 使用,否则将无法正确选择交互内容
4. 执行脚本过程中会自动备份原有源无需手动备份,期间会在终端输出多个主观选择交互内容,可按回车键快速确定
5. 脚本支持在原有源配置错误或者不存在的情况下使用,并且可以重复使用;脚本变更的软件源默认使用 `HTTP` 协议
> [!WARNING|label:未启用的源]
> **Debian** 系 Linux 默认禁用了**源码仓库**和**预发布软件源**,若需启用请将 `/etc/apt/sources.list` 文件中相关内容的所在行**取消注释**
> **RedHat** 系 Linux 部分仓库**默认没有启用**,若需启用请将 `/etc/yum.repos.d` 目录下相关 **repo** 文件中的 `enabled` 值修改为 `1`
> **openEuler** 系 Linux 部分仓库**默认没有启用**,若需启用请将 `/etc/yum.repos.d` 目录下相关 **repo** 文件中的 `enabled` 值修改为 `1`
> **openSUSE** 系 Linux 部分仓库**默认没有启用**,若需启用请将 `/etc/zypp/repos.d` 目录下相关 **repo** 文件中的 `enabled` 值修改为 `1`
> [!WARNING|label:未启用的软件源]
> - **Debian** 系 Linux 默认禁用了源码仓库预发布软件源,若需启用请将 `/etc/apt/sources.list` 文件中相关内容的所在行取消注释
> - **RedHat**/**openEuler** 系 Linux 部分仓库默认没有启用,若需启用请将 `/etc/yum.repos.d` 目录下相关 **repo** 文件中的 `enabled` 值修改为 `1`
> - **openSUSE** 系 Linux 部分仓库默认没有启用,若需启用请将 `/etc/zypp/repos.d` 目录下相关 **repo** 文件中的 `enabled` 值修改为 `1`
- ### <i class="fa-solid fa-list-ol fa-fade" style="--fa-animation-duration: 2s; --fa-fade-opacity: 0.6;" ></i> 软件源
| | 镜像站名称 | 镜像站地址 | IPv6 | Kali Linux | Rocky Linux | Fedora | openEuler | openSUSE | EPEL |
| :---: | :---------------: | :------------------------------------------------------------------: | :---: | :--------: | :---------: | :----: | :-------: | :------: | :---: |
| 1 | 阿里云 | [mirrors.aliyun.com](https://mirrors.aliyun.com) | ✓ | ✓ | | ✓ | ✓ | ✓ | ✓ |
| 2 | 腾讯云 | [mirrors.tencent.com](https://mirrors.tencent.com) | ✓ | ✓ | ✓ | ✓ | | ✓ | ✓ |
| 3 | 华为云 | [mirrors.huaweicloud.com](https://mirrors.huaweicloud.com) | ✓ | ✓ | | ✓ | ✓ | ✓ | ✓ |
| 4 | 网易 | [mirrors.163.com](https://mirrors.163.com) | | | | ✓ | ✓ | | |
| 5 | 搜狐 | [mirrors.sohu.com](https://mirrors.sohu.com) | | | | ✓ | | ✓ | |
| 6 | 清华大学 | [mirrors.tuna.tsinghua.edu.cn](https://mirrors.tuna.tsinghua.edu.cn) | ✓ | ✓ | | ✓ | ✓ | ✓ | ✓ |
| 7 | 北京大学 | [mirrors.pku.edu.cn](https://mirrors.pku.edu.cn/Mirrors) | ✓ | | | | ✓ | ✓ | ✓ |
| 8 | 浙江大学 | [mirrors.zju.edu.cn](https://mirrors.zju.edu.cn) | | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
| 9 | 南京大学 | [mirrors.nju.edu.cn](https://mirrors.nju.edu.cn) | | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
| 10 | 重庆大学 | [mirrors.cqu.edu.cn](https://mirrors.cqu.edu.cn) | | ✓ | | ✓ | | ✓ | ✓ |
| 11 | 兰州大学 | [mirror.lzu.edu.cn](https://mirror.lzu.edu.cn) | ✓ | | | ✓ | ✓ | ✓ | ✓ |
| 12 | 上海交通大学 | [mirror.sjtu.edu.cn](https://mirror.sjtu.edu.cn) | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
| 13 | 哈尔滨工业大学 | [mirrors.hit.edu.cn](https://mirrors.hit.edu.cn) | ✓ | ✓ | | | ✓ | ✓ | ✓ |
| 14 | 中国科学技术大学 | [mirrors.ustc.edu.cn](https://mirrors.ustc.edu.cn) | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
| 15 | 中国科学院软件研究所 | [mirror.iscas.ac.cn](https://mirror.iscas.ac.cn) | | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
| | 镜像站名称 | 镜像站地址 | IPv6 | Kali | Rocky | Fedora | openEuler | openSUSE | EPEL |
| :---: | :---------------: | :------------------------------------------------------------------: | :--: | :--: | :---: | :----: | :-------: | :------: | :--: |
| 1 | 阿里云 | [mirrors.aliyun.com](https://mirrors.aliyun.com) | ✓ | ✓ | | ✓ | ✓ | ✓ | ✓ |
| 2 | 腾讯云 | [mirrors.tencent.com](https://mirrors.tencent.com) | ✓ | ✓ | ✓ | ✓ | | ✓ | ✓ |
| 3 | 华为云 | [mirrors.huaweicloud.com](https://mirrors.huaweicloud.com) | ✓ | ✓ | | ✓ | ✓ | ✓ | ✓ |
| 4 | 网易 | [mirrors.163.com](https://mirrors.163.com) | | | | ✓ | ✓ | | |
| 5 | 搜狐 | [mirrors.sohu.com](https://mirrors.sohu.com) | | | | ✓ | | ✓ | |
| 6 | 清华大学 | [mirrors.tuna.tsinghua.edu.cn](https://mirrors.tuna.tsinghua.edu.cn) | ✓ | ✓ | | ✓ | ✓ | ✓ | ✓ |
| 7 | 北京大学 | [mirrors.pku.edu.cn](https://mirrors.pku.edu.cn/Mirrors) | ✓ | | | | ✓ | ✓ | ✓ |
| 8 | 浙江大学 | [mirrors.zju.edu.cn](https://mirrors.zju.edu.cn) | | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
| 9 | 南京大学 | [mirrors.nju.edu.cn](https://mirrors.nju.edu.cn) | | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
| 10 | 重庆大学 | [mirrors.cqu.edu.cn](https://mirrors.cqu.edu.cn) | | ✓ | | ✓ | | ✓ | ✓ |
| 11 | 兰州大学 | [mirror.lzu.edu.cn](https://mirror.lzu.edu.cn) | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
| 12 | 上海交通大学 | [mirror.sjtu.edu.cn](https://mirror.sjtu.edu.cn) | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
| 13 | 哈尔滨工业大学 | [mirrors.hit.edu.cn](https://mirrors.hit.edu.cn) | ✓ | ✓ | | | ✓ | ✓ | ✓ |
| 14 | 中国科学技术大学 | [mirrors.ustc.edu.cn](https://mirrors.ustc.edu.cn) | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
| 15 | 中国科学院软件研究所 | [mirror.iscas.ac.cn](https://mirror.iscas.ac.cn) | | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
以上为脚本当前使用的开源镜像站,所有镜像站均支持 `Debian` `Ubuntu` `CentOS` 软件源
以上为脚本默认使用的镜像站,上述所有镜像站均支持 `Debian` `Ubuntu` `CentOS` 软件源,列表根据单位性质、地理位置、名称长度进行排序,与实际速度无关
华北地区建议优先使用 `中科大``腾讯云``清华大学`,软件源的速度区分刷新速度和下载速度,具体请结合实际地理位置进行选择尝试
> [!TIP]
@@ -139,13 +137,13 @@ bash <(curl -sSL https://gitee.com/SuperManito/LinuxMirrors/raw/main/ChangeMirro
- ### <i class="fa-regular fa-list-tree fa-fade" style="--fa-animation-duration: 2s; --fa-fade-opacity: 0.6;" ></i> 脚本执行流程
- └ 选择国内源 `交互`
- └ 检测如果是 RHEL或CentOS 系统选择是否安装/覆盖 EPEL 扩展国内源 `交互`
- └ 选择软件源 `交互`
- └ 检测如果是 RHEL或CentOS 系统选择是否安装/覆盖 EPEL 扩展软件源 `交互`
- └ 选择软件源使用的 WEB 协议 `交互`
- └ 检测 防火墙 和 SELINUX 如果开启并且系统是 RHEL或CentOS 选择是否关闭 `交互`
- └ 备份原有源
- └ 检测如果存在重复的备份文件选择是否覆盖 `交互`
- └ 更换国内
- └ 更换软件
- └ 选择是否更新软件包 `交互`
- └ 选择是否清理已下载的软件包缓存 `交互`
@@ -161,9 +159,11 @@ bash <(curl -sSL https://gitee.com/SuperManito/LinuxMirrors/raw/main/ChangeMirro
> `Docker CE` Docker Community Edition 镜像仓库,用于下载并安装 Docker 相关软件包。
> `Docker Hub` Docker Hub 镜像仓库,默认为官方提供的公共库,用于切换下载镜像时的来源仓库,又称镜像加速器。
脚本集成安装 `Docker Engine`,可手动选择安装版本、下载源、镜像加速器,支持内外服务器环境和 `ARM` 架构处理器环境使用
脚本集成安装 `Docker Engine`,可手动选择安装版本、下载源、镜像加速器,支持内外服务器环境和 `ARM` 架构处理器环境使用
***
项目已设立开源许可协议,传播时在显著位置标注来源和作者,请尊重作者的知识成果
建议通过命令直接调用脚本,如有意见与建议您可以提交至 [Issues](https://github.com/SuperManito/LinuxMirrors/issues)
项目已设立开源许可协议,传播时在显著位置标注来源和作者,请尊重作者的知识成果,建议通过命令直接调用脚本
如有意见与建议您可以提交至 [Issues](https://github.com/SuperManito/LinuxMirrors/issues),如果您需要提交您的代码,请前往 GitHub 仓库提交 [Pull Requests](https://github.com/SuperManito/LinuxMirrors/pulls)
***

View File

@@ -1,5 +1,6 @@
# ![LinuxMirrors](./img/logo.png)
<img src="./img/logo.png"/>
</br>
</br>
<div style="color: black"><strong>脚本一键更换 Linux 软件源</strong></br><strong>让换源更简单</strong></div>
<a href="https://github.com/SuperManito/LinuxMirrors"><img src="./img/icon/github-1.svg" width="34" height="42"></a>

View File

@@ -62,7 +62,7 @@
footer: {
style: 'text-align: center; font-size: 16px; line-height: 1.5; margin-top: 1.5em; color: var(--sidebarSublinkColor)',
copy: 'Copyright 2021 ~ 2023 <i class="fa-regular fa-copyright"></i><a href="https://github.com/SuperManito" target="_blank"> SuperManito</a></br>',
auth: 'Released under the <a href="https://github.com/SuperManito/LinuxMirrors/blob/main/LICENSE" target="_blank">GPL-2.0</a> . Website built with <a href="https://docsify.js.org" target="_blank" rel="noreferrer" rel="noopener">Docsify</a>'
auth: 'Released under the <a href="https://github.com/SuperManito/LinuxMirrors/blob/main/LICENSE" target="_blank">MIT</a> . Website built with <a href="https://docsify.js.org" target="_blank" rel="noreferrer" rel="noopener">Docsify</a>'
},
// 选项卡