新增适配 Gentoo 操作系统

This commit is contained in:
SuperManito
2024-07-31 21:30:10 +08:00
parent 91e9262f67
commit 74cb06dc3f
10 changed files with 303 additions and 153 deletions

View File

@@ -1,6 +1,6 @@
#!/bin/bash #!/bin/bash
## Author: SuperManito ## Author: SuperManito
## Modified: 2024-07-27 ## Modified: 2024-07-31
## License: MIT ## License: MIT
## GitHub: https://github.com/SuperManito/LinuxMirrors ## GitHub: https://github.com/SuperManito/LinuxMirrors
## Website: https://linuxmirrors.cn ## Website: https://linuxmirrors.cn
@@ -165,6 +165,7 @@ SYSTEM_OPENEULER="openEuler"
SYSTEM_OPENSUSE="openSUSE" SYSTEM_OPENSUSE="openSUSE"
SYSTEM_ARCH="Arch" SYSTEM_ARCH="Arch"
SYSTEM_ALPINE="Alpine" SYSTEM_ALPINE="Alpine"
SYSTEM_GENTOO="Gentoo"
## 定义系统版本文件 ## 定义系统版本文件
File_LinuxRelease=/etc/os-release File_LinuxRelease=/etc/os-release
@@ -175,6 +176,7 @@ File_OpenCloudOSRelease=/etc/opencloudos-release
File_openEulerRelease=/etc/openEuler-release File_openEulerRelease=/etc/openEuler-release
File_ArchLinuxRelease=/etc/arch-release File_ArchLinuxRelease=/etc/arch-release
File_AlpineRelease=/etc/alpine-release File_AlpineRelease=/etc/alpine-release
File_GentooRelease=/etc/gentoo-release
File_ProxmoxVersion=/etc/pve/.version File_ProxmoxVersion=/etc/pve/.version
## 定义软件源相关文件或目录 ## 定义软件源相关文件或目录
@@ -190,12 +192,17 @@ File_ProxmoxSourceList=/etc/apt/sources.list.d/pve-no-subscription.list
File_ProxmoxSourceListBackup=/etc/apt/sources.list.d/pve-no-subscription.list.bak File_ProxmoxSourceListBackup=/etc/apt/sources.list.d/pve-no-subscription.list.bak
File_LinuxMintSourceList=/etc/apt/sources.list.d/official-package-repositories.list File_LinuxMintSourceList=/etc/apt/sources.list.d/official-package-repositories.list
File_LinuxMintSourceListBackup=/etc/apt/sources.list.d/official-package-repositories.list.bak File_LinuxMintSourceListBackup=/etc/apt/sources.list.d/official-package-repositories.list.bak
Dir_DebianExtendSource=/etc/apt/sources.list.d
Dir_DebianExtendSourceBackup=/etc/apt/sources.list.d.bak
File_ArchLinuxMirrorList=/etc/pacman.d/mirrorlist File_ArchLinuxMirrorList=/etc/pacman.d/mirrorlist
File_ArchLinuxMirrorListBackup=/etc/pacman.d/mirrorlist.bak File_ArchLinuxMirrorListBackup=/etc/pacman.d/mirrorlist.bak
File_AlpineRepositories=/etc/apk/repositories File_AlpineRepositories=/etc/apk/repositories
File_AlpineRepositoriesBackup=/etc/apk/repositories.bak File_AlpineRepositoriesBackup=/etc/apk/repositories.bak
File_GentooMakeConf=/etc/portage/make.conf
File_GentooMakeConfBackup=/etc/portage/make.conf.bak
File_GentooReposConf=/etc/portage/repos.conf/gentoo.conf
File_GentooReposConfBackup=/etc/portage/repos.conf/gentoo.conf.bak
Dir_GentooReposConf=/etc/portage/repos.conf
Dir_DebianExtendSource=/etc/apt/sources.list.d
Dir_DebianExtendSourceBackup=/etc/apt/sources.list.d.bak
Dir_YumRepos=/etc/yum.repos.d Dir_YumRepos=/etc/yum.repos.d
Dir_YumReposBackup=/etc/yum.repos.d.bak Dir_YumReposBackup=/etc/yum.repos.d.bak
Dir_openSUSERepos=/etc/zypp/repos.d Dir_openSUSERepos=/etc/zypp/repos.d
@@ -238,32 +245,34 @@ function main() {
function handle_command_options() { function handle_command_options() {
## 命令帮助 ## 命令帮助
function output_command_help() { function output_command_help() {
echo -e " echo -e "\n命令选项(参数名/含义/参数值)
命令选项(参数名/含义/参数值)
--abroad 使用海外软件源 无 --abroad 使用海外软件源 无
--edu 使用中国大陆教育网软件源 无 --edu 使用中国大陆教育网软件源 无
--source 指定软件源地址 地址 --source 指定软件源地址(域名或IP) 地址
--source-security 指定 Debian 的 security 软件源地址 地址 --source-epel 指定 EPEL 附加软件包仓库的软件源地址(域名或IP) 地址
--source-vault 指定 CentOS/AlmaLinux 的 vault 软件源地址 地址 --source-security 指定 Debian 系统 security 仓库的软件源地址(域名或IP) 地址
--use-official-source 使用操作系统官方软件源 --source-vault 指定 CentOS/AlmaLinux 系统 vault 仓库的软件源地址(域名或IP) 地址
--source-portage 指定 Gentoo 系统 portage 仓库的软件源地址(域名或IP) 地址
--branch 指定软件源分支(路径) 分支名 --branch 指定软件源分支(路径) 分支名
--branch-security 指定 Debian 的 security 软件源分支(路径) 分支名 --branch-epel 指定 EPEL 附加软件包仓库的软件源分支(路径) 分支名
--branch-vault 指定 CentOS/AlmaLinux 的 vault 软件源分支(路径) 分支名 --branch-security 指定 Debian 系统 security 仓库的软件源分支(路径) 分支名
--branch-vault 指定 CentOS/AlmaLinux 系统 vault 仓库的软件源分支(路径) 分支名
--branch-portage 指定 Gentoo 系统 portage 仓库的软件源分支(路径) 分支名
--codename 指定 Debian 系操作系统的版本代号 代号名称 --codename 指定 Debian 系操作系统的版本代号 代号名称
--protocol 指定 WEB 协议 http 或 https --protocol 指定 WEB 协议 http 或 https
--intranet 优先使用内网地址 true 或 false --install-epel 是否安装 EPEL 附加软件包 true 或 false
--install-epel 安装 EPEL 附加软件包 true 或 false --close-firewall 是否关闭防火墙 true 或 false
--backup 是否备份原有软件源 true 或 false
--upgrade-software 是否更新软件包 true 或 false
--clean-cache 是否清理下载缓存 true 或 false
--use-intranet-source 优先使用内网软件源地址 无
--use-official-source 使用目标操作系统的官方软件源 无
--only-epel 仅更换 EPEL 软件源模式 无 --only-epel 仅更换 EPEL 软件源模式 无
--close-firewall 关闭防火墙 true 或 false
--backup 备份原有软件源 true 或 false
--ignore-backup-tips 忽略覆盖备份提示 无 --ignore-backup-tips 忽略覆盖备份提示 无
--upgrade-software 更新软件包 true 或 false
--clean-cache 清理下载缓存 true 或 false
--print-diff 打印源文件修改前后差异 无 --print-diff 打印源文件修改前后差异 无
问题报告 https://github.com/SuperManito/LinuxMirrors/issues 问题报告 https://github.com/SuperManito/LinuxMirrors/issues\n"
"
} }
## 判断参数 ## 判断参数
@@ -291,6 +300,19 @@ function handle_command_options() {
output_error "检测到 ${BLUE}$1${PLAIN} 为无效参数,请在该参数后指定软件源地址!" output_error "检测到 ${BLUE}$1${PLAIN} 为无效参数,请在该参数后指定软件源地址!"
fi fi
;; ;;
--source-epel)
if [ "$2" ]; then
echo "$2" | grep -Eq "\(|\)|\[|\]|\{|\}"
if [ $? -eq 0 ]; then
output_error "检测到无效参数值 ${BLUE}$2${PLAIN} ,请输入有效的地址!"
else
SOURCE_EPEL="$(echo "$2" | sed -e 's,^http[s]\?://,,g' -e 's,/$,,')"
shift
fi
else
output_error "检测到 ${BLUE}$1${PLAIN} 为无效参数,请在该参数后指定软件源地址!"
fi
;;
--source-security) --source-security)
if [ "$2" ]; then if [ "$2" ]; then
echo "$2" | grep -Eq "\(|\)|\[|\]|\{|\}" echo "$2" | grep -Eq "\(|\)|\[|\]|\{|\}"
@@ -317,6 +339,19 @@ function handle_command_options() {
output_error "检测到 ${BLUE}$1${PLAIN} 为无效参数,请在该参数后指定软件源地址!" output_error "检测到 ${BLUE}$1${PLAIN} 为无效参数,请在该参数后指定软件源地址!"
fi fi
;; ;;
--source-portage)
if [ "$2" ]; then
echo "$2" | grep -Eq "\(|\)|\[|\]|\{|\}"
if [ $? -eq 0 ]; then
output_error "检测到无效参数值 ${BLUE}$2${PLAIN} ,请输入有效的地址!"
else
SOURCE_PORTAGE="$(echo "$2" | sed -e 's,^http[s]\?://,,g' -e 's,/$,,')"
shift
fi
else
output_error "检测到 ${BLUE}$1${PLAIN} 为无效参数,请在该参数后指定软件源地址!"
fi
;;
## 使用官方源 ## 使用官方源
--use-official-source) --use-official-source)
USE_OFFICIAL_SOURCE="true" USE_OFFICIAL_SOURCE="true"
@@ -330,9 +365,17 @@ function handle_command_options() {
output_error "检测到 ${BLUE}$1${PLAIN} 为无效参数,请在该参数后指定软件源地址!" output_error "检测到 ${BLUE}$1${PLAIN} 为无效参数,请在该参数后指定软件源地址!"
fi fi
;; ;;
--branch-epel)
if [ "$2" ]; then
SOURCE_EPEL_BRANCH="$2"
shift
else
output_error "检测到 ${BLUE}$1${PLAIN} 为无效参数,请在该参数后指定软件源地址!"
fi
;;
--branch-security) --branch-security)
if [ "$2" ]; then if [ "$2" ]; then
SOURCE_BRANCH_SECURITY="$2" SOURCE_SECURITY_BRANCH="$2"
shift shift
else else
output_error "检测到 ${BLUE}$1${PLAIN} 为无效参数,请在该参数后指定软件源地址!" output_error "检测到 ${BLUE}$1${PLAIN} 为无效参数,请在该参数后指定软件源地址!"
@@ -340,7 +383,15 @@ function handle_command_options() {
;; ;;
--branch-vault) --branch-vault)
if [ "$2" ]; then if [ "$2" ]; then
SOURCE_BRANCH_VAULT="$2" SOURCE_VAULT_BRANCH="$2"
shift
else
output_error "检测到 ${BLUE}$1${PLAIN} 为无效参数,请在该参数后指定软件源地址!"
fi
;;
--branch-portage)
if [ "$2" ]; then
SOURCE_PORTAGE_BRANCH="$2"
shift shift
else else
output_error "检测到 ${BLUE}$1${PLAIN} 为无效参数,请在该参数后指定软件源地址!" output_error "检测到 ${BLUE}$1${PLAIN} 为无效参数,请在该参数后指定软件源地址!"
@@ -356,7 +407,11 @@ function handle_command_options() {
fi fi
;; ;;
## 优先使用内网地址 ## 优先使用内网地址
--use-intranet-source)
USE_INTRANET_SOURCE="true"
;;
--intranet) --intranet)
## 废弃的命令选项
if [ "$2" ]; then if [ "$2" ]; then
case "$2" in case "$2" in
[Tt]rue | [Ff]alse) [Tt]rue | [Ff]alse)
@@ -543,6 +598,8 @@ function collect_system_info() {
SYSTEM_FACTIONS="${SYSTEM_ARCH}" SYSTEM_FACTIONS="${SYSTEM_ARCH}"
elif [ -f $File_AlpineRelease ]; then elif [ -f $File_AlpineRelease ]; then
SYSTEM_FACTIONS="${SYSTEM_ALPINE}" SYSTEM_FACTIONS="${SYSTEM_ALPINE}"
elif [ -f $File_GentooRelease ]; then
SYSTEM_FACTIONS="${SYSTEM_GENTOO}"
elif [ -s $File_RedHatRelease ]; then elif [ -s $File_RedHatRelease ]; then
SYSTEM_FACTIONS="${SYSTEM_REDHAT}" SYSTEM_FACTIONS="${SYSTEM_REDHAT}"
elif [ -s $File_OpenCloudOSRelease ]; then elif [ -s $File_OpenCloudOSRelease ]; then
@@ -632,7 +689,7 @@ function collect_system_info() {
;; ;;
esac esac
;; ;;
"${SYSTEM_KALI}" | "${SYSTEM_DEEPIN}" | "${SYSTEM_ARCH}" | "${SYSTEM_ALPINE}") "${SYSTEM_KALI}" | "${SYSTEM_DEEPIN}" | "${SYSTEM_ARCH}" | "${SYSTEM_ALPINE}" | "${SYSTEM_GENTOO}")
# 理论全部支持或不作判断 # 理论全部支持或不作判断
;; ;;
*) *)
@@ -739,7 +796,7 @@ function collect_system_info() {
"${SYSTEM_OPENSUSE}") "${SYSTEM_OPENSUSE}")
SYNC_MIRROR_TEXT="刷新软件源" SYNC_MIRROR_TEXT="刷新软件源"
;; ;;
"${SYSTEM_ARCH}") "${SYSTEM_ARCH}" | "${SYSTEM_GENTOO}")
SYNC_MIRROR_TEXT="同步软件源" SYNC_MIRROR_TEXT="同步软件源"
;; ;;
esac esac
@@ -750,18 +807,31 @@ function check_command_options() {
if [[ "${USE_ABROAD_SOURCE}" == "true" && "${USE_EDU_SOURCE}" == "true" ]]; then if [[ "${USE_ABROAD_SOURCE}" == "true" && "${USE_EDU_SOURCE}" == "true" ]]; then
output_error "两种模式不可同时使用!" output_error "两种模式不可同时使用!"
fi fi
if [[ "${SYSTEM_JUDGMENT}" != "${SYSTEM_DEBIAN}" ]] && [[ "${SOURCE_SECURITY}" == "true" || "${SOURCE_BRANCH_SECURITY}" == "true" ]]; then if [[ "${DEBIAN_CODENAME}" ]]; then
output_error "当前系统不支持使用 security 仓库相关命令选项,请确认后重试!" if [[ "${SYSTEM_FACTIONS}" != "${SYSTEM_DEBIAN}" ]]; then
fi
if [[ "${SYSTEM_FACTIONS}" != "${SYSTEM_DEBIAN}" ]] && [[ "${DEBIAN_CODENAME}" ]]; then
output_error "当前系统不支持使用指定版本代号命令选项,请确认后重试!" output_error "当前系统不支持使用指定版本代号命令选项,请确认后重试!"
fi fi
if [[ "${SYSTEM_FACTIONS}" != "${SYSTEM_REDHAT}" || "${SYSTEM_JUDGMENT}" == "${SYSTEM_FEDORA}" ]] && [[ "${INSTALL_EPEL}" == "true" || "${ONLY_EPEL}" == "true" ]]; then fi
if [[ "${INSTALL_EPEL}" == "true" || "${ONLY_EPEL}" == "true" ]]; then
if [[ "${SYSTEM_JUDGMENT}" == "${SYSTEM_FEDORA}" ]] || [[ "${SYSTEM_FACTIONS}" != "${SYSTEM_REDHAT}" && "${SYSTEM_FACTIONS}" && "${SYSTEM_OPENCLOUDOS}" || "${SYSTEM_FACTIONS}" && "${SYSTEM_OPENEULER}" ]]; then
output_error "当前系统不支持安装 EPEL 附件软件包故无法使用相关命令选项,请确认后重试!" output_error "当前系统不支持安装 EPEL 附件软件包故无法使用相关命令选项,请确认后重试!"
fi fi
if [[ "${SYSTEM_JUDGMENT}" != "${SYSTEM_CENTOS}" && "${SYSTEM_JUDGMENT}" != "${SYSTEM_RHEL}" && "${SYSTEM_JUDGMENT}" != "${SYSTEM_ALMALINUX}" ]] && [[ "${SOURCE_VAULT}" == "true" || "${SOURCE_BRANCH_VAULT}" == "true" ]]; then fi
if [[ "${SOURCE_SECURITY}" == "true" || "${SOURCE_SECURITY_BRANCH}" == "true" ]]; then
if [[ "${SYSTEM_JUDGMENT}" != "${SYSTEM_DEBIAN}" ]]; then
output_error "当前系统不支持使用 security 仓库相关命令选项,请确认后重试!"
fi
fi
if [[ "${SOURCE_VAULT}" == "true" || "${SOURCE_VAULT_BRANCH}" == "true" ]]; then
if [[ "${SYSTEM_JUDGMENT}" != "${SYSTEM_CENTOS}" && "${SYSTEM_JUDGMENT}" != "${SYSTEM_RHEL}" && "${SYSTEM_JUDGMENT}" != "${SYSTEM_ALMALINUX}" ]]; then
output_error "当前系统不支持使用 vault 仓库相关命令选项,请确认后重试!" output_error "当前系统不支持使用 vault 仓库相关命令选项,请确认后重试!"
fi fi
fi
if [[ "${SOURCE_PORTAGE}" == "true" || "${SOURCE_PORTAGE_BRANCH}" == "true" ]]; then
if [[ "${SYSTEM_JUDGMENT}" != "${SYSTEM_GENTOO}" ]]; then
output_error "当前系统不支持使用 portage 仓库相关命令选项,请确认后重试!"
fi
fi
} }
## 选择软件源 ## 选择软件源
@@ -1146,6 +1216,13 @@ function backup_original_mirrors() {
# /etc/apk/repositories # /etc/apk/repositories
backup_file $File_AlpineRepositories $File_AlpineRepositoriesBackup "repositories" backup_file $File_AlpineRepositories $File_AlpineRepositoriesBackup "repositories"
;; ;;
"${SYSTEM_GENTOO}")
# /etc/portage/make.conf
backup_file $File_GentooMakeConf $File_GentooMakeConfBackup "make.conf"
# /etc/portage/repos.conf/gentoo.conf
[ -d "${Dir_GentooReposConf}" ] || mkdir -p "${Dir_GentooReposConf}"
backup_file $File_GentooReposConf $File_GentooReposConfBackup "gentoo.conf"
;;
esac esac
fi fi
} }
@@ -1261,6 +1338,9 @@ function remove_original_mirrors() {
"${SYSTEM_ALPINE}") "${SYSTEM_ALPINE}")
[ -f $File_AlpineRepositories ] && sed -i '1,$d' $File_AlpineRepositories [ -f $File_AlpineRepositories ] && sed -i '1,$d' $File_AlpineRepositories
;; ;;
"${SYSTEM_GENTOO}")
[ -f $File_GentooReposConf ] && sed -i '1,$d' $File_GentooReposConf
;;
esac esac
} }
@@ -1319,6 +1399,10 @@ function change_mirrors_main() {
"${SYSTEM_ALPINE}") "${SYSTEM_ALPINE}")
diff_file $File_AlpineRepositoriesBackup $File_AlpineRepositories diff_file $File_AlpineRepositoriesBackup $File_AlpineRepositories
;; ;;
"${SYSTEM_GENTOO}")
diff_file $File_GentooMakeConfBackup $File_GentooMakeConf
diff_file $File_GentooReposConfBackup $File_GentooReposConf
;;
esac esac
fi fi
} }
@@ -1346,6 +1430,9 @@ function change_mirrors_main() {
"${SYSTEM_ALPINE}") "${SYSTEM_ALPINE}")
change_mirrors_Alpine change_mirrors_Alpine
;; ;;
"${SYSTEM_GENTOO}")
change_mirrors_Gentoo
;;
esac esac
## 比较差异 ## 比较差异
if [[ "${PRINT_DIFF}" == "true" ]]; then if [[ "${PRINT_DIFF}" == "true" ]]; then
@@ -1382,6 +1469,9 @@ function change_mirrors_main() {
"${SYSTEM_ALPINE}") "${SYSTEM_ALPINE}")
apk update -f apk update -f
;; ;;
"${SYSTEM_GENTOO}")
emerge --sync --quiet
;;
esac esac
if [ $? -eq 0 ]; then if [ $? -eq 0 ]; then
echo -e "\n$SUCCESS 软件源更换完毕" echo -e "\n$SUCCESS 软件源更换完毕"
@@ -1398,12 +1488,6 @@ function change_mirrors_main() {
## 升级软件包 ## 升级软件包
function upgrade_software() { function upgrade_software() {
function clean_cache() { function clean_cache() {
## 跳过特殊系统
case "${SYSTEM_JUDGMENT}" in
"${SYSTEM_RHEL}" | "${SYSTEM_OPENSUSE}" | "${SYSTEM_ARCH}" | "${SYSTEM_ALPINE}")
return
;;
esac
## 交互确认 ## 交互确认
if [[ -z "${CLEAN_CACHE}" ]]; then if [[ -z "${CLEAN_CACHE}" ]]; then
CLEAN_CACHE="false" CLEAN_CACHE="false"
@@ -1447,16 +1531,27 @@ function upgrade_software() {
$package_manager autoremove -y >/dev/null 2>&1 $package_manager autoremove -y >/dev/null 2>&1
$package_manager clean packages -y >/dev/null 2>&1 $package_manager clean packages -y >/dev/null 2>&1
;; ;;
"${SYSTEM_OPENSUSE}")
rm -rf /var/cache/zypp/* >/dev/null 2>&1
;;
"${SYSTEM_ALPINE}")
rm -rf /var/cache/apk/* >/dev/null 2>&1
;;
"${SYSTEM_GENTOO}")
eclean-dist --deep >/dev/null 2>&1
eclean-packages --deep >/dev/null 2>&1
;;
esac esac
echo -e "\n$COMPLETE 清理完毕" echo -e "\n$COMPLETE 清理完毕"
} }
## 跳过特殊系统 ## 跳过特殊系统
case "${SYSTEM_JUDGMENT}" in case "${SYSTEM_JUDGMENT}" in
"${SYSTEM_ARCH}" | "${SYSTEM_RHEL}") "${SYSTEM_ARCH}")
return return
;; ;;
esac esac
## 交互确认 ## 交互确认
if [[ -z "${UPGRADE_SOFTWARE}" ]]; then if [[ -z "${UPGRADE_SOFTWARE}" ]]; then
UPGRADE_SOFTWARE="false" UPGRADE_SOFTWARE="false"
@@ -1505,6 +1600,9 @@ function upgrade_software() {
"${SYSTEM_ALPINE}") "${SYSTEM_ALPINE}")
apk upgrade --no-cache apk upgrade --no-cache
;; ;;
"${SYSTEM_GENTOO}")
emerge --update --deep --with-bdeps=y --ask=n @world
;;
esac esac
## 清理缓存 ## 清理缓存
clean_cache clean_cache
@@ -1578,7 +1676,7 @@ deb ${1} ${2}-security ${3}
echo "${tips} echo "${tips}
$(gen_debian_source "${base_url}" "${SYSTEM_VERSION_CODENAME}" "${repository_sections}")" >>$File_DebianSourceList $(gen_debian_source "${base_url}" "${SYSTEM_VERSION_CODENAME}" "${repository_sections}")" >>$File_DebianSourceList
# 处理 debian-security 仓库源 # 处理 debian-security 仓库源
base_url="${WEB_PROTOCOL}://${SOURCE_SECURITY:-"${SOURCE}"}/${SOURCE_BRANCH_SECURITY:-"${SOURCE_BRANCH}-security"}" base_url="${WEB_PROTOCOL}://${SOURCE_SECURITY:-"${SOURCE}"}/${SOURCE_SECURITY_BRANCH:-"${SOURCE_BRANCH}-security"}"
echo "$(gen_debian_security_source "${base_url}" "${SYSTEM_VERSION_CODENAME}" "${repository_sections}")" >>$File_DebianSourceList echo "$(gen_debian_security_source "${base_url}" "${SYSTEM_VERSION_CODENAME}" "${repository_sections}")" >>$File_DebianSourceList
else else
echo "deb ${base_url} ${SYSTEM_VERSION_CODENAME} ${repository_sections} echo "deb ${base_url} ${SYSTEM_VERSION_CODENAME} ${repository_sections}
@@ -1591,7 +1689,7 @@ $(gen_debian_source "${base_url}" "${SYSTEM_VERSION_CODENAME}" "${repository_sec
$(gen_ubuntu_source "${base_url}" "${SYSTEM_VERSION_CODENAME}" "${repository_sections}")" >>$File_DebianSourceList $(gen_ubuntu_source "${base_url}" "${SYSTEM_VERSION_CODENAME}" "${repository_sections}")" >>$File_DebianSourceList
;; ;;
"${SYSTEM_KALI}") "${SYSTEM_KALI}")
repository_sections="main non-free contrib" repository_sections="main contrib non-free non-free-firmware"
echo "${tips} echo "${tips}
deb ${base_url} ${SYSTEM_VERSION_CODENAME} ${repository_sections} deb ${base_url} ${SYSTEM_VERSION_CODENAME} ${repository_sections}
# deb-src ${base_url} ${SYSTEM_VERSION_CODENAME} ${repository_sections}" >>$File_DebianSourceList # deb-src ${base_url} ${SYSTEM_VERSION_CODENAME} ${repository_sections}" >>$File_DebianSourceList
@@ -1618,7 +1716,7 @@ deb ${base_url} ${SYSTEM_VERSION_CODENAME} ${repository_sections}
base_url="${WEB_PROTOCOL}://${SOURCE}/${base_system_source_branch}" base_url="${WEB_PROTOCOL}://${SOURCE}/${base_system_source_branch}"
echo "$(gen_debian_source "${base_url}" "${base_system_codename}" "${repository_sections}")" >>$File_LinuxMintSourceList echo "$(gen_debian_source "${base_url}" "${base_system_codename}" "${repository_sections}")" >>$File_LinuxMintSourceList
# 处理 debian-security 仓库源 # 处理 debian-security 仓库源
base_url="${WEB_PROTOCOL}://${SOURCE_SECURITY:-"${SOURCE}"}/${SOURCE_BRANCH_SECURITY:-"${base_system_source_branch}-security"}" base_url="${WEB_PROTOCOL}://${SOURCE_SECURITY:-"${SOURCE}"}/${SOURCE_SECURITY_BRANCH:-"${base_system_source_branch}-security"}"
echo "$(gen_debian_security_source "${base_url}" "${base_system_codename}" "${repository_sections}")" >>$File_LinuxMintSourceList echo "$(gen_debian_security_source "${base_url}" "${base_system_codename}" "${repository_sections}")" >>$File_LinuxMintSourceList
else else
# Ubuntu 版 # Ubuntu 版
@@ -1658,7 +1756,7 @@ deb ${base_url} ${SYSTEM_VERSION_CODENAME} ${repository_sections}
fi fi
} }
## 更换基于 RedHat 系 Linux 发行版软件源 ## 更换基于 RedHat 系 Linux 发行版软件源
function change_mirrors_RedHat() { function change_mirrors_RedHat() {
## 仅 EPEL 模式 ## 仅 EPEL 模式
if [[ "${ONLY_EPEL}" == "true" ]]; then if [[ "${ONLY_EPEL}" == "true" ]]; then
@@ -1728,13 +1826,13 @@ function change_mirrors_RedHat() {
sed -i "s|mirror.centos.org/\$contentdir|mirror.centos.org/centos-vault|g" CentOS-* sed -i "s|mirror.centos.org/\$contentdir|mirror.centos.org/centos-vault|g" CentOS-*
sed -i "s/\$releasever/8.5.2111/g" CentOS-* sed -i "s/\$releasever/8.5.2111/g" CentOS-*
# 单独处理 CentOS-Linux-Sources.repo # 单独处理 CentOS-Linux-Sources.repo
sed -i "s|vault.centos.org/\$contentdir|${SOURCE_VAULT:-"${SOURCE}"}/${SOURCE_BRANCH_VAULT:-"centos-vault"}|g" CentOS-Linux-Sources.repo sed -i "s|vault.centos.org/\$contentdir|${SOURCE_VAULT:-"${SOURCE}"}/${SOURCE_VAULT_BRANCH:-"centos-vault"}|g" CentOS-Linux-Sources.repo
;; ;;
7) 7)
sed -i "s|mirror.centos.org/\$contentdir|mirror.centos.org/${SOURCE_BRANCH}|g" CentOS-* sed -i "s|mirror.centos.org/\$contentdir|mirror.centos.org/${SOURCE_BRANCH}|g" CentOS-*
sed -i "s/\$releasever/7/g" CentOS-* sed -i "s/\$releasever/7/g" CentOS-*
# 单独处理 CentOS-Sources.repo # 单独处理 CentOS-Sources.repo
sed -i "s|vault.centos.org/centos|${SOURCE_VAULT:-"${SOURCE}"}/${SOURCE_BRANCH_VAULT:-"${SOURCE_BRANCH}"}|g" CentOS-Sources.repo sed -i "s|vault.centos.org/centos|${SOURCE_VAULT:-"${SOURCE}"}/${SOURCE_VAULT_BRANCH:-"${SOURCE_BRANCH}"}|g" CentOS-Sources.repo
;; ;;
esac esac
sed -i "s|mirror.centos.org|${SOURCE}|g" CentOS-* sed -i "s|mirror.centos.org|${SOURCE}|g" CentOS-*
@@ -1750,13 +1848,13 @@ function change_mirrors_RedHat() {
# 最终版本为 8.5.2011,从 2022-02 开始切换至 centos-vault 分支 # 最终版本为 8.5.2011,从 2022-02 开始切换至 centos-vault 分支
sed -i "s|mirror.centos.org/\$contentdir|mirror.centos.org/${SOURCE_BRANCH:-"centos-vault"}|g" CentOS-* sed -i "s|mirror.centos.org/\$contentdir|mirror.centos.org/${SOURCE_BRANCH:-"centos-vault"}|g" CentOS-*
sed -i "s/\$releasever/8.5.2111/g" CentOS-* sed -i "s/\$releasever/8.5.2111/g" CentOS-*
sed -i "s|vault.centos.org/\$contentdir|${SOURCE_VAULT:-"${SOURCE}"}/${SOURCE_BRANCH_VAULT:-"centos-vault"}|g" CentOS-Linux-Sources.repo # 单独处理 CentOS-Linux-Sources.repo sed -i "s|vault.centos.org/\$contentdir|${SOURCE_VAULT:-"${SOURCE}"}/${SOURCE_VAULT_BRANCH:-"centos-vault"}|g" CentOS-Linux-Sources.repo # 单独处理 CentOS-Linux-Sources.repo
;; ;;
7) 7)
# 最终版本为 7.9.2009,从 2024-07 开始切换至 centos-vault 分支 # 最终版本为 7.9.2009,从 2024-07 开始切换至 centos-vault 分支
sed -i "s|mirror.centos.org/centos|mirror.centos.org/${SOURCE_BRANCH:-"centos-vault"}|g" CentOS-* sed -i "s|mirror.centos.org/centos|mirror.centos.org/${SOURCE_BRANCH:-"centos-vault"}|g" CentOS-*
sed -i "s/\$releasever/7.9.2009/g" CentOS-* sed -i "s/\$releasever/7.9.2009/g" CentOS-*
sed -i "s|vault.centos.org/centos|${SOURCE_VAULT:-"${SOURCE}"}/${SOURCE_BRANCH_VAULT:-"centos-vault"}|g" CentOS-Sources.repo # 单独处理 CentOS-Sources.repo sed -i "s|vault.centos.org/centos|${SOURCE_VAULT:-"${SOURCE}"}/${SOURCE_VAULT_BRANCH:-"centos-vault"}|g" CentOS-Sources.repo # 单独处理 CentOS-Sources.repo
;; ;;
esac esac
sed -i "s|mirror.centos.org|${SOURCE}|g" CentOS-* sed -i "s|mirror.centos.org|${SOURCE}|g" CentOS-*
@@ -1772,7 +1870,7 @@ function change_mirrors_RedHat() {
centos-addons.repo centos-addons.repo
;; ;;
8) 8)
sed -i "s|vault.centos.org/\$contentdir|${SOURCE_VAULT:-"${SOURCE}"}/${SOURCE_BRANCH_VAULT:-"${SOURCE_BRANCH}"}|g" CentOS-Stream-Sources.repo # 单独处理 CentOS-Stream-Sources.repo sed -i "s|vault.centos.org/\$contentdir|${SOURCE_VAULT:-"${SOURCE}"}/${SOURCE_VAULT_BRANCH:-"${SOURCE_BRANCH}"}|g" CentOS-Stream-Sources.repo # 单独处理 CentOS-Stream-Sources.repo
sed -e "s|^#baseurl=http|baseurl=${WEB_PROTOCOL}|g" \ sed -e "s|^#baseurl=http|baseurl=${WEB_PROTOCOL}|g" \
-e "s|^mirrorlist=|#mirrorlist=|g" \ -e "s|^mirrorlist=|#mirrorlist=|g" \
-e "s|mirror.centos.org/\$contentdir|${SOURCE}/${SOURCE_BRANCH}|g" \ -e "s|mirror.centos.org/\$contentdir|${SOURCE}/${SOURCE_BRANCH}|g" \
@@ -1807,7 +1905,7 @@ function change_mirrors_RedHat() {
9) 9)
sed -e "s|^# baseurl=http|baseurl=${WEB_PROTOCOL}|g" \ sed -e "s|^# baseurl=http|baseurl=${WEB_PROTOCOL}|g" \
-e "s|^mirrorlist=|#mirrorlist=|g" \ -e "s|^mirrorlist=|#mirrorlist=|g" \
-e "s|repo.almalinux.org/vault|${SOURCE_VAULT:-"${SOURCE}"}/${SOURCE_BRANCH_VAULT:-"almalinux-vault"}|g" \ -e "s|repo.almalinux.org/vault|${SOURCE_VAULT:-"${SOURCE}"}/${SOURCE_VAULT_BRANCH:-"almalinux-vault"}|g" \
-e "s|repo.almalinux.org/almalinux|${SOURCE}/${SOURCE_BRANCH}|g" \ -e "s|repo.almalinux.org/almalinux|${SOURCE}/${SOURCE_BRANCH}|g" \
-i \ -i \
almalinux-* almalinux-*
@@ -1815,7 +1913,7 @@ function change_mirrors_RedHat() {
8) 8)
sed -e "s|^mirrorlist=|#mirrorlist=|g" \ sed -e "s|^mirrorlist=|#mirrorlist=|g" \
-e "s|^# baseurl=http|baseurl=${WEB_PROTOCOL}|g" \ -e "s|^# baseurl=http|baseurl=${WEB_PROTOCOL}|g" \
-e "s|repo.almalinux.org/vault|${SOURCE_VAULT:-"${SOURCE}"}/${SOURCE_BRANCH_VAULT:-"almalinux-vault"}|g" \ -e "s|repo.almalinux.org/vault|${SOURCE_VAULT:-"${SOURCE}"}/${SOURCE_VAULT_BRANCH:-"almalinux-vault"}|g" \
-e "s|repo.almalinux.org/almalinux|${SOURCE}/${SOURCE_BRANCH}|g" \ -e "s|repo.almalinux.org/almalinux|${SOURCE}/${SOURCE_BRANCH}|g" \
-i \ -i \
almalinux-ha.repo \ almalinux-ha.repo \
@@ -1861,7 +1959,7 @@ function change_mirrors_RedHat() {
change_mirrors_or_install_EPEL # EPEL 附加软件包 change_mirrors_or_install_EPEL # EPEL 附加软件包
} }
## 更换基于 OpenCloudOS 发行版软件源 ## 更换 OpenCloudOS 发行版软件源
function change_mirrors_OpenCloudOS() { function change_mirrors_OpenCloudOS() {
## 生成官方 repo 源文件 ## 生成官方 repo 源文件
gen_repo_files_OpenCloudOS "${SYSTEM_VERSION_NUMBER:0:1}" gen_repo_files_OpenCloudOS "${SYSTEM_VERSION_NUMBER:0:1}"
@@ -1885,7 +1983,7 @@ function change_mirrors_OpenCloudOS() {
change_mirrors_or_install_EPEL # EPEL 附加软件包 change_mirrors_or_install_EPEL # EPEL 附加软件包
} }
## 更换基于 openEuler 发行版软件源 ## 更换 openEuler 发行版软件源
function change_mirrors_openEuler() { function change_mirrors_openEuler() {
## 生成官方 repo 源文件 ## 生成官方 repo 源文件
gen_repo_files_openEuler gen_repo_files_openEuler
@@ -1907,7 +2005,7 @@ function change_mirrors_openEuler() {
change_mirrors_or_install_EPEL # EPEL 附加软件包 change_mirrors_or_install_EPEL # EPEL 附加软件包
} }
## 更换基于 openSUSE 发行版软件源 ## 更换 openSUSE 发行版软件源
function change_mirrors_openSUSE() { function change_mirrors_openSUSE() {
## 生成官方 repo 源文件 ## 生成官方 repo 源文件
case "${SYSTEM_ID}" in case "${SYSTEM_ID}" in
@@ -1973,7 +2071,7 @@ function change_mirrors_openSUSE() {
esac esac
} }
## 更换基于 Arch Linux 发行版软件源 ## 更换 Arch Linux 发行版软件源
function change_mirrors_ArchLinux() { function change_mirrors_ArchLinux() {
## 使用官方源 ## 使用官方源
if [[ "${USE_OFFICIAL_SOURCE}" == "true" ]]; then if [[ "${USE_OFFICIAL_SOURCE}" == "true" ]]; then
@@ -1994,7 +2092,7 @@ function change_mirrors_ArchLinux() {
esac esac
} }
## 更换基于 Alpine Linux 发行版软件源 ## 更换 Alpine Linux 发行版软件源
function change_mirrors_Alpine() { function change_mirrors_Alpine() {
## 使用官方源 ## 使用官方源
if [[ "${USE_OFFICIAL_SOURCE}" == "true" ]]; then if [[ "${USE_OFFICIAL_SOURCE}" == "true" ]]; then
@@ -2012,6 +2110,34 @@ function change_mirrors_Alpine() {
${WEB_PROTOCOL}://${SOURCE}/${SOURCE_BRANCH}/${version_name}/community" >>$File_AlpineRepositories ${WEB_PROTOCOL}://${SOURCE}/${SOURCE_BRANCH}/${version_name}/community" >>$File_AlpineRepositories
} }
## 更换 Gentoo 发行版软件源
function change_mirrors_Gentoo() {
## 使用官方源
if [[ "${USE_OFFICIAL_SOURCE}" == "true" ]]; then
grep -Eq "^GENTOO_MIRRORS=" $File_GentooMakeConf
if [ $? -eq 0 ]; then
sed -i "/^GENTOO_MIRRORS=/d" $File_GentooMakeConf
fi
[ -f $File_GentooReposConf ] && rm -rf $File_GentooReposConf
return
fi
## 修改源
grep -Eq "^GENTOO_MIRRORS=" $File_GentooMakeConf
if [ $? -eq 0 ]; then
sed -i "s|^GENTOO_MIRRORS=.*|GENTOO_MIRRORS=\"${WEB_PROTOCOL}://${SOURCE}/${SOURCE_BRANCH}\"|g" $File_GentooMakeConf
else
echo -e "\nGENTOO_MIRRORS=\"${WEB_PROTOCOL}://${SOURCE}/${SOURCE_BRANCH}\"" >>$File_GentooMakeConf
fi
echo "[DEFAULT]
main-repo = gentoo
[gentoo]
location = /usr/portage
sync-type = rsync
sync-uri = rsync://${SOURCE_PORTAGE:-"${SOURCE}"}/${SOURCE_PORTAGE_BRANCH:-"gentoo-portage"}
auto-sync = yes" >$File_GentooReposConf
}
## EPEL (Extra Packages for Enterprise Linux) 附加软件包 - 安装或更换软件源 ## EPEL (Extra Packages for Enterprise Linux) 附加软件包 - 安装或更换软件源
function change_mirrors_or_install_EPEL() { function change_mirrors_or_install_EPEL() {
if [[ "${INSTALL_EPEL}" != "true" ]]; then if [[ "${INSTALL_EPEL}" != "true" ]]; then
@@ -2061,12 +2187,11 @@ function change_mirrors_or_install_EPEL() {
if [[ "${USE_OFFICIAL_SOURCE}" == "true" ]]; then if [[ "${USE_OFFICIAL_SOURCE}" == "true" ]]; then
return return
fi fi
## 修改源(仓库分支名称暂时固定为 epel ## 修改源
local epel_branch="epel"
sed -e "s|^#baseurl=http\(s\)\?|baseurl=${WEB_PROTOCOL}|g" \ sed -e "s|^#baseurl=http\(s\)\?|baseurl=${WEB_PROTOCOL}|g" \
-e "s|^metalink=|#metalink=|g" \ -e "s|^metalink=|#metalink=|g" \
-e "s|download.example/pub/epel|${SOURCE}/${epel_branch}|g" \ -e "s|download.example/pub/epel|${SOURCE_EPEL:-"${SOURCE}"}/${SOURCE_EPEL_BRANCH:-"epel"}|g" \
-e "s|download.fedoraproject.org/pub/epel|${SOURCE}/${epel_branch}|g" \ -e "s|download.fedoraproject.org/pub/epel|${SOURCE_EPEL:-"${SOURCE}"}/${SOURCE_EPEL_BRANCH:-"epel"}|g" \
-i \ -i \
$Dir_YumRepos/epel* $Dir_YumRepos/epel*
} }

View File

@@ -9,7 +9,7 @@
</strong> </strong>
</p> </p>
<p align="center"> <p align="center">
GNU/Linux 更换系统软件源脚本 GNU/Linux 更换系统软件源脚本及 Docker 安装脚本
</p> </p>
<p align="center"> <p align="center">
<strong> <strong>
@@ -86,11 +86,15 @@
<td><a href="https://www.alpinelinux.org" target="_blank"><img src="./docs/assets/images/icon/alpine.png" width="16" height="16" style="vertical-align: -0.15em"/></a>&nbsp;Alpine Linux</td> <td><a href="https://www.alpinelinux.org" target="_blank"><img src="./docs/assets/images/icon/alpine.png" width="16" height="16" style="vertical-align: -0.15em"/></a>&nbsp;Alpine Linux</td>
<td align="center">v3 / edge</td> <td align="center">v3 / edge</td>
</tr> </tr>
<tr>
<td><a href="https://www.gentoo.org" target="_blank"><img src="./docs/assets/images/icon/gentoo.svg" width="16" height="16" style="vertical-align: -0.25em"/></a>&nbsp;Gentoo</td>
<td align="center">all</td>
</tr>
</table> </table>
<p align="center"> <p align="center">
<strong> <strong>
<a href="https://linuxmirrors.cn/use" style="text-decoration: none;">使用方法</a>&nbsp;&nbsp;&nbsp;&nbsp;<a href="https://linuxmirrors.cn/mirrors" style="text-decoration: none;">软件源</a>&nbsp;&nbsp;&nbsp;&nbsp;<a href="https://linuxmirrors.cn/help" style="text-decoration: none;">常见问题</a>&nbsp;&nbsp;&nbsp;&nbsp;<a href="https://linuxmirrors.cn/other" style="text-decoration: none;">Docker 一键安装(额外脚本)</a> <a href="https://linuxmirrors.cn/use" style="text-decoration: none;">使用方法</a>&nbsp;&nbsp;&nbsp;&nbsp;<a href="https://linuxmirrors.cn/mirrors" style="text-decoration: none;">软件源</a>&nbsp;&nbsp;&nbsp;&nbsp;<a href="https://linuxmirrors.cn/help" style="text-decoration: none;">常见问题</a>&nbsp;&nbsp;&nbsp;&nbsp;<a href="https://linuxmirrors.cn/other" style="text-decoration: none;">Docker 安装(额外脚本)</a>
</strong> </strong>
</p> </p>

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 5.7 KiB

View File

@@ -44,7 +44,7 @@ hide:
--- ---
脚本使换源变得更简单,默认交互运行,逐步引导用户更换软件源 脚本使换源变得更简单,默认交互运行,逐步引导用户选择软件源配置
同时提供了强大的命令选项,可实现各种定制需求和无交互操作 同时提供了强大的命令选项,可实现各种定制需求和无交互操作
- :material-scale-balance:{ .lg .middle } __开源MIT__ - :material-scale-balance:{ .lg .middle } __开源MIT__
@@ -82,6 +82,7 @@ hide:
| <a href="https://www.opensuse.org" target="_blank"><img src="/assets/images/icon/opensuse.svg" width="16" height="16"></a> openSUSE | Leep 15 / Tumbleweed | | <a href="https://www.opensuse.org" target="_blank"><img src="/assets/images/icon/opensuse.svg" width="16" height="16"></a> openSUSE | Leep 15 / Tumbleweed |
| <a href="https://archlinux.org" target="_blank"><img src="/assets/images/icon/arch-linux.ico" width="16" height="16" style="vertical-align: -0.15em"></a> Arch Linux | all | | <a href="https://archlinux.org" target="_blank"><img src="/assets/images/icon/arch-linux.ico" width="16" height="16" style="vertical-align: -0.15em"></a> Arch Linux | all |
| <a href="https://www.alpinelinux.org" target="_blank"><img src="/assets/images/icon/alpine.png" width="16" height="16" style="vertical-align: -0.15em"></a> Alpine Linux | v3 / edge | | <a href="https://www.alpinelinux.org" target="_blank"><img src="/assets/images/icon/alpine.png" width="16" height="16" style="vertical-align: -0.15em"></a> Alpine Linux | v3 / edge |
| <a href="https://www.gentoo.org" target="_blank"><img src="/assets/images/icon/gentoo.svg" width="16" height="16" style="vertical-align: -0.2em"></a> Gentoo | all |
</div> </div>

View File

@@ -10,7 +10,7 @@ hide:
> 下方列表中的镜像站均支持 `Debian` `Ubuntu` `CentOS` `openSUSE` `openEuler` 软件源,列表根据单位性质、地理位置、名称长度进行排序,与实际速度无关 > 下方列表中的镜像站均支持 `Debian` `Ubuntu` `CentOS` `openSUSE` `openEuler` 软件源,列表根据单位性质、地理位置、名称长度进行排序,与实际速度无关
| 镜像站 | IPv6 | Arch Linux | Kali Linux | Deepin | Rocky Linux | AlmaLinux | EPEL | Fedora | OpenCloudOS | Alpine Linux | Armbian | Proxmox | Linux Mint | | 镜像站 | IPv6 | Arch Linux | Kali Linux | Deepin | Rocky Linux | AlmaLinux | EPEL :material-information-outline:{ title="EPEL (Extra Packages for Enterprise Linux) 是由 Fedora 组织维护的一个附加软件包仓库,它主要适用于除 Fedora 操作系统以外的红帽系 Linux 发行版" } | Fedora | OpenCloudOS | Alpine Linux | Armbian | Proxmox | Linux Mint |
| :--: | :--: | :--: | :--: | :--: | :--: | :--: | :--: | :--: | :--: | :--: | :--: | :--: | :--: | | :--: | :--: | :--: | :--: | :--: | :--: | :--: | :--: | :--: | :--: | :--: | :--: | :--: | :--: |
| [阿里云](https://mirrors.aliyun.com "mirrors.aliyun.com") | :supported: | :supported: | :supported: | :supported: | :incompatible: | :supported: | :supported: | :supported: | :unsupport: | :supported: | :supported: | :unsupport: | :supported: | | [阿里云](https://mirrors.aliyun.com "mirrors.aliyun.com") | :supported: | :supported: | :supported: | :supported: | :incompatible: | :supported: | :supported: | :supported: | :unsupport: | :supported: | :supported: | :unsupport: | :supported: |
| [腾讯云](https://mirrors.tencent.com "mirrors.tencent.com") | :unsupport: | :supported: | :supported: | :unsupport: | :supported: | :supported: | :supported: | :supported: | :supported: | :supported: | :unsupport: | :unsupport: | :supported: | | [腾讯云](https://mirrors.tencent.com "mirrors.tencent.com") | :unsupport: | :supported: | :supported: | :unsupport: | :supported: | :supported: | :supported: | :supported: | :supported: | :supported: | :unsupport: | :unsupport: | :supported: |
@@ -47,7 +47,6 @@ hide:
| 浙江大学 | [mirrors.zju.edu.cn](https://mirrors.zju.edu.cn "https://mirrors.zju.edu.cn") | | 浙江大学 | [mirrors.zju.edu.cn](https://mirrors.zju.edu.cn "https://mirrors.zju.edu.cn") |
| 山东大学 | [mirrors.sdu.edu.cn](https://mirrors.sdu.edu.cn "https://mirrors.sdu.edu.cn") | | 山东大学 | [mirrors.sdu.edu.cn](https://mirrors.sdu.edu.cn "https://mirrors.sdu.edu.cn") |
| 吉林大学 | [mirrors.jlu.edu.cn](https://mirrors.jlu.edu.cn "https://mirrors.jlu.edu.cn") | | 吉林大学 | [mirrors.jlu.edu.cn](https://mirrors.jlu.edu.cn "https://mirrors.jlu.edu.cn") |
| 上海交通大学 | [mirror.sjtu.edu.cn](https://mirror.sjtu.edu.cn "https://mirror.sjtu.edu.cn") |
| 上海科技大学 | [mirrors.shanghaitech.edu.cn](https://mirrors.shanghaitech.edu.cn "https://mirrors.shanghaitech.edu.cn") | | 上海科技大学 | [mirrors.shanghaitech.edu.cn](https://mirrors.shanghaitech.edu.cn "https://mirrors.shanghaitech.edu.cn") |
| 南方科技大学 | [mirrors.sustech.edu.cn](https://mirrors.sustech.edu.cn "https://mirrors.sustech.edu.cn") | | 南方科技大学 | [mirrors.sustech.edu.cn](https://mirrors.sustech.edu.cn "https://mirrors.sustech.edu.cn") |
| 南京邮电大学 | [mirrors.njupt.edu.cn](https://mirrors.njupt.edu.cn "https://mirrors.njupt.edu.cn") | | 南京邮电大学 | [mirrors.njupt.edu.cn](https://mirrors.njupt.edu.cn "https://mirrors.njupt.edu.cn") |
@@ -60,6 +59,7 @@ hide:
| 西安交通大学 | [mirrors.xjtu.edu.cn](https://mirrors.xjtu.edu.cn "https://mirrors.xjtu.edu.cn") | | 西安交通大学 | [mirrors.xjtu.edu.cn](https://mirrors.xjtu.edu.cn "https://mirrors.xjtu.edu.cn") |
| 江西理工大学 | [mirrors.jxust.edu.cn](https://mirrors.jxust.edu.cn "https://mirrors.jxust.edu.cn") | | 江西理工大学 | [mirrors.jxust.edu.cn](https://mirrors.jxust.edu.cn "https://mirrors.jxust.edu.cn") |
| 重庆邮电大学 | [mirrors.cqupt.edu.cn](https://mirrors.cqupt.edu.cn "https://mirrors.cqupt.edu.cn") | | 重庆邮电大学 | [mirrors.cqupt.edu.cn](https://mirrors.cqupt.edu.cn "https://mirrors.cqupt.edu.cn") |
| 华中科技大学 | [mirrors.hust.edu.cn](https://mirrors.hust.edu.cn "https://mirrors.hust.edu.cn") |
| 南阳理工学院 | [mirror.nyist.edu.cn](https://mirror.nyist.edu.cn "https://mirror.nyist.edu.cn") | | 南阳理工学院 | [mirror.nyist.edu.cn](https://mirror.nyist.edu.cn "https://mirror.nyist.edu.cn") |
| 武昌首义学院 | [mirrors.wsyu.edu.cn](https://mirrors.wsyu.edu.cn "https://mirrors.wsyu.edu.cn") | | 武昌首义学院 | [mirrors.wsyu.edu.cn](https://mirrors.wsyu.edu.cn "https://mirrors.wsyu.edu.cn") |
| 荆楚理工学院 | [mirrors.jcut.edu.cn](https://mirrors.jcut.edu.cn "https://mirrors.jcut.edu.cn") | | 荆楚理工学院 | [mirrors.jcut.edu.cn](https://mirrors.jcut.edu.cn "https://mirrors.jcut.edu.cn") |
@@ -67,6 +67,8 @@ hide:
| 中国科学技术大学 | [mirrors.ustc.edu.cn](https://mirrors.ustc.edu.cn "https://mirrors.ustc.edu.cn") | | 中国科学技术大学 | [mirrors.ustc.edu.cn](https://mirrors.ustc.edu.cn "https://mirrors.ustc.edu.cn") |
| 西北农林科技大学 | [mirrors.nwafu.edu.cn](https://mirrors.nwafu.edu.cn "https://mirrors.nwafu.edu.cn") | | 西北农林科技大学 | [mirrors.nwafu.edu.cn](https://mirrors.nwafu.edu.cn "https://mirrors.nwafu.edu.cn") |
| 大连东软信息学院 | [mirrors.neusoft.edu.cn](https://mirrors.neusoft.edu.cn "https://mirrors.neusoft.edu.cn") | | 大连东软信息学院 | [mirrors.neusoft.edu.cn](https://mirrors.neusoft.edu.cn "https://mirrors.neusoft.edu.cn") |
| 上海交通大学(思源) | [mirror.sjtu.edu.cn](https://mirror.sjtu.edu.cn "https://mirror.sjtu.edu.cn") |
| 上海交通大学(致远) | [mirrors.sjtug.sjtu.edu.cn](https://mirrors.sjtug.sjtu.edu.cn "https://mirrors.sjtug.sjtu.edu.cn") |
## 海外地区 :flag-world-map: ## 海外地区 :flag-world-map:
@@ -78,6 +80,7 @@ hide:
| 亚洲 · 01Link · 香港 :flag-HK: | [mirror.01link.hk](https://mirror.01link.hk "https://mirror.01link.hk") | | 亚洲 · 01Link · 香港 :flag-HK: | [mirror.01link.hk](https://mirror.01link.hk "https://mirror.01link.hk") |
| 亚洲 · 新加坡国立大学(NUS) · 新加坡 :flag-SG: | [download.nus.edu.sg/mirror](https://download.nus.edu.sg "https://download.nus.edu.sg") | | 亚洲 · 新加坡国立大学(NUS) · 新加坡 :flag-SG: | [download.nus.edu.sg/mirror](https://download.nus.edu.sg "https://download.nus.edu.sg") |
| 亚洲 · SG.GS · 新加坡 :flag-SG: | [mirror.sg.gs](https://mirror.sg.gs "https://mirror.sg.gs") | | 亚洲 · SG.GS · 新加坡 :flag-SG: | [mirror.sg.gs](https://mirror.sg.gs "https://mirror.sg.gs") |
| 亚洲 · xTom · 新加坡 :flag-SG: | [mirrors.xtom.sg](https://mirrors.xtom.sg "https://mirrors.xtom.sg") |
| 亚洲 · 自由软件实验室(NCHC) · 台湾 :flag-TW: | [free.nchc.org.tw](https://free.nchc.org.tw "https://free.nchc.org.tw") | | 亚洲 · 自由软件实验室(NCHC) · 台湾 :flag-TW: | [free.nchc.org.tw](https://free.nchc.org.tw "https://free.nchc.org.tw") |
| 亚洲 · OSS Planet · 台湾 :flag-TW: | [mirror.ossplanet.net](https://mirror.ossplanet.net "https://mirror.ossplanet.net") | | 亚洲 · OSS Planet · 台湾 :flag-TW: | [mirror.ossplanet.net](https://mirror.ossplanet.net "https://mirror.ossplanet.net") |
| 亚洲 · 国立阳明交通大学 · 台湾 :flag-TW: | [linux.cs.nctu.edu.tw](https://linux.cs.nctu.edu.tw "https://linux.cs.nctu.edu.tw") | | 亚洲 · 国立阳明交通大学 · 台湾 :flag-TW: | [linux.cs.nctu.edu.tw](https://linux.cs.nctu.edu.tw "https://linux.cs.nctu.edu.tw") |
@@ -174,6 +177,7 @@ hide:
| 亚洲 · 01Link · 香港 :flag-HK: | [mirror.01link.hk](https://mirror.01link.hk "https://mirror.01link.hk") | | 亚洲 · 01Link · 香港 :flag-HK: | [mirror.01link.hk](https://mirror.01link.hk "https://mirror.01link.hk") |
| 亚洲 · 新加坡国立大学(NUS) · 新加坡 :flag-SG: | [download.nus.edu.sg/mirror](https://download.nus.edu.sg "https://download.nus.edu.sg") | | 亚洲 · 新加坡国立大学(NUS) · 新加坡 :flag-SG: | [download.nus.edu.sg/mirror](https://download.nus.edu.sg "https://download.nus.edu.sg") |
| 亚洲 · SG.GS · 新加坡 :flag-SG: | [mirror.sg.gs](https://mirror.sg.gs "https://mirror.sg.gs") | | 亚洲 · SG.GS · 新加坡 :flag-SG: | [mirror.sg.gs](https://mirror.sg.gs "https://mirror.sg.gs") |
| 亚洲 · xTom · 新加坡 :flag-SG: | [mirrors.xtom.sg](https://mirrors.xtom.sg "https://mirrors.xtom.sg") |
| 亚洲 · 自由软件实验室(NCHC) · 台湾 :flag-TW: | [free.nchc.org.tw](https://free.nchc.org.tw "https://free.nchc.org.tw") | | 亚洲 · 自由软件实验室(NCHC) · 台湾 :flag-TW: | [free.nchc.org.tw](https://free.nchc.org.tw "https://free.nchc.org.tw") |
| 亚洲 · OSS Planet · 台湾 :flag-TW: | [mirror.ossplanet.net](https://mirror.ossplanet.net "https://mirror.ossplanet.net") | | 亚洲 · OSS Planet · 台湾 :flag-TW: | [mirror.ossplanet.net](https://mirror.ossplanet.net "https://mirror.ossplanet.net") |
| 亚洲 · 国立阳明交通大学 · 台湾 :flag-TW: | [linux.cs.nctu.edu.tw](https://linux.cs.nctu.edu.tw "https://linux.cs.nctu.edu.tw") | | 亚洲 · 国立阳明交通大学 · 台湾 :flag-TW: | [linux.cs.nctu.edu.tw](https://linux.cs.nctu.edu.tw "https://linux.cs.nctu.edu.tw") |

View File

@@ -2,70 +2,76 @@
| - | - | :-: | | - | - | :-: |
| `--abroad` | 使用海外软件源 | 无 | | `--abroad` | 使用海外软件源 | 无 |
| `--edu` | 使用中国大陆教育网软件源 | 无 | | `--edu` | 使用中国大陆教育网软件源 | 无 |
| `--source` | 指定软件源地址(域名或IP) | 地址 | | `--source` | 指定软件源地址域名或IP | 地址 |
| `--source-security` | 指定 Debian 的 security 软件源地址(域名或IP) | 地址 | | `--source-epel` | 指定 EPEL 附加软件包仓库的软件源地址域名或IP | 地址 |
| `--source-vault` | 指定 CentOS/AlmaLinux 的 vault 软件源地址(域名或IP) | 地址 | | `--source-security` | 指定 Debian 系统 security 仓库的软件源地址域名或IP | 地址 |
| `--use-official-source` | 使用操作系统官方软件源 | | | `--source-vault` | 指定 CentOS/AlmaLinux 系统 vault 仓库的软件源地址域名或IP | 地址 |
| `--branch` | 指定软件源分支(路径) | 分支名 | | `--source-portage` | 指定 Gentoo 系统 portage 仓库的软件源地址域名或IP | 地址 |
| `--branch-security` | 指定 Debian 的 security 软件源分支(路径) | 分支名 | | `--branch` | 指定软件源分支路径 | 分支名 |
| `--branch-vault` | 指定 CentOS/AlmaLinux 的 vault 软件源分支(路径) | 分支名 | | `--branch-epel` | 指定 EPEL 附加软件包仓库的软件源分支路径 | 分支名 |
| `--branch-security` | 指定 Debian 系统 security 仓库的软件源分支(路径) | 分支名 |
| `--branch-vault` | 指定 CentOS/AlmaLinux 系统 vault 仓库的软件源分支(路径) 分支名 | 分支名 |
| `--branch-portage` | 指定 Gentoo 系统 portage 仓库的软件源分支(路径) | 分支名 |
| `--codename` | 指定 Debian 系操作系统的版本代号 | 代号名称 | | `--codename` | 指定 Debian 系操作系统的版本代号 | 代号名称 |
| `--protocol` | 指定 WEB 协议 | `http``https` | | `--protocol` | 指定 WEB 协议 | `http``https` |
| `--intranet` | 优先使用内网地址 | `true``false` | | `--install-epel` | 是否安装 EPEL 附加软件包 | `true``false` |
| `--install-epel` | 安装 EPEL 附加软件包 | `true``false` | | `--close-firewall` | 是否关闭防火墙 | `true``false` |
| `--backup` | 是否备份原有软件源 | `true``false` |
| `--upgrade-software` | 是否更新软件包 | `true``false` |
| `--clean-cache` | 是否清理下载缓存 | `true``false` |
| `--print-diff` | 是否打印源文件修改前后差异 | `true``false` |
| `--use-intranet-source` | 优先使用内网软件源地址 | 无 |
| `--use-official-source` | 使用目标操作系统的官方软件源 | 无 |
| `--only-epel` | 仅更换 EPEL 软件源模式 | 无 | | `--only-epel` | 仅更换 EPEL 软件源模式 | 无 |
| `--close-firewall` | 关闭防火墙 | `true``false` |
| `--backup` | 备份原有软件源 | `true``false` |
| `--ignore-backup-tips` | 忽略覆盖备份提示(即不覆盖备份) | 无 | | `--ignore-backup-tips` | 忽略覆盖备份提示(即不覆盖备份) | 无 |
| `--upgrade-software` | 更新软件包 | `true``false` |
| `--clean-cache` | 清理下载缓存 | `true``false` |
| `--print-diff` | 打印源文件修改前后差异 | `true``false` |
| `--help` | 查看帮助菜单 | 无 | | `--help` | 查看帮助菜单 | 无 |
> 软件源格式 `<指定WEB协议>://<软件源地址>/<软件源分支>` > 软件源格式 `<指定WEB协议>://<软件源地址>/<软件源分支>`
## 示例 ---
### 指定软件源地址 ## 指定软件源地址
若不想通过交互选择默认提供的软件源,你可以使用该命令选项指定软件源地址
``` { .bash .no-copy } ``` { .bash .no-copy }
bash <(curl -sSL https://linuxmirrors.cn/main.sh) \ bash <(curl -sSL https://linuxmirrors.cn/main.sh) \
--source mirror.example.com --source mirror.example.com
``` ```
### 指定软件源分支 ---
使用场景:目标镜像站有对应的系统镜像但是不符合本项目脚本关于软件源分支设置的默认规则 ## 指定软件源仓库分支
项目脚本为了适配大的环境不会针对某一镜像站独特的镜像分支名称而单独适配,默认使用的分支名称如下 主要使用场景:目标镜像站有对应的系统镜像但是不符合本项目脚本关于软件源分支设置的默认规则
??? note "项目默认使用的系统分支名称"
项目脚本为了适配大的环境不会针对某一镜像站独特的镜像分支名称而单独适配
| 系统名称 | 涉及的分支名称 |
| --- | :---: |
| <a href="https://www.debian.org" target="_blank"><img src="/assets/images/icon/debian.svg" width="16" height="16" style="vertical-align: -0.35em"></a> Debian | debian / debian-archive |
| <a href="https://cn.ubuntu.com" target="_blank"><img src="/assets/images/icon/ubuntu.svg" width="16" height="16" style="vertical-align: -0.1em"></a> Ubuntu | ubuntu / ubuntu-ports |
| <a href="https://www.kali.org" target="_blank"><img src="/assets/images/icon/kali-linux.svg" width="16" height="16"></a> Kali Linux | kali |
| <a href="https://linuxmint.com" target="_blank"><img src="/assets/images/icon/linux-mint.ico" width="16" height="16" style="vertical-align: -0.2em"></a> Linux Mint | linuxmint / ubuntu / ubuntu-ports / debian |
| <a href="https://www.deepin.org" target="_blank"><img src="/assets/images/icon/deepin.svg" width="16" height="16" style="vertical-align: -0.25em"></a> Deepin | deepin |
| <a href="https://www.armbian.com" target="_blank"><img src="/assets/images/icon/armbian.png" width="16" height="16" style="vertical-align: -0.2em"></a> Armbian | armbian |
| <a href="https://www.proxmox.com" target="_blank"><img src="/assets/images/icon/proxmox.svg" width="16" height="16" style="vertical-align: -0.2em"></a> Proxmox | proxmox |
| <a href="https://access.redhat.com/products/red-hat-enterprise-linux" target="_blank"><img src="/assets/images/icon/redhat.svg" width="16" height="16" style="vertical-align: -0.1em"></a> Red Hat Enterprise Linux :material-information-outline:{ title="9版本使用 <code>CentOS Stream</code> 7、8版本使用<code>CentOS</code>" } | centos / centos-stream / centos-altarch / centos-vault |
| <a href="https://fedoraproject.org/zh-Hans" target="_blank"><img src="/assets/images/icon/fedora.ico" width="16" height="16" style="vertical-align: -0.2em"></a> Fedora | fedora |
| <a href="https://www.centos.org" target="_blank"><img src="/assets/images/icon/centos.svg" width="16" height="16" style="vertical-align: -0.2em"></a> CentOS | centos / centos-stream / centos-altarch / centos-vault |
| <a href="https://rockylinux.org" target="_blank"><img src="/assets/images/icon/rocky-linux.svg" width="16" height="16" style="vertical-align: -0.25em"></a> Rocky Linux | rocky |
| <a href="https://almalinux.org/zh-hans" target="_blank"><img src="/assets/images/icon/almalinux.svg" width="16" height="16" style="vertical-align: -0.25em"></a> AlmaLinux | almalinux / almalinux-vault |
| <a href="https://www.opencloudos.org" target="_blank"><img src="/assets/images/icon/opencloudos.png" width="16" height="16" style="vertical-align: -0.25em"></a> OpenCloudOS | opencloudos |
| <a href="https://www.openeuler.org/zh" target="_blank"><img src="/assets/images/icon/openeuler.ico" width="16" height="16" style="vertical-align: -0.2em"></a> openEuler | openeuler |
| <a href="https://www.opensuse.org" target="_blank"><img src="/assets/images/icon/opensuse.svg" width="16" height="16"></a> openSUSE | opensuse |
| <a href="https://archlinux.org" target="_blank"><img src="/assets/images/icon/arch-linux.ico" width="16" height="16" style="vertical-align: -0.15em"></a> Arch Linux | archlinux / archlinuxarm |
| <a href="https://www.alpinelinux.org" target="_blank"><img src="/assets/images/icon/alpine.png" width="16" height="16" style="vertical-align: -0.15em"></a> Alpine Linux | alpine |
| <a href="https://www.gentoo.org" target="_blank"><img src="/assets/images/icon/gentoo.svg" width="16" height="16" style="vertical-align: -0.2em"></a> Gentoo | gentoo / gentoo-portage |
<div class="annotate" markdown>
| 系统名称 | 涉及的分支名称 |
| --- | :---: |
| <a href="https://www.debian.org" target="_blank"><img src="/assets/images/icon/debian.svg" width="16" height="16" style="vertical-align: -0.35em"></a> Debian | debian / debian-archive |
| <a href="https://cn.ubuntu.com" target="_blank"><img src="/assets/images/icon/ubuntu.svg" width="16" height="16" style="vertical-align: -0.1em"></a> Ubuntu | ubuntu / ubuntu-ports |
| <a href="https://www.kali.org" target="_blank"><img src="/assets/images/icon/kali-linux.svg" width="16" height="16"></a> Kali Linux | kali |
| <a href="https://linuxmint.com" target="_blank"><img src="/assets/images/icon/linux-mint.ico" width="16" height="16" style="vertical-align: -0.2em"></a> Linux Mint | linuxmint / ubuntu / ubuntu-ports / debian |
| <a href="https://www.deepin.org" target="_blank"><img src="/assets/images/icon/deepin.svg" width="16" height="16" style="vertical-align: -0.25em"></a> Deepin | deepin |
| <a href="https://www.armbian.com" target="_blank"><img src="/assets/images/icon/armbian.png" width="16" height="16" style="vertical-align: -0.2em"></a> Armbian | armbian |
| <a href="https://www.proxmox.com" target="_blank"><img src="/assets/images/icon/proxmox.svg" width="16" height="16" style="vertical-align: -0.2em"></a> Proxmox | proxmox |
| <a href="https://access.redhat.com/products/red-hat-enterprise-linux" target="_blank"><img src="/assets/images/icon/redhat.svg" width="16" height="16" style="vertical-align: -0.1em"></a> Red Hat Enterprise Linux :material-information-outline:{ title="9版本使用 <code>Rocky Linux</code> 7、8版本使用<code>CentOS</code>" } | centos / centos-altarch / rocky |
| <a href="https://fedoraproject.org/zh-Hans" target="_blank"><img src="/assets/images/icon/fedora.ico" width="16" height="16" style="vertical-align: -0.2em"></a> Fedora | fedora |
| <a href="https://www.centos.org" target="_blank"><img src="/assets/images/icon/centos.svg" width="16" height="16" style="vertical-align: -0.2em"></a> CentOS | centos / centos-stream / centos-altarch / centos-vault |
| <a href="https://rockylinux.org" target="_blank"><img src="/assets/images/icon/rocky-linux.svg" width="16" height="16" style="vertical-align: -0.25em"></a> Rocky Linux | rocky |
| <a href="https://almalinux.org/zh-hans" target="_blank"><img src="/assets/images/icon/almalinux.svg" width="16" height="16" style="vertical-align: -0.25em"></a> AlmaLinux | almalinux / almalinux-vault |
| <a href="https://www.opencloudos.org" target="_blank"><img src="/assets/images/icon/opencloudos.png" width="16" height="16" style="vertical-align: -0.25em"></a> OpenCloudOS | opencloudos |
| <a href="https://www.openeuler.org/zh" target="_blank"><img src="/assets/images/icon/openeuler.ico" width="16" height="16" style="vertical-align: -0.2em"></a> openEuler | openeuler |
| <a href="https://www.opensuse.org" target="_blank"><img src="/assets/images/icon/opensuse.svg" width="16" height="16"></a> openSUSE | opensuse |
| <a href="https://archlinux.org" target="_blank"><img src="/assets/images/icon/arch-linux.ico" width="16" height="16" style="vertical-align: -0.15em"></a> Arch Linux | archlinux / archlinuxarm |
| <a href="https://www.alpinelinux.org" target="_blank"><img src="/assets/images/icon/alpine.png" width="16" height="16" style="vertical-align: -0.15em"></a> Alpine Linux | alpine |
</div>
请看下面的例子 请看下面的例子
``` { .bash title="使用阿里云的 Rocky Linux 软件源" } ``` { .bash title="使用阿里云镜像站的 Rocky Linux 软件源" }
bash <(curl -sSL https://linuxmirrors.cn/main.sh) \ bash <(curl -sSL https://linuxmirrors.cn/main.sh) \
--source mirrors.aliyun.com \ --source mirrors.aliyun.com \
--branch rockylinux --branch rockylinux
@@ -73,9 +79,11 @@ bash <(curl -sSL https://linuxmirrors.cn/main.sh) \
阿里云镜像站的 Rocky Linux 镜像分支名称为 [`rockylinux`](https://mirrors.aliyun.com/rockylinux),不符合默认规则,但是可以通过命令选项绕过脚本默认规则来实现。 阿里云镜像站的 Rocky Linux 镜像分支名称为 [`rockylinux`](https://mirrors.aliyun.com/rockylinux),不符合默认规则,但是可以通过命令选项绕过脚本默认规则来实现。
什么是默认规则?参考这几个例子: `Debian GNU/Linux => debian`、`Rocky Linux => rocky`、`AlmaLinux => almalinux` > 部分系统会同时配置多个仓库的软件源,具体详见命令选项
### 单独更换 EPEL 源 ---
## 单独更换 EPEL 源
!!! info "EPEL (Extra Packages for Enterprise Linux) 是由 Fedora 组织维护的一个附加软件包仓库,它主要适用于除 Fedora 操作系统以外的红帽系 Linux 发行版,配置 EPEL 仓库已成为广大用户的普遍需求,建议默认安装它" !!! info "EPEL (Extra Packages for Enterprise Linux) 是由 Fedora 组织维护的一个附加软件包仓库,它主要适用于除 Fedora 操作系统以外的红帽系 Linux 发行版,配置 EPEL 仓库已成为广大用户的普遍需求,建议默认安装它"
@@ -85,7 +93,9 @@ bash <(curl -sSL https://linuxmirrors.cn/main.sh) \
bash <(curl -sSL https://linuxmirrors.cn/main.sh) --only-epel bash <(curl -sSL https://linuxmirrors.cn/main.sh) --only-epel
``` ```
### 恢复使用官方源 ---
## 恢复使用官方源
当你不小心删除了官方源的备份时可以使用此命令来恢复,使用此命令选项后将跳过选择软件源步骤 当你不小心删除了官方源的备份时可以使用此命令来恢复,使用此命令选项后将跳过选择软件源步骤
@@ -94,7 +104,9 @@ bash <(curl -sSL https://linuxmirrors.cn/main.sh) --use-official-source
``` ```
> 部分系统不存在官方源例如 `Arch Linux`,届时会自动更换成兼容性较高的阿里云镜像站 > 部分系统不存在官方源例如 `Arch Linux`,届时会自动更换成兼容性较高的阿里云镜像站
### 自定义 Debian Security 源 ---
## 自定义 Debian Security 源
如果你想尽可能提高服务器的安全性则建议使用官方源,因为镜像同步存在延迟 如果你想尽可能提高服务器的安全性则建议使用官方源,因为镜像同步存在延迟
@@ -104,7 +116,9 @@ bash <(curl -sSL https://linuxmirrors.cn/main.sh) \
--branch-security debian-security --branch-security debian-security
``` ```
### 指定 Debian 系 Linux 操作系统的版本代号 ---
## 指定 Debian 系 Linux 操作系统的版本代号
大多数情况下自定义版本代号用于更换系统版本,请看下面的例子 大多数情况下自定义版本代号用于更换系统版本,请看下面的例子
@@ -128,7 +142,9 @@ bash <(curl -sSL https://linuxmirrors.cn/main.sh) \
sed -i "s/$(lsb_release -cs)/指定版本代号/g" /etc/apt/sources.list sed -i "s/$(lsb_release -cs)/指定版本代号/g" /etc/apt/sources.list
``` ```
### 更换 Ubuntu EOF版本软件源 ---
## 更换 Ubuntu EOF版本软件源
!!! info "EOF 为生命周期结束的缩写End Of LifeUbuntu 迭代速度较快一般非长期支持(LTS)版本的生命周期只有9个月。官方会定期从主仓库移除不在生命周期内的版本仓库目录届时可能就需要使用镜像站的 `Ubuntu Old Releases` 分支" !!! info "EOF 为生命周期结束的缩写End Of LifeUbuntu 迭代速度较快一般非长期支持(LTS)版本的生命周期只有9个月。官方会定期从主仓库移除不在生命周期内的版本仓库目录届时可能就需要使用镜像站的 `Ubuntu Old Releases` 分支"
@@ -140,9 +156,11 @@ bash <(curl -sSL https://linuxmirrors.cn/main.sh) \
--branch ubuntu-old-releases --branch ubuntu-old-releases
``` ```
## 无人值守 ---
不通过交互完成换源操作,需要使用大量命令选项来实现,建议熟悉后再使用 ## 无人值守(自动化)
不通过交互完成换源操作,至少需要使用如下命令选项来实现,建议熟悉后再使用
``` { .bash .no-copy title="参考命令" } ``` { .bash .no-copy title="参考命令" }
bash <(curl -sSL https://linuxmirrors.cn/main.sh) \ bash <(curl -sSL https://linuxmirrors.cn/main.sh) \

View File

@@ -1,10 +0,0 @@
- 选择软件源 `交互`
- 检测到存在对应内网地址选择是否切换 `交互`
- 选择软件源使用的 WEB 协议 `交互`
- 检测如果是 RHEL/CentOS/Rocky 系统选择是否安装/覆盖 EPEL 扩展包软件源 `交互`
- 检测防火墙和SELINUX如果开启选择是否关闭 `交互`
- 备份原有源
- 检测如果存在重复的备份文件选择是否覆盖 `交互`
- 更换软件源
- 选择是否更新软件包 `交互`
- 选择是否清理已下载的软件包缓存 `交互`

View File

@@ -1,4 +1,3 @@
## 关于报错 Command not found ## 关于报错 Command not found
!!! quote "" !!! quote ""
@@ -16,13 +15,11 @@
=== "RedHat 系 / OpenCloudOS / openEuler" === "RedHat 系 / OpenCloudOS / openEuler"
``` sh ``` sh
yum install -y curl || dnf install -y curl dnf install -y curl || yum install -y curl
``` ```
> `Red Hat Enterprise Linux` &nbsp; `CentOS` &nbsp; `Rocky Linux` &nbsp; `AlmaLinux` &nbsp; `Fedora` &nbsp; `OpenCloudOS` &nbsp; `openEuler` > `Red Hat Enterprise Linux` &nbsp; `CentOS` &nbsp; `Rocky Linux` &nbsp; `AlmaLinux` &nbsp; `Fedora` &nbsp; `OpenCloudOS` &nbsp; `openEuler`
新装系统需要先执行一遍更新 `yum makecache`
=== "openSUSE" === "openSUSE"
``` sh ``` sh
@@ -41,6 +38,12 @@
apk --no-cache add -f curl bash apk --no-cache add -f curl bash
``` ```
=== "Gentoo"
``` sh
emerge --ask curl
```
## 关于开启 SSH 远程登录的方法 ## 关于开启 SSH 远程登录的方法
!!! quote "" !!! quote ""
@@ -70,6 +73,8 @@
ps -ef | grep -q ssh ; [ $? -eq 0 ] && systemctl restart sshd || systemctl enable --now sshd ps -ef | grep -q ssh ; [ $? -eq 0 ] && systemctl restart sshd || systemctl enable --now sshd
``` ```
> 命令仅供参考,只适配了部分常见发行版
## 还原已备份的软件源 ## 还原已备份的软件源
!!! quote "" !!! quote ""
@@ -77,7 +82,7 @@
=== "Debian 系" === "Debian 系"
``` sh ``` sh
cp -rvf /etc/apt/sources.list.bak /etc/apt/sources.list cp -rf /etc/apt/sources.list.bak /etc/apt/sources.list
apt-get update apt-get update
``` ```
@@ -86,7 +91,7 @@
=== "RedHat 系 / OpenCloudOS / openEuler" === "RedHat 系 / OpenCloudOS / openEuler"
``` sh ``` sh
cp -rvf /etc/yum.repos.d.bak /etc/yum.repos.d cp -rf /etc/yum.repos.d.bak /etc/yum.repos.d
yum makecache yum makecache
``` ```
@@ -95,24 +100,32 @@
=== "openSUSE" === "openSUSE"
``` sh ``` sh
cp -rvf /etc/zypp/repos.d.bak /etc/zypp/repos.d cp -rf /etc/zypp/repos.d.bak /etc/zypp/repos.d
zypper ref zypper ref
``` ```
=== "Arch Linux" === "Arch Linux"
``` sh ``` sh
cp -rvf /etc/pacman.d/mirrorlist.bak /etc/pacman.d/mirrorlist cp -rf /etc/pacman.d/mirrorlist.bak /etc/pacman.d/mirrorlist
pacman -Sy pacman -Sy
``` ```
=== "Alpine Linux" === "Alpine Linux"
``` sh ``` sh
cp -rvf /etc/apk/repositories.bak /etc/apk/repositories cp -rf /etc/apk/repositories.bak /etc/apk/repositories
apk update -f apk update -f
``` ```
=== "Gentoo"
``` sh
cp -rf /etc/portage/make.conf.bak /etc/portage/make.conf
[ -d /etc/portage/repos.conf ] && cp -rf /etc/portage/repos.conf/gentoo.conf.bak /etc/portage/repos.conf/gentoo.conf
emerge --sync --quiet
```
## 其它 ## 其它
!!! quote "" !!! quote ""

View File

@@ -3,6 +3,8 @@ hide:
- feedback - feedback
--- ---
!!! question "请在使用前检查目标镜像站是否支持您所使用的操作系统"
## 一键执行命令 ## 一键执行命令
=== ":material-home: 中国大陆(默认)" === ":material-home: 中国大陆(默认)"
@@ -11,8 +13,6 @@ hide:
bash <(curl -sSL https://linuxmirrors.cn/main.sh) bash <(curl -sSL https://linuxmirrors.cn/main.sh)
``` ```
!!! question "请在使用前检查目标镜像站是否支持您所使用的操作系统"
??? quote "原始执行命令" ??? quote "原始执行命令"
=== ":simple-github: GitHub" === ":simple-github: GitHub"
@@ -37,8 +37,6 @@ hide:
1. 通过 `--edu` 命令选项来使用中国大陆教育单位软件源 1. 通过 `--edu` 命令选项来使用中国大陆教育单位软件源
!!! question "请在使用前检查目标镜像站是否支持您所使用的操作系统"
??? quote "原始执行命令" ??? quote "原始执行命令"
=== ":simple-github: GitHub" === ":simple-github: GitHub"
@@ -63,8 +61,6 @@ hide:
1. 通过 `--abroad` 命令选项来使用海外软件源 1. 通过 `--abroad` 命令选项来使用海外软件源
!!! question "请在使用前检查目标镜像站是否支持您所使用的操作系统"
??? quote "原始执行命令" ??? quote "原始执行命令"
=== ":simple-github: GitHub" === ":simple-github: GitHub"
@@ -89,19 +85,19 @@ hide:
--- ---
切换命令为 `sudo -i` 或 `su root`不同系统环境使用的命令不一样,因为有些系统没有在初始安装时为 ROOT 户设置固定密码例如Ubuntu所以需要使用 `sudo` 令来提权 切换命令为 `sudo -i` 或 `su root`不同系统使用的命令不,因为有些系统没有在初始安装时为 ROOT 户设置密码(例如 Ubuntu,故需要使用 `sudo -i` 令来切换至 ROOT
- :material-numeric-2:{style="color: #3CA7E5" .lg} __建议使用 `SSH` 远程工具__ - :material-numeric-2:{style="color: #3CA7E5" .lg} __建议使用 `SSH` 远程工具__
--- ---
如果你使用的系统终端界面不支持 `UTF-8` 编码那么将无法正常显示中文内容导致无法查看交互内容。部分系统会自动开启服务,否则请参考[启用方法](help.md#关于开启-ssh-远程登录的方法) 如果你使用的系统终端界面无法正常显示中文内容那么将导致无法查看交互内容。部分系统会自动开启 SSH 服务,否则请参考[启用方法](help.md#关于开启-ssh-远程登录的方法)
- :material-numeric-3:{style="color: #3CA7E5" .lg} __如果是在新系统上首次执行脚本__ - :material-numeric-3:{style="color: #3CA7E5" .lg} __如果是在新系统上首次执行脚本__
--- ---
当前执行方式依赖 `curl` 指令获取脚本内容并执行,所以需要先通过包管理工具来安装该软件包,则会报错 `Command not found`,安装方法详见[常见问题](help.md#关于报错-command-not-found),若无法安装就复制[源码](https://gitee.com/SuperManito/LinuxMirrors/raw/main/ChangeMirrors.sh)本地新建`.sh`脚本,后通过 `bash` 手动执行 当前执行方式依赖 `curl` 指令获取脚本内容并执行,但部分操作系统没有预装此软件包,届时则会报错 `Command not found`,安装方法详见[常见问题](help.md#关于报错-command-not-found)。还可自行复制[源码](https://gitee.com/SuperManito/LinuxMirrors/raw/main/ChangeMirrors.sh)本地新建任意名称的 `.sh` 脚本,粘贴源码内容后通过 `bash` 指令手动执行
</div> </div>

View File

@@ -146,8 +146,6 @@ nav:
- "使用方法": - "使用方法":
- "使用方法": use/index.md - "使用方法": use/index.md
- "常见问题": use/help.md - "常见问题": use/help.md
- "执行流程": use/execution-flow.md
- "高级用法":
- "命令选项": use/command-options.md - "命令选项": use/command-options.md
- "软件源列表": mirrors/index.md - "软件源列表": mirrors/index.md
- "其它工具": other/index.md - "其它工具": other/index.md