diff --git a/ChangeMirrors.sh b/ChangeMirrors.sh index c072239..91e9da4 100755 --- a/ChangeMirrors.sh +++ b/ChangeMirrors.sh @@ -1,6 +1,6 @@ #!/bin/bash ## Author: SuperManito -## Modified: 2025-05-13 +## Modified: 2025-05-29 ## License: MIT ## GitHub: https://github.com/SuperManito/LinuxMirrors ## Website: https://linuxmirrors.cn @@ -798,7 +798,7 @@ function collect_system_info() { fi ;; "${SYSTEM_RHEL}") - if [[ "${SYSTEM_VERSION_ID_MAJOR}" != [7-9] ]]; then + if [[ "${SYSTEM_VERSION_ID_MAJOR}" != [7-9] && "${SYSTEM_VERSION_ID_MAJOR}" != 10 ]]; then is_supported="false" fi ;; @@ -807,11 +807,16 @@ function collect_system_info() { is_supported="false" fi ;; - "${SYSTEM_CENTOS_STREAM}" | "${SYSTEM_ROCKY}" | "${SYSTEM_ALMALINUX}") + "${SYSTEM_CENTOS_STREAM}" | "${SYSTEM_ALMALINUX}") if [[ "${SYSTEM_VERSION_ID_MAJOR}" != [8-9] && "${SYSTEM_VERSION_ID_MAJOR}" != 10 ]]; then is_supported="false" fi ;; + "${SYSTEM_ROCKY}") + if [[ "${SYSTEM_VERSION_ID_MAJOR}" != [8-9] ]]; then + is_supported="false" + fi + ;; "${SYSTEM_FEDORA}") if [[ "${SYSTEM_VERSION_ID}" != [3-4][0-9] ]]; then is_supported="false" @@ -912,16 +917,16 @@ function collect_system_info() { ;; "${SYSTEM_RHEL}") case "${SYSTEM_VERSION_ID_MAJOR}" in - 9) - SOURCE_BRANCH="centos-stream" # 使用 CentOS Stream 仓库 - ;; - *) + 7 | 8) if [[ "${DEVICE_ARCH_RAW}" == "x86_64" ]]; then SOURCE_BRANCH="centos-vault" else SOURCE_BRANCH="centos-altarch" fi ;; + *) + SOURCE_BRANCH="centos-stream" # 使用 CentOS Stream 仓库 + ;; esac ;; "${SYSTEM_CENTOS}") @@ -1491,16 +1496,16 @@ function remove_original_mirrors() { case "${SYSTEM_JUDGMENT}" in "${SYSTEM_RHEL}") case "${SYSTEM_VERSION_ID_MAJOR}" in - 9) - rm -rf $Dir_YumRepos/centos.repo $Dir_YumRepos/centos-addons.repo - ;; - *) + 7 | 8) if [ -f "${Dir_YumRepos}/epel.repo" ]; then ls $Dir_YumRepos/ | grep -Ev epel | xargs rm -rf else rm -rf $Dir_YumRepos/* fi ;; + *) + rm -rf $Dir_YumRepos/centos.repo $Dir_YumRepos/centos-addons.repo + ;; esac ;; "${SYSTEM_CENTOS}") @@ -2173,11 +2178,11 @@ function change_mirrors_RedHat() { case "${SYSTEM_JUDGMENT}" in "${SYSTEM_RHEL}") case "${SYSTEM_VERSION_ID_MAJOR}" in - 9 | 10) - gen_repo_files_CentOSStream "${SYSTEM_VERSION_ID_MAJOR}" + 7 | 8) + gen_repo_files_CentOS "${SYSTEM_VERSION_ID_MAJOR}" ;; *) - gen_repo_files_CentOS "${SYSTEM_VERSION_ID_MAJOR}" + gen_repo_files_CentOSStream "${SYSTEM_VERSION_ID_MAJOR}" ;; esac ;; @@ -2222,20 +2227,7 @@ function change_mirrors_RedHat() { case "${SYSTEM_JUDGMENT}" in "${SYSTEM_RHEL}") case "${SYSTEM_VERSION_ID_MAJOR}" in - 9) - sed -e "s|^#baseurl=https|baseurl=${WEB_PROTOCOL}|g" \ - -e "s|^metalink=|#metalink=|g" \ - -e "s|mirror.stream.centos.org|${SOURCE}/${SOURCE_BRANCH}|g" \ - -i \ - centos.repo \ - centos-addons.repo - # 禁用 GPG 签名检查 - sed -e "s|gpgcheck=1|gpgcheck=0|g" \ - -i \ - centos.repo \ - centos-addons.repo - ;; - *) + 7 | 8) sed -e "s|^#baseurl=http|baseurl=${WEB_PROTOCOL}|g" \ -e "s|^mirrorlist=|#mirrorlist=|g" \ -i \ @@ -2265,6 +2257,19 @@ function change_mirrors_RedHat() { -i \ CentOS-* ;; + *) + sed -e "s|^#baseurl=https|baseurl=${WEB_PROTOCOL}|g" \ + -e "s|^metalink=|#metalink=|g" \ + -e "s|mirror.stream.centos.org|${SOURCE}/${SOURCE_BRANCH}|g" \ + -i \ + centos.repo \ + centos-addons.repo + # 禁用 GPG 签名检查 + sed -e "s|gpgcheck=1|gpgcheck=0|g" \ + -i \ + centos.repo \ + centos-addons.repo + ;; esac ;; "${SYSTEM_CENTOS}") @@ -2347,13 +2352,39 @@ function change_mirrors_RedHat() { ;; "${SYSTEM_ALMALINUX}") case "${SYSTEM_VERSION_ID_MAJOR}" in + 10) + sed -e "s|^# baseurl=https|baseurl=${WEB_PROTOCOL}|g" \ + -e "s|^mirrorlist=|#mirrorlist=|g" \ + -e "s|vault.almalinux.org|${SOURCE}/${SOURCE_BRANCH}|g" \ + -i \ + almalinux-appstream.repo \ + almalinux-baseos.repo \ + almalinux-crb.repo \ + almalinux-extras.repo \ + almalinux-highavailability.repo \ + almalinux-nfv.repo \ + almalinux-rt.repo \ + almalinux-saphana.repo \ + almalinux-sap.repo + + ;; 9) sed -e "s|^# baseurl=http|baseurl=${WEB_PROTOCOL}|g" \ -e "s|^mirrorlist=|#mirrorlist=|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" \ -i \ - almalinux-* + almalinux-appstream.repo \ + almalinux-baseos.repo \ + almalinux-crb.repo \ + almalinux-extras.repo \ + almalinux-highavailability.repo \ + almalinux-nfv.repo \ + almalinux-plus.repo \ + almalinux-resilientstorage.repo \ + almalinux-rt.repo \ + almalinux-sap.repo \ + almalinux-saphana.repo ;; 8) sed -e "s|^mirrorlist=|#mirrorlist=|g" \ @@ -4567,6 +4598,296 @@ EOF ## 生成 AlmaLinux repo 源文件 function gen_repo_files_AlmaLinux() { case "$1" in + 10) + cat <<'EOF' >$Dir_YumRepos/almalinux-appstream.repo +[appstream] +name=AlmaLinux $releasever - AppStream +mirrorlist=https://mirrors.almalinux.org/mirrorlist/$releasever/appstream +# baseurl=https://repo.almalinux.org/almalinux/$releasever/AppStream/$basearch/os/ +enabled=1 +gpgcheck=1 +countme=1 +gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-AlmaLinux-10 +metadata_expire=86400 +enabled_metadata=1 + +[appstream-debuginfo] +name=AlmaLinux $releasever - AppStream - Debug +mirrorlist=https://mirrors.almalinux.org/mirrorlist/$releasever/appstream-debug +# baseurl=https://vault.almalinux.org/$releasever/AppStream/debug/$basearch/ +enabled=0 +gpgcheck=1 +gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-AlmaLinux-10 +metadata_expire=86400 +enabled_metadata=0 + +[appstream-source] +name=AlmaLinux $releasever - AppStream - Source +mirrorlist=https://mirrors.almalinux.org/mirrorlist/$releasever/appstream-source +# baseurl=https://vault.almalinux.org/$releasever/AppStream/Source/ +enabled=0 +gpgcheck=1 +gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-AlmaLinux-10 +metadata_expire=86400 +enabled_metadata=0 +EOF + cat <<'EOF' >$Dir_YumRepos/almalinux-baseos.repo +[baseos] +name=AlmaLinux $releasever - BaseOS +mirrorlist=https://mirrors.almalinux.org/mirrorlist/$releasever/baseos +# baseurl=https://repo.almalinux.org/almalinux/$releasever/BaseOS/$basearch/os/ +enabled=1 +gpgcheck=1 +countme=1 +gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-AlmaLinux-10 +metadata_expire=86400 +enabled_metadata=1 + +[baseos-debuginfo] +name=AlmaLinux $releasever - BaseOS - Debug +mirrorlist=https://mirrors.almalinux.org/mirrorlist/$releasever/baseos-debug +# baseurl=https://vault.almalinux.org/$releasever/BaseOS/debug/$basearch/ +enabled=0 +gpgcheck=1 +gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-AlmaLinux-10 +metadata_expire=86400 +enabled_metadata=0 + +[baseos-source] +name=AlmaLinux $releasever - BaseOS - Source +mirrorlist=https://mirrors.almalinux.org/mirrorlist/$releasever/baseos-source +# baseurl=https://vault.almalinux.org/$releasever/BaseOS/Source/ +enabled=0 +gpgcheck=1 +gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-AlmaLinux-10 +metadata_expire=86400 +enabled_metadata=0 +EOF + cat <<'EOF' >$Dir_YumRepos/almalinux-crb.repo +[crb] +name=AlmaLinux $releasever - CRB +mirrorlist=https://mirrors.almalinux.org/mirrorlist/$releasever/crb +# baseurl=https://repo.almalinux.org/almalinux/$releasever/CRB/$basearch/os/ +enabled=0 +gpgcheck=1 +countme=1 +gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-AlmaLinux-10 +metadata_expire=86400 +enabled_metadata=0 + +[crb-debuginfo] +name=AlmaLinux $releasever - CRB - Debug +mirrorlist=https://mirrors.almalinux.org/mirrorlist/$releasever/crb-debug +# baseurl=https://vault.almalinux.org/$releasever/CRB/debug/$basearch/ +enabled=0 +gpgcheck=1 +gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-AlmaLinux-10 +metadata_expire=86400 +enabled_metadata=0 + +[crb-source] +name=AlmaLinux $releasever - CRB - Source +mirrorlist=https://mirrors.almalinux.org/mirrorlist/$releasever/crb-source +# baseurl=https://vault.almalinux.org/$releasever/CRB/Source/ +enabled=0 +gpgcheck=1 +gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-AlmaLinux-10 +metadata_expire=86400 +enabled_metadata=0 +EOF + cat <<'EOF' >$Dir_YumRepos/almalinux-extras.repo +[extras] +name=AlmaLinux $releasever - Extras +mirrorlist=https://mirrors.almalinux.org/mirrorlist/$releasever/extras +# baseurl=https://repo.almalinux.org/almalinux/$releasever/extras/$basearch/os/ +enabled=1 +gpgcheck=1 +countme=1 +gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-AlmaLinux-10 +metadata_expire=86400 +enabled_metadata=0 + +[extras-debuginfo] +name=AlmaLinux $releasever - Extras - Debug +mirrorlist=https://mirrors.almalinux.org/mirrorlist/$releasever/extras-debug +# baseurl=https://vault.almalinux.org/$releasever/extras/debug/$basearch/ +enabled=0 +gpgcheck=1 +gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-AlmaLinux-10 +metadata_expire=86400 +enabled_metadata=0 + +[extras-source] +name=AlmaLinux $releasever - Extras - Source +mirrorlist=https://mirrors.almalinux.org/mirrorlist/$releasever/extras-source +# baseurl=https://vault.almalinux.org/$releasever/extras/Source/ +enabled=0 +gpgcheck=1 +gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-AlmaLinux-10 +metadata_expire=86400 +enabled_metadata=0 +EOF + cat <<'EOF' >$Dir_YumRepos/almalinux-highavailability.repo +[highavailability] +name=AlmaLinux $releasever - HighAvailability +mirrorlist=https://mirrors.almalinux.org/mirrorlist/$releasever/highavailability +# baseurl=https://repo.almalinux.org/almalinux/$releasever/HighAvailability/$basearch/os/ +enabled=0 +gpgcheck=1 +countme=1 +gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-AlmaLinux-10 +metadata_expire=86400 +enabled_metadata=0 + +[highavailability-debuginfo] +name=AlmaLinux $releasever - HighAvailability - Debug +mirrorlist=https://mirrors.almalinux.org/mirrorlist/$releasever/highavailability-debug +# baseurl=https://vault.almalinux.org/$releasever/HighAvailability/debug/$basearch/ +enabled=0 +gpgcheck=1 +gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-AlmaLinux-10 +metadata_expire=86400 +enabled_metadata=0 + +[highavailability-source] +name=AlmaLinux $releasever - HighAvailability - Source +mirrorlist=https://mirrors.almalinux.org/mirrorlist/$releasever/highavailability-source +# baseurl=https://vault.almalinux.org/$releasever/HighAvailability/Source/ +enabled=0 +gpgcheck=1 +gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-AlmaLinux-10 +metadata_expire=86400 +enabled_metadata=0 +EOF + cat <<'EOF' >$Dir_YumRepos/almalinux-nfv.repo +[nfv] +name=AlmaLinux $releasever - NFV +mirrorlist=https://mirrors.almalinux.org/mirrorlist/$releasever/nfv +# baseurl=https://repo.almalinux.org/almalinux/$releasever/NFV/$basearch/os/ +enabled=0 +gpgcheck=1 +countme=1 +gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-AlmaLinux-10 +metadata_expire=86400 +enabled_metadata=0 + +[nfv-debuginfo] +name=AlmaLinux $releasever - NFV - Debug +mirrorlist=https://mirrors.almalinux.org/mirrorlist/$releasever/nfv-debug +# baseurl=https://vault.almalinux.org/$releasever/NFV/debug/$basearch/ +enabled=0 +gpgcheck=1 +gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-AlmaLinux-10 +metadata_expire=86400 +enabled_metadata=0 + +[nfv-source] +name=AlmaLinux $releasever - NFV - Source +mirrorlist=https://mirrors.almalinux.org/mirrorlist/$releasever/nfv-source +# baseurl=https://vault.almalinux.org/$releasever/NFV/Source/ +enabled=0 +gpgcheck=1 +gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-AlmaLinux-10 +metadata_expire=86400 +enabled_metadata=0 +EOF + cat <<'EOF' >$Dir_YumRepos/almalinux-rt.repo +[rt] +name=AlmaLinux $releasever - RT +mirrorlist=https://mirrors.almalinux.org/mirrorlist/$releasever/rt +# baseurl=https://repo.almalinux.org/almalinux/$releasever/RT/$basearch/os/ +enabled=0 +gpgcheck=1 +countme=1 +gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-AlmaLinux-10 +metadata_expire=86400 +enabled_metadata=0 + +[rt-debuginfo] +name=AlmaLinux $releasever - RT - Debug +mirrorlist=https://mirrors.almalinux.org/mirrorlist/$releasever/rt-debug +# baseurl=https://vault.almalinux.org/$releasever/RT/debug/$basearch/ +enabled=0 +gpgcheck=1 +gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-AlmaLinux-10 +metadata_expire=86400 +enabled_metadata=0 + +[rt-source] +name=AlmaLinux $releasever - RT - Source +mirrorlist=https://mirrors.almalinux.org/mirrorlist/$releasever/rt-source +# baseurl=https://vault.almalinux.org/$releasever/RT/Source/ +enabled=0 +gpgcheck=1 +gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-AlmaLinux-10 +metadata_expire=86400 +enabled_metadata=0 +EOF + cat <<'EOF' >$Dir_YumRepos/almalinux-saphana.repo +[saphana] +name=AlmaLinux $releasever - SAPHANA +mirrorlist=https://mirrors.almalinux.org/mirrorlist/$releasever/saphana +# baseurl=https://repo.almalinux.org/almalinux/$releasever/SAPHANA/$basearch/os/ +enabled=0 +gpgcheck=1 +countme=1 +gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-AlmaLinux-10 +metadata_expire=86400 +enabled_metadata=0 + +[saphana-debuginfo] +name=AlmaLinux $releasever - SAPHANA - Debug +mirrorlist=https://mirrors.almalinux.org/mirrorlist/$releasever/saphana-debug +# baseurl=https://vault.almalinux.org/$releasever/SAPHANA/debug/$basearch/ +enabled=0 +gpgcheck=1 +gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-AlmaLinux-10 +metadata_expire=86400 +enabled_metadata=0 + +[saphana-source] +name=AlmaLinux $releasever - SAPHANA - Source +mirrorlist=https://mirrors.almalinux.org/mirrorlist/$releasever/saphana-source +# baseurl=https://vault.almalinux.org/$releasever/SAPHANA/Source/ +enabled=0 +gpgcheck=1 +gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-AlmaLinux-10 +metadata_expire=86400 +enabled_metadata=0 +EOF + cat <<'EOF' >$Dir_YumRepos/almalinux-sap.repo +[sap] +name=AlmaLinux $releasever - SAP +mirrorlist=https://mirrors.almalinux.org/mirrorlist/$releasever/sap +# baseurl=https://repo.almalinux.org/almalinux/$releasever/SAP/$basearch/os/ +enabled=0 +gpgcheck=1 +countme=1 +gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-AlmaLinux-10 +metadata_expire=86400 +enabled_metadata=0 + +[sap-debuginfo] +name=AlmaLinux $releasever - SAP - Debug +mirrorlist=https://mirrors.almalinux.org/mirrorlist/$releasever/sap-debug +# baseurl=https://vault.almalinux.org/$releasever/SAP/debug/$basearch/ +enabled=0 +gpgcheck=1 +gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-AlmaLinux-10 +metadata_expire=86400 +enabled_metadata=0 + +[sap-source] +name=AlmaLinux $releasever - SAP - Source +mirrorlist=https://mirrors.almalinux.org/mirrorlist/$releasever/sap-source +# baseurl=https://vault.almalinux.org/$releasever/SAP/Source/ +enabled=0 +gpgcheck=1 +gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-AlmaLinux-10 +metadata_expire=86400 +enabled_metadata=0 +EOF + ;; 9) cat <<'EOF' >$Dir_YumRepos/almalinux-appstream.repo [appstream] diff --git a/DockerInstallation.sh b/DockerInstallation.sh index 01e6109..ab6db4d 100755 --- a/DockerInstallation.sh +++ b/DockerInstallation.sh @@ -1,6 +1,6 @@ #!/bin/bash ## Author: SuperManito -## Modified: 2025-05-19 +## Modified: 2025-05-29 ## License: MIT ## GitHub: https://github.com/SuperManito/LinuxMirrors ## Website: https://linuxmirrors.cn @@ -446,6 +446,10 @@ function collect_system_info() { fi ;; "${SYSTEM_REDHAT}") + # 拦截最新的红帽 10 版本 + if [[ "${SYSTEM_VERSION_ID_MAJOR}" == 10 ]]; then + output_error "暂不支持当前操作系统,请等待官方适配 10 版本!" + fi SYSTEM_JUDGMENT="$(awk '{printf $1}' $File_RedHatRelease)" # 拦截 Anolis OS 8.8 以下版本,不支持从 Docker 官方仓库安装 if [[ "${SYSTEM_JUDGMENT}" == "${SYSTEM_ANOLISOS}" ]]; then @@ -506,9 +510,6 @@ function collect_system_info() { "${SYSTEM_UBUNTU}" | "${SYSTEM_ZORIN}") SOURCE_BRANCH="ubuntu" ;; - "${SYSTEM_RHEL}") - SOURCE_BRANCH="rhel" - ;; "${SYSTEM_RASPBERRY_PI_OS}") case "${DEVICE_ARCH_RAW}" in x86_64 | aarch64) diff --git a/README.md b/README.md index 99d1578..0ea4f98 100644 --- a/README.md +++ b/README.md @@ -63,7 +63,7 @@  Red Hat Enterprise Linux - 7 ~ 9 + 7 ~ 10  Fedora @@ -79,7 +79,7 @@  AlmaLinux - 8 ~ 9 + 8 ~ 10  openEuler(开源欧拉) @@ -132,19 +132,19 @@ ### GNU/Linux 更换系统软件源 ```bash -bash <(curl -sSL https://raw.githubusercontent.com/SuperManito/LinuxMirrors/main/ChangeMirrors.sh) +bash <(curl -sSL https://linuxmirrors.cn/main.sh) ``` ### Docker 安装与换源 ```bash -bash <(curl -sSL https://raw.githubusercontent.com/SuperManito/LinuxMirrors/main/DockerInstallation.sh) +bash <(curl -sSL https://linuxmirrors.cn/docker.sh) ``` -### 更换 Docker 镜像加速器 +### Docker 更换镜像加速器 ```bash -bash <(curl -sSL https://raw.githubusercontent.com/SuperManito/LinuxMirrors/main/DockerInstallation.sh) --only-registry +bash <(curl -sSL https://linuxmirrors.cn/docker.sh) --only-registry ``` > 项目官方网站集成了 AI 聊天与搜索,更多使用方法详见 [**linuxmirrors.cn**](https://linuxmirrors.cn/use) diff --git a/docs/index.md b/docs/index.md index 3fb239a..7ccf664 100644 --- a/docs/index.md +++ b/docs/index.md @@ -1,142 +1,142 @@ ---- -title: 一键脚本使换源更简单 -description: GNU/Linux 更换系统软件源脚本及 Docker 安装与换源脚本 -comments: true -glightbox: false -comments_description: 该评论区仅用于展示项目使用评价和经验分享,反馈问题或提出建议请前往社区 -hide: - - navigation - - toc - - feedback - - footer ---- - -
-
-
- - -
- LinuxMirrors - LinuxMirrors -
GNU/Linux 更换系统软件源脚本及 Docker 安装与换源脚本
-
一键脚本使换源更简单
-
-
-=== "GNU/Linux" - - command-linux - command-linux - - - -=== "Docker" - - command-docker - command-docker - - - -
-
- -
- -
- -- :material-thumb-up-outline:{ .lg .middle } __轻松使用__ - - --- - - 只需要一行命令就能直接运行,零技术门槛,无需安装任何依赖 - 文档集成了 AI 搜索与聊天,提供各种场景的解决方案 - -- :material-vector-polyline:{ .lg .middle } __系统支持广泛__ - - --- - - 已适配高达 `23+` 操作系统,涵盖各类版本,精准识别系统类型 - 脚本兼容性高,不支持的系统会有相应提示并无操作跳出 - -- :material-vector-triangle:{ .lg .middle } __多元软件源适配__ - - --- - - 深入考察了国内镜像站的系统适配情况,专为中国宝宝打造 - 还提供全网搜集的国内教育网和海外镜像站供用户选择 - -- :material-rocket-launch-outline:{ .lg .middle } __快,且高效__ - - --- - - 最快仅需 10 秒即可完成软件源的更换,高效运维,节省大量时间成本 - 项目经过数年的迭代与优化,脚本运行稳定性能卓越,场景判断完善 - -- :octicons-globe-24:{ .lg .middle } __全球网络,调用无忧__ - - --- - - 本网站提供全球边缘网络加速,不惧各种网络环境,国内轻松访问 - 同时提供了多个备用地址以确保项目脚本始终可用,真正做到使用无忧 - -- :material-arm-flex-outline:{ .lg .middle } __功能强大,无以伦比__ - - --- - - 脚本通过方向键交互逐步引导用户选择软件源配置,使换源更简单 - 此外脚本提供了丰富的命令选项,可实现各种自定义需求 - -- :material-pencil-ruler-outline:{ .lg .middle } __高度可定制__ - - --- - - 脚本命令选项遵循正式应用程序规范设计,能够满足各种高级需求 - 代码结构清晰,易于阅读和修改,支持克隆后定制 - -- :material-scale-balance:{ .lg .middle } __自由,开源__ - - --- - - 项目已设立 MIT 开源许可协议,脚本代码完全开源且免费使用 - 请尊重作者的知识成果,传播时请在显著位置标注来源或项目地址 - -
- -
- -| 操作系统 | 适配版本 | -| --- | :---: | -| Debian | _8~13_ | -| Ubuntu :material-information-outline:{ title="支持乌班图家族衍生操作系统,例如 优麒麟 Kubuntu
由于迭代速度较快并不直接支持所有非 LTS 的版本,具体详见文档" } | _14~25_ | -| Kali Linux | _all_ | -| Linux Mint | _19~22 / LMDE 6_ | -| Deepin(深度) | _all_ | -| Zorin OS | _all_ | -| Armbian | _all_ | -| Proxmox VE | _all_ | -| Raspberry Pi OS | _all_ | -| Red Hat Enterprise Linux :material-information-outline:{ title="使用 CentOS StreamCentOS 源" } | _7~9_ | -| Fedora | _30~42_ | -| CentOS | _7~8 / Stream 8~10_ | -| Rocky Linux | _8~9_ | -| AlmaLinux | _8~9_ | -| openEuler(开源欧拉) | _21~25_ | -| OpenCloudOS(鸥栖) | _8.6~9 / Stream 23_ | -| openKylin(开放麒麟) | _all_ | -| Anolis OS(龙蜥) | _8 / 23_ | -| openSUSE | _Leep 15 / Tumbleweed_ | -| Arch Linux | _all_ | -| Alpine Linux | _v3 / edge_ | -| Gentoo | _all_ | -| NixOS | _19~24_ | - -
-
- -
-[开 始 使 用](use/index.md){ .md-button .md-button--primary }   [查看软件源列表](mirrors/index.md){ .md-button } -
- ---8<-- "docs/sponsor/main.html" - - +--- +title: 一键脚本使换源更简单 +description: GNU/Linux 更换系统软件源脚本及 Docker 安装与换源脚本 +comments: true +glightbox: false +comments_description: 该评论区仅用于展示项目使用评价和经验分享,反馈问题或提出建议请前往社区 +hide: + - navigation + - toc + - feedback + - footer +--- + +
+
+
+ + +
+ LinuxMirrors + LinuxMirrors +
GNU/Linux 更换系统软件源脚本及 Docker 安装与换源脚本
+
一键脚本使换源更简单
+
+
+=== "GNU/Linux" + + command-linux + command-linux + + + +=== "Docker" + + command-docker + command-docker + + + +
+
+ +
+ +
+ +- :material-thumb-up-outline:{ .lg .middle } __轻松使用__ + + --- + + 只需要一行命令就能直接运行,零技术门槛,无需安装任何依赖 + 文档集成了 AI 搜索与聊天,提供各种场景的解决方案 + +- :material-vector-polyline:{ .lg .middle } __系统支持广泛__ + + --- + + 已适配高达 `23+` 操作系统,涵盖各类版本,精准识别系统类型 + 脚本兼容性高,不支持的系统会有相应提示并无操作跳出 + +- :material-vector-triangle:{ .lg .middle } __多元软件源适配__ + + --- + + 深入考察了国内镜像站的系统适配情况,专为中国宝宝打造 + 还提供全网搜集的国内教育网和海外镜像站供用户选择 + +- :material-rocket-launch-outline:{ .lg .middle } __快,且高效__ + + --- + + 最快仅需 10 秒即可完成软件源的更换,高效运维,节省大量时间成本 + 项目经过数年的迭代与优化,脚本运行稳定性能卓越,场景判断完善 + +- :octicons-globe-24:{ .lg .middle } __全球网络,调用无忧__ + + --- + + 本网站提供全球边缘网络加速,不惧各种网络环境,国内轻松访问 + 同时提供了多个备用地址以确保项目脚本始终可用,真正做到使用无忧 + +- :material-arm-flex-outline:{ .lg .middle } __功能强大,无以伦比__ + + --- + + 脚本通过方向键交互逐步引导用户选择软件源配置,使换源更简单 + 此外脚本提供了丰富的命令选项,可实现各种自定义需求 + +- :material-pencil-ruler-outline:{ .lg .middle } __高度可定制__ + + --- + + 脚本命令选项遵循正式应用程序规范设计,能够满足各种高级需求 + 代码结构清晰,易于阅读和修改,支持克隆后定制 + +- :material-scale-balance:{ .lg .middle } __自由,开源__ + + --- + + 项目已设立 MIT 开源许可协议,脚本代码完全开源且免费使用 + 请尊重作者的知识成果,传播时请在显著位置标注来源或项目地址 + +
+ +
+ +| 操作系统 | 适配版本 | +| --- | :---: | +| Debian | _8~13_ | +| Ubuntu :material-information-outline:{ title="支持乌班图家族衍生操作系统,例如 优麒麟 Kubuntu
由于迭代速度较快并不直接支持所有非 LTS 的版本,具体详见文档" } | _14~25_ | +| Kali Linux | _all_ | +| Linux Mint | _19~22 / LMDE 6_ | +| Deepin(深度) | _all_ | +| Zorin OS | _all_ | +| Armbian | _all_ | +| Proxmox VE | _all_ | +| Raspberry Pi OS | _all_ | +| Red Hat Enterprise Linux :material-information-outline:{ title="使用 CentOS StreamCentOS 源" } | _7~10_ | +| Fedora | _30~42_ | +| CentOS | _7~8 / Stream 8~10_ | +| Rocky Linux | _8~9_ | +| AlmaLinux | _8~10_ | +| openEuler(开源欧拉) | _21~25_ | +| OpenCloudOS(鸥栖) | _8.6~9 / Stream 23_ | +| openKylin(开放麒麟) | _all_ | +| Anolis OS(龙蜥) | _8 / 23_ | +| openSUSE | _Leep 15 / Tumbleweed_ | +| Arch Linux | _all_ | +| Alpine Linux | _v3 / edge_ | +| Gentoo | _all_ | +| NixOS | _19~24_ | + +
+
+ +
+[开 始 使 用](use/index.md){ .md-button .md-button--primary }   [查看软件源列表](mirrors/index.md){ .md-button } +
+ +--8<-- "docs/sponsor/main.html" + + diff --git a/docs/other/index.md b/docs/other/index.md index af78213..82862a8 100644 --- a/docs/other/index.md +++ b/docs/other/index.md @@ -5,8 +5,6 @@ hide: - footer --- -> _如果觉得这个项目不错对您有所帮助的话,请点击仓库右上角的 Star 并分享给更多的朋友_ :octicons-heart-fill-24:{ .heart } - !!! tip inline end "本项目已被众多流行项目使用,广受社区用户好评" ## :simple-docker:{style="color: #1d63ed"} Docker 安装与换源脚本 diff --git a/docs/stylesheets/extra.css b/docs/stylesheets/extra.css index b6c393b..2838a8f 100644 --- a/docs/stylesheets/extra.css +++ b/docs/stylesheets/extra.css @@ -1,454 +1,464 @@ -:root { - --md-text-font: system-ui, -apple-system, 'Roboto', 'PingFang SC', 'Microsoft YaHei', 'Hiragino Sans GB', 'Segoe UI', Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; - --md-code-font: 'SF Mono'; - --md-primary-fg-color--light: hsl(0, 0%, 100%, 0.33); - --md-default-bg-color--light: #fff; - --md-default-bg-color--dark: hsla(var(--md-hue), 15%, 14%, 1); - --view-transition-z-index-foreground: 999; - --view-transition-z-index-background: 1; - --hero-background-image: linear-gradient(90deg, rgb(104 104 104) 50%, rgb(104 104 104) 50%); -} - -[data-md-color-scheme='slate'] { - --hero-background-image: linear-gradient(90deg, rgb(114 114 114) 50%, rgb(114 114 114) 50%); -} - -[data-md-color-primary=white] { - --md-typeset-a-color: #2080f0; -} - -[data-md-color-scheme='slate'][data-md-color-primary=black] { - --md-typeset-a-color: #2080f0; -} - -/* logo */ -[data-md-color-scheme="default"] .md-logo img { - content: url(/assets/images/brand/svg/logo-light.svg); -} - -[data-md-color-scheme="slate"] .md-logo img { - content: url(/assets/images/brand/svg/logo-dark.svg); -} - -/* 字体 */ -@font-face { - font-family: 'SF Mono'; - src: url('./fonts/SF-Mono-Regular.otf'); -} - -/* 告诫 */ - -.md-typeset .admonition, -.md-typeset details { - border-width: 0; - border-left-width: 4px; -} - -.md-typeset .admonition.quote, -.md-typeset details.quote { - border-width: .075rem !important; - border-color: var(--md-default-fg-color--lightest) !important; -} - -[data-md-color-scheme='slate'] .md-typeset .admonition, -[data-md-color-scheme='slate'] .md-typeset details { - box-shadow: var(--md-shadow-z2) !important; -} - -[data-md-color-scheme='slate'] .md-typeset .admonition.quote, -[data-md-color-scheme='slate'] .md-typeset details.quote { - border-color: var(--md-default-fg-color--lightest) !important; -} - -.md-typeset .admonition.tip, -.md-typeset details.tip { - border-color: #03b803; -} - -.md-typeset .tip>.admonition-title:before, -.md-typeset .tip>summary:before { - background-color: #03b803; -} - -.md-typeset .tip>.admonition-title, -.md-typeset .tip>summary { - background-color: #0094001a; -} - -.md-typeset .admonition.tip:focus-within, -.md-typeset details.tip:focus-within { - box-shadow: 0 0 0 .2rem #0094000a; -} - -[data-md-color-scheme="slate"] .md-typeset .admonition.quote, -.md-typeset details.quote { - border-color: hsla(225deg, 15%, 90%, 0.24); -} - -/* 着陆页 */ -.home-cmd pre>code { - padding-right: 3em; -} - -.home-cmd .md-clipboard { - top: calc(100% - 60px); -} - -@media screen and (max-width: 768px) { - .home-cmd .md-clipboard { - top: calc(100% - 50px); - } -} - -/* 主题覆盖 */ -.no-select img { - user-select: none; - -webkit-user-select: none; - -webkit-user-drag: none; -} - -.md-header { - background-color: hsla(240, 9%, 75%, 0.33); - -webkit-backdrop-filter: blur(8px); - backdrop-filter: blur(8px); - z-index: 999 !important; -} - -[data-md-color-scheme='slate'] .md-header { - background-color: hsla(var(--md-hue), 15%, 9%, 0.33); -} - -.md-tabs { - background-color: hsla(240, 9%, 75%, 0.33); -} - -[data-md-color-scheme='slate'] .md-tabs { - background-color: hsla(var(--md-hue), 15%, 9%, 0.33); -} - -@media screen and (max-width: 768px) { - .md-typeset .admonition .tabbed-set { - width: calc(100vw - 3rem - 2px); - } - - .md-typeset .admonition .tabbed-labels { - width: calc(100vw - 3rem - 1.2rem); - padding-left: .6rem; - } -} - -.md-tabs__link { - font-size: 0.8rem !important; - font-weight: 600 !important; -} - -.md-typeset { - font-size: 16px; -} - -.md-typeset .emojione, -.md-typeset .gemoji, -.md-typeset .twemoji { - height: 100%; - vertical-align: -0.2em !important; -} - -.md-typeset .middle { - vertical-align: -0.35em !important; -} - -/* HERO */ -.hero { - width: 390px; - max-width: 100vw; - height: 160px; - position: absolute; - margin: 0 auto; -} - -.hero-background { - top: 50%; - width: 50%; - height: 80px; - position: absolute; - background-image: var(--hero-background-image); - filter: blur(68px); - transform: translate(-50%, -50%); -} - -@media screen and (max-width: 768px) { - .hero { - width: calc(100% - .8rem - 40px); - } -} - -/* 赞助组件 */ -.sponsor { - padding-top: 1rem; - margin-top: 0; - border-top: none; -} - -.sponsor-title { - font-size: 1.2rem; - font-weight: 550; - font-feature-settings: "kern", "liga"; - color: #444; - font-family: var(--md-text-font-family); -} - -[data-md-color-scheme="slate"] .sponsor-title { - color: #ddd; -} - -.sponsor-title-toc { - font-weight: 550; - font-feature-settings: "kern", "liga"; - color: hsl(225deg 0% 46.48% / 56%); - font-family: var(--md-text-font-family); -} - -[data-md-color-scheme="slate"] .sponsor-title-toc { - color: hsl(225deg 5.64% 68.32% / 56%); -} - -.sponsor-toc { - margin-top: 24px !important; - border-top: 1px solid var(--md-default-fg-color--lightest) !important; -} - -.sponsor .sponsor-label { - font-size: 0.8rem; - text-align: center; - margin-bottom: 0.2rem; - color: var(--md-default-fg-color); -} - -.sponsor .sponsor-wrapper { - width: 100%; - padding: 0.5rem 0; -} - -.sponsor .sponsor-item { - display: flex; - align-items: center; - justify-content: center; - width: 100%; - text-align: center; - padding: 1rem; - border-radius: 6px; - height: 80px; - max-height: 80px; - transition: background-color 0.2s, filter 0.3s ease-in-out, opacity 0.3s ease-in-out !important; -} - -.sponsor .sponsor-item:hover { - background-color: rgba(0, 0, 0, 0.03); -} - -[data-md-color-scheme="slate"] .sponsor .sponsor-item:hover { - background-color: rgba(240, 241, 244, 0.024); -} - -.sponsor .sponsor-item img { - max-width: 100%; - height: auto; - vertical-align: middle; -} - -.sponsor-item-toc { - margin: 0; - padding: 14px !important; - height: 62px !important; - border-radius: 4px !important; - box-sizing: border-box; - flex: 0 0 calc(50% - 2px) !important; - background-color: var(--md-code-bg-color); -} - -.sponsor-item-toc:hover { - background-color: rgba(0, 0, 0, 0.08) !important; -} - -[data-md-color-scheme="slate"] .sponsor-item-toc:hover { - background-color: rgba(240, 241, 244, 0.1) !important; -} - -.sponsor-item-toc-full-row { - flex: 0 0 100% !important; -} - -.sponsor-item-toc-full-row img { - width: 50% !important; -} - -.sponsor-item-toc img { - width: 100%; - object-fit: contain; - filter: grayscale(1) invert(0.6); - opacity: 0.7; -} - -[data-md-color-scheme="slate"] .sponsor-item-toc img { - filter: brightness(1.3) grayscale(1); - opacity: 0.75; -} - -.sponsor-item-toc:hover img { - filter: grayscale(0%) !important; - opacity: 1; -} - -.sponsor-flex-wrapper { - display: flex; - flex-wrap: wrap; - gap: 1rem; - justify-content: center; -} - -.sponsor-flex-wrapper-toc { - display: flex !important; - flex-direction: row !important; - flex-wrap: wrap !important; - gap: 4px !important; - padding: 0; - width: 100%; -} - -.sponsor-item-flex { - flex: 0 1 calc(33.33% - 1rem); - min-width: 200px; - max-width: 300px; -} - -.sponsor-item-flex img { - width: 60% !important; -} - -@media screen and (max-width: 480px) { - .sponsor-flex-wrapper { - gap: 24px; - } - - .sponsor-title { - font-size: .8rem; - } - - .sponsor .sponsor-item { - height: 40px; - padding: 2px; - } - - .sponsor-toc { - display: none; - } - - .sponsor-item-flex { - flex: 0 1 calc(33.33% - 1rem); - min-width: 100px; - max-width: calc(33.33% - 1rem); - } - - .sponsor-item-flex img { - transform: scale(1.4); - } -} - -/* 图标动画 */ -.heart { - animation: heart 1000ms infinite; -} - -@keyframes heart { - - 0%, - 40%, - 80%, - 100% { - transform: scale(1); - } - - 20%, - 60% { - transform: scale(1.15); - } -} - -/* TDesign 组件相关 */ -.t-tag .t-icon { - margin-right: 0 !important; -} - -[theme-mode="dark"] .t-table { - --td-bg-color-container: hsla(var(--md-hue), 15%, 14%, 1) !important; - --td-component-border: hsla(225deg, 15%, 95%, 0.12) !important; -} - -[theme-mode="dark"] .t-tag { - --td-warning-color-light: #cf6e2d48 !important; -} - -.t-table--hoverable tbody tr:hover { - background-color: rgba(0, 0, 0, 0.016) !important; -} - -[theme-mode="dark"] .t-table--hoverable tbody tr:hover { - background-color: rgba(240, 241, 244, 0.016) !important; -} - -.t-table--column-fixed .t-table__cell--fixed-left { - z-index: 4; -} - -/* termynal 插件 */ -.termy { - padding: 65px 25px 35px !important; -} - -[data-termynal] { - color: #000 !important; - background: #f7f7f7 !important; - box-shadow: var(--md-shadow-z2); - font-size: 14px !important; -} - -[data-md-color-scheme="slate"] [data-termynal] { - color: #eeeeee !important; - background: #21252c !important; - box-shadow: var(--md-shadow-z2); -} - -button[data-terminal-control] { - color: var(--md-typeset-a-color) !important; -} - -[data-termynal]:after { - color: #585858 !important; -} - -[data-md-color-scheme="slate"] [data-termynal]:after { - color: #a2a2a2 !important; -} - -/* 切换主题动画 */ -::view-transition-old(root), -::view-transition-new(root) { - animation: none; - mix-blend-mode: normal; -} - -.dark::view-transition-old(root) { - z-index: var(--view-transition-z-index-foreground); -} - -.dark::view-transition-new(root) { - z-index: var(--view-transition-z-index-background); -} - -::view-transition-old(root) { - z-index: var(--view-transition-z-index-background) -} - -::view-transition-new(root) { - z-index: var(--view-transition-z-index-foreground); +:root { + --md-text-font: system-ui, -apple-system, 'Roboto', 'PingFang SC', 'Microsoft YaHei', 'Hiragino Sans GB', 'Segoe UI', Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; + --md-code-font: 'SF Mono'; + --md-primary-fg-color--light: hsl(0, 0%, 100%, 0.33); + --md-default-bg-color--light: #fff; + --md-default-bg-color--dark: hsla(var(--md-hue), 15%, 14%, 1); + --view-transition-z-index-foreground: 999; + --view-transition-z-index-background: 1; + --hero-background-image: linear-gradient(90deg, rgb(104 104 104) 50%, rgb(104 104 104) 50%); +} + +[data-md-color-scheme='slate'] { + --hero-background-image: linear-gradient(90deg, rgb(114 114 114) 50%, rgb(114 114 114) 50%); +} + +[data-md-color-primary=white] { + --md-typeset-a-color: #2080f0; +} + +[data-md-color-scheme='slate'][data-md-color-primary=black] { + --md-typeset-a-color: #2080f0; +} + +/* logo */ +[data-md-color-scheme="default"] .md-logo img { + content: url(/assets/images/brand/svg/logo-light.svg); +} + +[data-md-color-scheme="slate"] .md-logo img { + content: url(/assets/images/brand/svg/logo-dark.svg); +} + +/* 字体 */ +@font-face { + font-family: 'SF Mono'; + src: url('./fonts/SF-Mono-Regular.otf'); +} + +/* 告诫 */ + +.md-typeset .admonition, +.md-typeset details { + border-width: 0; + border-left-width: 4px; +} + +.md-typeset .admonition.quote, +.md-typeset details.quote { + border-width: .075rem !important; + border-color: var(--md-default-fg-color--lightest) !important; +} + +[data-md-color-scheme='slate'] .md-typeset .admonition, +[data-md-color-scheme='slate'] .md-typeset details { + box-shadow: var(--md-shadow-z2) !important; +} + +[data-md-color-scheme='slate'] .md-typeset .admonition.quote, +[data-md-color-scheme='slate'] .md-typeset details.quote { + border-color: var(--md-default-fg-color--lightest) !important; +} + +.md-typeset .admonition.tip, +.md-typeset details.tip { + border-color: #03b803; +} + +.md-typeset .tip>.admonition-title:before, +.md-typeset .tip>summary:before { + background-color: #03b803; +} + +.md-typeset .tip>.admonition-title, +.md-typeset .tip>summary { + background-color: #0094001a; +} + +.md-typeset .admonition.tip:focus-within, +.md-typeset details.tip:focus-within { + box-shadow: 0 0 0 .2rem #0094000a; +} + +[data-md-color-scheme="slate"] .md-typeset .admonition.quote, +.md-typeset details.quote { + border-color: hsla(225deg, 15%, 90%, 0.24); +} + +/* 着陆页 */ +.home-cmd pre>code { + padding-right: 3em; +} + +.home-cmd .md-clipboard { + top: calc(100% - 60px); +} + +@media screen and (max-width: 768px) { + .home-cmd .md-clipboard { + top: calc(100% - 50px); + } +} + +/* 主题覆盖 */ +.no-select img { + user-select: none; + -webkit-user-select: none; + -webkit-user-drag: none; +} + +.md-header { + background-color: hsla(240, 9%, 75%, 0.33); + -webkit-backdrop-filter: blur(8px); + backdrop-filter: blur(8px); + z-index: 999 !important; +} + +[data-md-color-scheme='slate'] .md-header { + background-color: hsla(var(--md-hue), 15%, 9%, 0.33); +} + +.md-tabs { + background-color: hsla(240, 9%, 75%, 0.33); +} + +[data-md-color-scheme='slate'] .md-tabs { + background-color: hsla(var(--md-hue), 15%, 9%, 0.33); +} + +.md-banner { + font-style: italic; + color: var(--md-default-fg-color--light); + background-color: hsla(240, 9%, 75%, 0.53); +} + +[data-md-color-scheme='slate'] .md-banner { + background-color: hsla(var(--md-hue), 15%, 9%, 0.83); +} + +@media screen and (max-width: 768px) { + .md-typeset .admonition .tabbed-set { + width: calc(100vw - 3rem - 2px); + } + + .md-typeset .admonition .tabbed-labels { + width: calc(100vw - 3rem - 1.2rem); + padding-left: .6rem; + } +} + +.md-tabs__link { + font-size: 0.8rem !important; + font-weight: 600 !important; +} + +.md-typeset { + font-size: 16px; +} + +.md-typeset .emojione, +.md-typeset .gemoji, +.md-typeset .twemoji { + height: 100%; + vertical-align: -0.2em !important; +} + +.md-typeset .middle { + vertical-align: -0.35em !important; +} + +/* HERO */ +.hero { + width: 390px; + max-width: 100vw; + height: 160px; + position: absolute; + margin: 0 auto; +} + +.hero-background { + top: 50%; + width: 50%; + height: 80px; + position: absolute; + background-image: var(--hero-background-image); + filter: blur(68px); + transform: translate(-50%, -50%); +} + +@media screen and (max-width: 768px) { + .hero { + width: calc(100% - .8rem - 40px); + } +} + +/* 赞助组件 */ +.sponsor { + padding-top: 1rem; + margin-top: 0; + border-top: none; +} + +.sponsor-title { + font-size: 1.2rem; + font-weight: 550; + font-feature-settings: "kern", "liga"; + color: #444; + font-family: var(--md-text-font-family); +} + +[data-md-color-scheme="slate"] .sponsor-title { + color: #ddd; +} + +.sponsor-title-toc { + font-weight: 550; + font-feature-settings: "kern", "liga"; + color: hsl(225deg 0% 46.48% / 56%); + font-family: var(--md-text-font-family); +} + +[data-md-color-scheme="slate"] .sponsor-title-toc { + color: hsl(225deg 5.64% 68.32% / 56%); +} + +.sponsor-toc { + margin-top: 24px !important; + border-top: 1px solid var(--md-default-fg-color--lightest) !important; +} + +.sponsor .sponsor-label { + font-size: 0.8rem; + text-align: center; + margin-bottom: 0.2rem; + color: var(--md-default-fg-color); +} + +.sponsor .sponsor-wrapper { + width: 100%; + padding: 0.5rem 0; +} + +.sponsor .sponsor-item { + display: flex; + align-items: center; + justify-content: center; + width: 100%; + text-align: center; + padding: 1rem; + border-radius: 6px; + height: 80px; + max-height: 80px; + transition: background-color 0.2s, filter 0.3s ease-in-out, opacity 0.3s ease-in-out !important; +} + +.sponsor .sponsor-item:hover { + background-color: rgba(0, 0, 0, 0.03); +} + +[data-md-color-scheme="slate"] .sponsor .sponsor-item:hover { + background-color: rgba(240, 241, 244, 0.024); +} + +.sponsor .sponsor-item img { + max-width: 100%; + height: auto; + vertical-align: middle; +} + +.sponsor-item-toc { + margin: 0; + padding: 14px !important; + height: 62px !important; + border-radius: 4px !important; + box-sizing: border-box; + flex: 0 0 calc(50% - 2px) !important; + background-color: var(--md-code-bg-color); +} + +.sponsor-item-toc:hover { + background-color: rgba(0, 0, 0, 0.08) !important; +} + +[data-md-color-scheme="slate"] .sponsor-item-toc:hover { + background-color: rgba(240, 241, 244, 0.1) !important; +} + +.sponsor-item-toc-full-row { + flex: 0 0 100% !important; +} + +.sponsor-item-toc-full-row img { + width: 50% !important; +} + +.sponsor-item-toc img { + width: 100%; + object-fit: contain; + filter: grayscale(1) invert(0.6); + opacity: 0.7; +} + +[data-md-color-scheme="slate"] .sponsor-item-toc img { + filter: brightness(1.3) grayscale(1); + opacity: 0.75; +} + +.sponsor-item-toc:hover img { + filter: grayscale(0%) !important; + opacity: 1; +} + +.sponsor-flex-wrapper { + display: flex; + flex-wrap: wrap; + gap: 1rem; + justify-content: center; +} + +.sponsor-flex-wrapper-toc { + display: flex !important; + flex-direction: row !important; + flex-wrap: wrap !important; + gap: 4px !important; + padding: 0; + width: 100%; +} + +.sponsor-item-flex { + flex: 0 1 calc(33.33% - 1rem); + min-width: 200px; + max-width: 300px; +} + +.sponsor-item-flex img { + width: 60% !important; +} + +@media screen and (max-width: 480px) { + .sponsor-flex-wrapper { + gap: 24px; + } + + .sponsor-title { + font-size: .8rem; + } + + .sponsor .sponsor-item { + height: 40px; + padding: 2px; + } + + .sponsor-toc { + display: none; + } + + .sponsor-item-flex { + flex: 0 1 calc(33.33% - 1rem); + min-width: 100px; + max-width: calc(33.33% - 1rem); + } + + .sponsor-item-flex img { + transform: scale(1.4); + } +} + +/* 图标动画 */ +.heart { + animation: heart 1000ms infinite; +} + +@keyframes heart { + + 0%, + 40%, + 80%, + 100% { + transform: scale(1); + } + + 20%, + 60% { + transform: scale(1.15); + } +} + +/* TDesign 组件相关 */ +.t-tag .t-icon { + margin-right: 0 !important; +} + +[theme-mode="dark"] .t-table { + --td-bg-color-container: hsla(var(--md-hue), 15%, 14%, 1) !important; + --td-component-border: hsla(225deg, 15%, 95%, 0.12) !important; +} + +[theme-mode="dark"] .t-tag { + --td-warning-color-light: #cf6e2d48 !important; +} + +.t-table--hoverable tbody tr:hover { + background-color: rgba(0, 0, 0, 0.016) !important; +} + +[theme-mode="dark"] .t-table--hoverable tbody tr:hover { + background-color: rgba(240, 241, 244, 0.016) !important; +} + +.t-table--column-fixed .t-table__cell--fixed-left { + z-index: 4; +} + +/* termynal 插件 */ +.termy { + padding: 65px 25px 35px !important; +} + +[data-termynal] { + color: #000 !important; + background: #f7f7f7 !important; + box-shadow: var(--md-shadow-z2); + font-size: 14px !important; +} + +[data-md-color-scheme="slate"] [data-termynal] { + color: #eeeeee !important; + background: #21252c !important; + box-shadow: var(--md-shadow-z2); +} + +button[data-terminal-control] { + color: var(--md-typeset-a-color) !important; +} + +[data-termynal]:after { + color: #585858 !important; +} + +[data-md-color-scheme="slate"] [data-termynal]:after { + color: #a2a2a2 !important; +} + +/* 切换主题动画 */ +::view-transition-old(root), +::view-transition-new(root) { + animation: none; + mix-blend-mode: normal; +} + +.dark::view-transition-old(root) { + z-index: var(--view-transition-z-index-foreground); +} + +.dark::view-transition-new(root) { + z-index: var(--view-transition-z-index-background); +} + +::view-transition-old(root) { + z-index: var(--view-transition-z-index-background) +} + +::view-transition-new(root) { + z-index: var(--view-transition-z-index-foreground); } \ No newline at end of file diff --git a/docs/theme/main.html b/docs/theme/main.html index cafec26..04426ff 100644 --- a/docs/theme/main.html +++ b/docs/theme/main.html @@ -5,3 +5,7 @@ {{ super() }} {% endblock %} + +{% block announce %} + 如果觉得这个项目不错对您有所帮助的话,请点击仓库右上角的 Star 并分享给更多的朋友   +{% endblock %} diff --git a/docs/theme/partials/toc.html b/docs/theme/partials/toc.html index 00ae909..adf3aed 100644 --- a/docs/theme/partials/toc.html +++ b/docs/theme/partials/toc.html @@ -46,7 +46,7 @@ Debian | `debian` `debian-archive` | - | Ubuntu | `ubuntu` `ubuntu-ports` | - | Kali Linux | `kali` | - | Linux Mint | `linuxmint` `ubuntu` `ubuntu-ports` `debian` | - | Deepin(深度) | `deepin` | - | Zorin OS | `ubuntu` `ubuntu-ports` | - | Armbian | `armbian` | - | Proxmox VE | `proxmox` | - | Raspberry Pi OS | `raspberrypi` `raspbian` `debian` `debian-archive` | - | Red Hat Enterprise Linux :material-information-outline:{ title="9版本使用 CentOS Stream, 7、8版本使用CentOS" } | `centos` `centos-stream` `centos-altarch` `centos-vault` | - | Fedora | `fedora` `fedora-archive` | - | CentOS | `centos` `centos-stream` `centos-altarch` `centos-vault` | - | Rocky Linux | `rocky` | - | AlmaLinux | `almalinux` `almalinux-vault` | - | openEuler(开源欧拉) | `openeuler` | - | OpenCloudOS(鸥栖) | `opencloudos` | - | openKylin(开放麒麟) | `openkylin` | - | Anolis OS(龙蜥) | `anolis` | - | openSUSE | `opensuse` | - | Arch Linux | `archlinux` `archlinuxarm` | - | Alpine Linux | `alpine` | - | Gentoo | `gentoo` `gentoo-portage` | - | NixOS | `nix-channels` | - - 请看下面的例子 - - ``` { .bash title="使用阿里云镜像站的 Rocky Linux 软件源" } - bash <(curl -sSL https://linuxmirrors.cn/main.sh) \ - --source mirrors.aliyun.com \ - --branch rockylinux - ``` - - 阿里云镜像站的 Rocky Linux 仓库名称为 [`rockylinux`](https://mirrors.aliyun.com/rockylinux),不符合默认规则,但是可以通过命令选项绕过脚本默认规则来实现。 - - > 部分系统会同时配置多个仓库的软件源,具体详见命令选项 - - > 由于软件源仓库作用在软件源地址上因此也可以使用多级路径,例如 `--branch "linux/debian"` -> `https://mirrors.example.com/linux/debian` - -- ### 单独更换 EPEL 源 - - !!! info "EPEL (Extra Packages for Enterprise Linux) 是由 Fedora 组织维护的一个附加软件包仓库,它主要适用于除 Fedora 操作系统以外的红帽系 Linux 发行版,配置 EPEL 仓库已成为广大用户的普遍需求,建议默认安装它" - - 有些时候你会发现想使用的镜像站没有 EPEL 仓库,那么你可以在第一次运行脚本时不安装或更换 EPEL 源然后再单独执行下面的命令 - - ``` bash - bash <(curl -sSL https://linuxmirrors.cn/main.sh) --only-epel - ``` - - 对于已经 EOF 的 EPEL 7 注意需要使用 [`archive`](https://dl.fedoraproject.org/pub/archive/epel) 仓库,境外以及海外网络环境建议通过命令选项 `--use-official-source-epel true` 使用官方源 - -- ### 恢复使用官方源 - - 当你不小心删除了官方源的备份时可以使用此命令来恢复,使用此命令选项后将跳过选择软件源步骤 - - ``` bash - bash <(curl -sSL https://linuxmirrors.cn/main.sh) --use-official-source true - ``` - > 部分系统不存在官方源例如 `Arch Linux`,届时会自动更换成兼容性较高的阿里云镜像站 - -- ### 特定系统的使用示例 - - - #### 关于 CentOS 停服问题 - - 脚本对于已经 EOF 的 CentOS 7/8、CentOS Stream 8 进行了适配 - -
- - - __国内网络环境__ - - --- - - 直接正常使用即可,因为国内大部分镜像站都同步了 [`CentOS Vault`](https://vault.centos.org/) 仓库 - - - __境外以及海外网络环境__ - - --- - - 建议使用 `腾讯云` 或 `阿里云` 镜像站,或者通过 `--use-official-source true` 命令选项使用官方源 - -
- - 另外 EPEL 7 也进入了 EOF,脚本同样对其进行了适配 - - - #### 指定 GNU/Linux Debian 操作系统的 Security 源 - - 如果你想尽可能提高服务器的安全性则建议使用官方源,因为镜像同步存在延迟 - - ``` bash - bash <(curl -sSL https://linuxmirrors.cn/main.sh) \ - --source-security security.debian.org \ - --branch-security debian-security - ``` - - - #### 指定 Debian 系 Linux 操作系统的版本代号 - - 大多数情况下自定义版本代号用于更换系统版本,请看下面的例子 - - === "升级 GNU/Linux Debian 至 12 版本 Bookworm" - - ``` bash - bash <(curl -sSL https://linuxmirrors.cn/main.sh) --codename bookworm - ``` - - === "将 GNU/Linux Debian 的版本切换到测试分支" - - ``` bash - bash <(curl -sSL https://linuxmirrors.cn/main.sh) --codename testing - ``` - - 更换软件源后还需要执行系统更新命令 `apt-get dist-upgrade`,并且建议在更新完成并重启系统后重新执行本换源脚本,因为仅更换软件源配置中的系统版本代号可能会在后期使用时产生一些兼容性问题 - - ``` { .bash title="若脚本无法实现指定版本代号,你也可以在执行脚本后手动替换" } - sed -i "s/$(lsb_release -cs)/指定版本代号/g" /etc/apt/sources.list - ``` - - - #### 更换 Ubuntu EOF版本软件源 - - !!! info "EOF 为生命周期结束的缩写(End Of Life),Ubuntu 迭代速度较快一般非LTS(长期支持)版本的生命周期只有9个月。官方会定期从主仓库移除不在生命周期内的版本仓库目录,届时可能就需要使用镜像站的 `Ubuntu Old Releases` 仓库" - - 具体版本支持情况详见官方 [Wiki](https://wiki.ubuntu.com/Releases),关于 `Ubuntu Old Releases` 仓库的支持情况详见各镜像站 - - ``` bash - bash <(curl -sSL https://linuxmirrors.cn/main.sh) \ - --source mirrors.ustc.edu.cn \ - --branch ubuntu-old-releases - ``` - -- ### 无人值守(自动化) - - 不通过交互完成换源操作,至少需要使用如下命令选项来实现,建议熟悉后再使用 - - ``` { .bash .no-copy title="参考命令" } - bash <(curl -sSL https://linuxmirrors.cn/main.sh) \ - --source mirror.example.com \ - --protocol http \ - --use-intranet-source false \ - --install-epel true \ - --backup true \ - --upgrade-software false \ - --clean-cache false \ - --ignore-backup-tips - ``` - > 如果报错 `命令选项无效` 那么请检查选项合法性以及空格字符编码,在示例中一行写一个选项是为了提高命令的可读性 - -- ### 纯净模式 - - 为了便于开发人员使用所推出的功能,启用后会精简脚本内容输出,建议搭配其它命令选项无交互使用 - - ``` bash - bash <(curl -sSL https://linuxmirrors.cn/main.sh) --pure-mode - ``` - - !!! tip "滚动输出的命令日志可能存在无法预料的显示问题,不过目前暂未发现异常" - ---- - -## 定制脚本 - -如果你是其它项目的开发者希望通过本项目来制作专属脚本那么请参考下面提到的内容,目前已经有国内教育单位镜像站的维护者这样做了。 - -1. 首先不建议修改代码的底层逻辑,应尽量与本项目源码保持同步,脚本内容执行顺序由 `main` 函数控制,代码逻辑清晰 -2. 你可以简单去除一些无关内容,例如将软件源列表(数组)`mirror_list_(default|edu|abroad|extranet|intranet)` 中的内容删除,例:`mirror_list_default=()` -3. 如果你想定制脚本打印内容可直接修改 `run_start` `run_end` `print_title` 这三个函数中的内容 -4. 如果你想添加自定义 Shell 内容详见 `main` 函数中脚本执行顺序,可以在对应位置直接插入内容也可以封装函数后调用 -5. 如果你想要缩减脚本体积那么可以删除一些不必要的内容,除了上面提到的软件源列表还有一些涉及脚本工作的部分模块内容,具体如下: - 1. 首先在删除内容时应尽可能保留脚本原始结构,直接把涉及函数中的内容删除即可,使其保留为空函数 - 2. 可以删除一些不使用(操作系统)的软件源原始内容 `gen_repo_files_xxx`,这些内容占据了脚本 `60%` 以上的体积 - 3. 如果你不使用某些功能那么可以删除对应功能模块函数中的内容,`命令选项 handle_command_options`、`备份原有软件源 backup_original_mirrors`、`更新软件包 upgrade_software` -6. 脚本主要功能配置是由统一的变量控制的,命令选项亦是如此,这些全局变量由全大写字母构成并遵循下划线命名法,具体变量详见如下表格,你只需要将这些变量声明在脚本头部(预留注释区域)即可快速完成定制 - -| 变量名 | 含义 | 值类型 | -| :-: | :-: | :-: | -| `SOURCE` | 指定软件源地址(域名或IP) | `地址` | -| `SOURCE_EPEL` | 指定 EPEL 附加软件包仓库的软件源地址(域名或IP) | `地址` | -| `SOURCE_SECURITY` | 指定 Debian / Ubuntu 系统 security 仓库的软件源地址(域名或IP) | `地址` | -| `SOURCE_VAULT` | 指定 CentOS / AlmaLinux 系统 vault 仓库的软件源地址(域名或IP) | `地址` | -| `SOURCE_PORTAGE` | 指定 Gentoo 系统 portage 仓库的软件源地址(域名或IP) | `地址` | -| `SOURCE_BASE_SYSTEM` | 指定 Linux Mint / Raspberry Pi OS 底层系统的软件源地址(域名或IP) | `地址` | -| `SOURCE_BRANCH` | 指定软件源仓库(路径) | `仓库名` | -| `SOURCE_EPEL_BRANCH` | 指定 EPEL 附加软件包仓库的软件源仓库(路径) | `仓库名` | -| `SOURCE_SECURITY_BRANCH` | 指定 Debian 系统 security 仓库的软件源仓库(路径) | `仓库名` | -| `SOURCE_VAULT_BRANCH` | 指定 CentOS / AlmaLinux 系统 vault 仓库的软件源仓库(路径) | `仓库名` | -| `SOURCE_PORTAGE_BRANCH` | 指定 Gentoo 系统 portage 仓库的软件源仓库(路径) | `仓库名` | -| `SOURCE_BASE_SYSTEM_BRANCH` | 指定 Linux Mint / Raspberry Pi OS 底层系统的软件源仓库(路径) | `仓库名` | -| `DEBIAN_CODENAME` | 指定 Debian 系 / openKylin 操作系统的版本代号 | `代号名称` | -| `USE_INTRANET_SOURCE` | 是否优先使用内网软件源地址 | `true` 或 `false` | -| `USE_OFFICIAL_SOURCE` | 是否使用目标操作系统的官方软件源 | `true` 或 `false` | -| `USE_OFFICIAL_SOURCE_EPEL` | 是否使用 EPEL 附加软件包的官方软件源 | `true` 或 `false` | -| `WEB_PROTOCOL` | 指定 WEB 协议 | `http` 或 `https` | -| `INSTALL_EPEL` | 是否安装 EPEL 附加软件包 | `true` 或 `false` | -| `ONLY_EPEL` | 仅更换 EPEL 软件源模式 | `true` 或 `false` | -| `BACKUP` | 是否备份原有软件源 | `true` 或 `false` | -| `IGNORE_BACKUP_TIPS` | 忽略覆盖备份提示(即不覆盖备份) | `true` 或 `false` | -| `UPGRADE_SOFTWARE` | 是否更新软件包 | `true` 或 `false` | -| `CLEAN_CACHE` | 是否在更新软件包后清理下载缓存 | `true` 或 `false` | -| `CLEAN_SCREEN` | 是否在运行前清除屏幕上的所有内容 | `true` 或 `false` | -| `PRINT_DIFF` | 是否打印源文件修改前后差异 | `true` 或 `false` | -| `PURE_MODE` | 纯净模式,精简打印内容 | `true` 或 `false` | - -> 部分变量存在默认值,未涉及的变量无需声明为空值(空字符串),另外如果对应功能配置不存在那么就可能会出现交互 +--- +hide: + - navigation + - footer +--- + +## 一键执行命令 + +=== ":material-home-city: 中国大陆" + + !!! quote "" + + === ":linuxmirrors: 官网(推荐)" + + ``` bash + bash <(curl -sSL https://linuxmirrors.cn/main.sh) + ``` + + === ":simple-github: GitHub" + + ``` bash + bash <(curl -sSL https://raw.githubusercontent.com/SuperManito/LinuxMirrors/main/ChangeMirrors.sh) + ``` + + === ":simple-gitee: Gitee 码云 (镜像仓库)" + + ``` bash + bash <(curl -sSL https://gitee.com/SuperManito/LinuxMirrors/raw/main/ChangeMirrors.sh) + ``` + > 实时同步、无延迟,国内网络环境下推荐使用 + + === ":gitcode: GitCode (镜像仓库)" + + ``` bash + bash <(curl -sSL https://raw.gitcode.com/gh_mirrors/li/LinuxMirrors/raw/main/ChangeMirrors.sh) + ``` + > 本项目已加入 GitHub 加速计划,同步存在1小时延迟 + + === ":simple-jsdelivr: jsDelivr (CDN)" + + ``` bash + bash <(curl -sSL https://cdn.jsdelivr.net/gh/SuperManito/LinuxMirrors@main/ChangeMirrors.sh) + ``` + +=== ":material-earth: 境外以及海外地区" + + !!! quote "" + + === ":linuxmirrors: 官网(推荐)" + + ``` bash + bash <(curl -sSL https://linuxmirrors.cn/main.sh) --abroad # (1)! + ``` + + 1. 通过 `--abroad` 命令选项来使用海外软件源 + + === ":simple-github: GitHub" + + ``` bash + bash <(curl -sSL https://raw.githubusercontent.com/SuperManito/LinuxMirrors/main/ChangeMirrors.sh) --abroad # (1)! + ``` + + 1. 通过 `--abroad` 命令选项来使用海外软件源 + + === ":simple-gitee: Gitee 码云 (镜像仓库)" + + ``` bash + bash <(curl -sSL https://gitee.com/SuperManito/LinuxMirrors/raw/main/ChangeMirrors.sh) --abroad # (1)! + ``` + + 1. 通过 `--abroad` 命令选项来使用海外软件源 + + > 实时同步、无延迟,国内网络环境下推荐使用 + + === ":gitcode: GitCode (镜像仓库)" + + ``` bash + bash <(curl -sSL https://raw.gitcode.com/gh_mirrors/li/LinuxMirrors/raw/main/ChangeMirrors.sh) --abroad # (1)! + ``` + + 1. 通过 `--abroad` 命令选项来使用海外软件源 + + > 本项目已加入 GitHub 加速计划,同步存在1小时延迟 + + === ":simple-jsdelivr: jsDelivr (CDN)" + + ``` bash + bash <(curl -sSL https://cdn.jsdelivr.net/gh/SuperManito/LinuxMirrors@main/ChangeMirrors.sh) --abroad # (1)! + ``` + + 1. 通过 `--abroad` 命令选项来使用海外软件源 + +=== ":material-library: 中国大陆教育网" + + !!! quote "" + + === ":linuxmirrors: 官网(推荐)" + + ``` bash + bash <(curl -sSL https://linuxmirrors.cn/main.sh) --edu # (1)! + ``` + + 1. 通过 `--edu` 命令选项来使用中国大陆教育单位软件源 + + === ":simple-github: GitHub" + + ``` bash + bash <(curl -sSL https://raw.githubusercontent.com/SuperManito/LinuxMirrors/main/ChangeMirrors.sh) --edu # (1)! + ``` + + 1. 通过 `--edu` 命令选项来使用中国大陆教育单位软件源 + + === ":simple-gitee: Gitee 码云 (镜像仓库)" + + ``` bash + bash <(curl -sSL https://gitee.com/SuperManito/LinuxMirrors/raw/main/ChangeMirrors.sh) --edu # (1)! + ``` + + 1. 通过 `--edu` 命令选项来使用中国大陆教育单位软件源 + + > 实时同步、无延迟,国内网络环境下推荐使用 + + === ":gitcode: GitCode (镜像仓库)" + + ``` bash + bash <(curl -sSL https://raw.gitcode.com/gh_mirrors/li/LinuxMirrors/raw/main/ChangeMirrors.sh) --edu # (1)! + ``` + + 1. 通过 `--edu` 命令选项来使用中国大陆教育单位软件源 + + > 本项目已加入 GitHub 加速计划,同步存在1小时延迟 + + === ":simple-jsdelivr: jsDelivr (CDN)" + + ``` bash + bash <(curl -sSL https://cdn.jsdelivr.net/gh/SuperManito/LinuxMirrors@main/ChangeMirrors.sh) --edu # (1)! + ``` + + 1. 通过 `--edu` 命令选项来使用中国大陆教育单位软件源 + + + +!!! tip "使用帮助" + + 选项卡分别代表脚本内置软件源类型和获取脚本途径,请在使用前检查目标镜像站是否支持您所使用的操作系统,可以在[软件源列表](../mirrors/index.md)中查看。 + 默认自动备份原有软件源内容,如需了解更多请翻阅下方文档。若使用过程中的某些选项令你疑惑不解,那么在选择软件源后一路回车即是最佳实践。 + +!!! quote "关于软件源的选择(新用户必读)" + + 如果你不了解这些镜像站那么建议使用 `阿里云 (兼容性高)` 或 `中国科学技术大学 (速度快)`,请不要陷入测速焦虑,内置的默认软件源一般不会有太大的差异。 + 本项目脚本是一个自动化运维工具,不会对镜像站进行主观的优劣排序和单独适配,用户的选择应该是自由的,这也是为了开源软件精神能够得到更好的延续。 + +
+ +- :material-numeric-1:{style="color: #3CA7E5" .lg} __需使用 `ROOT` 用户执行脚本__ + + --- + + 切换命令为 `sudo -i` 或 `su root`。不同系统使用的命令不同,因为部分系统没有在初始安装时为 ROOT 账户设置密码(例如 Ubuntu)或系统默认禁止 ROOT 用户登录。 + +- :material-numeric-2:{style="color: #3CA7E5" .lg} __建议使用现代化的 `SSH` 客户端应用__ + + --- + + 如果你系统命令行界面的中文显示乱码那么将导致无法查看交互内容,此外部分系统 GUI 图形界面的终端应用可能存在一些无法预料的显示问题。部分系统会自动开启 SSH 服务,否则请参考[开启方法](#关于开启-ssh-远程登录的方法)。 + +- :material-numeric-3:{style="color: #3CA7E5" .lg} __如果是在新装系统上首次执行脚本__ + + --- + + 当前依赖 `curl` 指令获取脚本内容,但部分操作系统没有预装此软件包,届时则会报错 `Command not found`,安装方法详见下方 [_关于报错 Command not found_](#关于报错-command-not-found)。脚本本身与 `curl` `wget` 指令无关,更不会下载任何内容。 + +- :material-numeric-4:{style="color: #3CA7E5" .lg} __脚本运行期间需要交互选择配置__ + + --- + + 请通过方向键 ++arrow-up++++arrow-down++++arrow-left++++arrow-right++ 或 ++w++++a++++s++++d++ 控制选项并按 ++enter++ 回车键确认。如果发现交互异常那么请改变终端软件的窗口大小后重试,另外窗口不要铺满全屏。 + +
+ +### 常见问题 + +- #### 关于报错 Command not found + + !!! quote "" + + 此报错是由于系统没有安装 `curl` 软件包导致,安装命令如下 + + === "Debian 系 / openKylin" + + ``` bash + apt-get install -y curl + ``` + + > `Debian`   `Ubuntu`   `Kali`   `Linux Mint`   `Deepin`   `Zorin OS`   `Armbian`   `Proxmox VE`   `Raspberry Pi OS`   `openKylin` + + 新装系统需要先执行一遍更新 `apt-get update` + + === "RedHat 系 / openEuler / OpenCloudOS / Anolis OS" + + ``` bash + dnf install -y curl || yum install -y curl + ``` + + > `Red Hat Enterprise Linux`   `CentOS`   `Rocky Linux`   `AlmaLinux`   `Fedora`   `openEuler`   `OpenCloudOS`   `Anolis OS` + + === "openSUSE" + + ``` bash + zypper install curl + ``` + + === "Arch Linux" + + ``` bash + pacman -S curl + ``` + + === "Alpine Linux" + + ``` bash + apk --no-cache add -f curl bash ncurses + ``` + + === "Gentoo" + + ``` bash + emerge --ask curl + ``` + + === "NixOS" + + ``` bash + nix-env -iA nixos.curl + ``` + + ??? question "安装不上?(点击展开查看其它解决方法)" + + 假如系统原有软件源是无效的导致安装不上 `curl` 软件包,那么对于 Linux 初学者来说可能会比较麻烦,这里提供几个在线获取脚本的应急方法 + + === "使用 Python 下载脚本" + + 适用于大部分操作系统(`Alpine Linux` 除外),`python3` 要是不存在那就再试试 `python` 指令 + ``` bash + python3 -c "import urllib.request; urllib.request.urlretrieve('https://linuxmirrors.cn/main.sh', 'main.sh')" + ``` + + === "使用 wget 下载脚本" + + 一般没有预装 `curl` 软件包的系统也不会预装 `wget` 软件包,所以大概率这个方法应该是不行的 + ``` bash + wget https://linuxmirrors.cn/main.sh + ``` + + === "使用浏览器下载" + + 如果可以访问系统 GUI 图像界面和桌面的话那可以直接在浏览器中打开链接下载脚本,很多系统都会预装 Firefox 火狐浏览器 + + 之后再执行脚本即可 + + === ":material-home-city: 中国大陆" + + ``` bash + bash main.sh + ``` + + === ":material-earth: 境外以及海外地区" + + ``` bash + bash main.sh --abroad + ``` + + === ":material-library: 中国大陆教育网" + + ``` bash + bash main.sh --edu + ``` + + 如果以上方法试了都不行,那就复制[源码](https://gitee.com/SuperManito/LinuxMirrors/raw/main/ChangeMirrors.sh)至本地新建任意名称的 `.sh` 脚本,粘贴源码内容后通过 `bash` 指令手动执行。 + +- #### 备份原有软件源 + + !!! quote "" + + 脚本会自动备份原有软件源内容,备份路径为原有文件或目录的绝对路径加上 `.bak` 后缀,例如 `/etc/apt/sources.list => /etc/apt/sources.list.bak`,当检查到已存在备份内容时会询问是否覆盖备份。 + +- #### 还原已备份的软件源 + + !!! quote "" + + === "Debian 系 / openKylin" + + === "传统格式" + + ``` bash + cp -rf /etc/apt/sources.list.bak /etc/apt/sources.list + apt-get update + ``` + + === "DEB822 格式" + + ``` bash + system_name="$(lsb_release -is | tr '[:upper:]' '[:lower:]')" + cp -rf "/etc/apt/sources.list.d/${system_name}.sources.bak" "/etc/apt/sources.list.d/${system_name}.sources" + apt-get update + ``` + + > `Debian`   `Ubuntu`   `Kali`   `Linux Mint`   `Deepin`   `Zorin OS`   `Armbian`   `Proxmox VE`   `Raspberry Pi OS`   `openKylin` + + === "RedHat 系 / openEuler / OpenCloudOS / Anolis OS" + + ``` bash + cp -rf /etc/yum.repos.d.bak /etc/yum.repos.d + yum makecache + ``` + + > `Red Hat Enterprise Linux`   `CentOS`   `Rocky Linux`   `AlmaLinux`   `Fedora`   `openEuler`   `OpenCloudOS`   `Anolis OS` + + === "openSUSE" + + ``` bash + cp -rf /etc/zypp/repos.d.bak /etc/zypp/repos.d + zypper ref + ``` + + === "Arch Linux" + + ``` bash + cp -rf /etc/pacman.d/mirrorlist.bak /etc/pacman.d/mirrorlist + pacman -Sy + ``` + + === "Alpine Linux" + + ``` bash + cp -rf /etc/apk/repositories.bak /etc/apk/repositories + apk update -f + ``` + + === "Gentoo" + + ``` bash + 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 + ``` + + === "NixOS" + + ``` bash + cp -rf /etc/nix/nix.conf.bak /etc/nix/nix.conf + ``` + +- #### 关于开启 SSH 远程登录的方法 + + !!! quote "" + + - 验证是否已安装 `SSH` 服务 + + ``` bash + ls /etc | grep ssh + ``` + > 如果没有这个文件夹说明系统未安装 `SSH` 服务,你需要通过包管理工具安装 `openssh` 软件包 + > 需要注意的是不同系统上的软件包名称有所差异,可直接使用 `openssh*` 通配符进行安装 + + - 设置允许 Root 用户登录 + + ``` bash + cat /etc/ssh/sshd_config | grep -Eq "^[# ]?PermitRootLogin " ; [ $? -eq 0 ] && sed -i 's/^[# ]\?PermitRootLogin.*/PermitRootLogin yes/g' /etc/ssh/sshd_config || echo -e "\nPermitRootLogin yes" >> /etc/ssh/sshd_config + ``` + + - 设置密码认证 + + ``` bash + cat /etc/ssh/sshd_config | grep -Eq "^[# ]?PasswordAuthentication " ; [ $? -eq 0 ] && sed -i 's/^[# ]\?PasswordAuthentication.*/PasswordAuthentication yes/g' /etc/ssh/sshd_config || echo -e "\nPasswordAuthentication yes" >> /etc/ssh/sshd_config + ``` + + - 启动/重启 `SSH` 服务 + + ``` bash + ps -ef | grep -q ssh ; [ $? -eq 0 ] && systemctl restart sshd || systemctl enable --now sshd + ``` + > 不同系统上的服务名称有所差异,如果不是 `sshd` 那就试试 `ssh` + + > 命令以及配置步骤仅供参考,只适配了部分常见发行版。 + +- #### 关于未显示方向键交互控制界面 + + !!! quote "" + + 如果发现交互界面是输入而不是新式的方向键控制,那么请自行安装 `ncurses` 或 `nano` 软件包,新式的按键交互依赖 `tput` 指令实现。 + +- #### 关于调用脚本的互联网位置 + + !!! quote "" + + 项目利用 [GitHub Action](https://github.com/SuperManito/LinuxMirrors/blob/main/.github/workflows/build-docs.yml#L29) 在每次提交后自动拷贝源码到文档目录作为网站资源发布,网站托管于 :netlify: [Netlify](https://www.netlify.com),几乎没有被劫持的风险请放心使用。 + + 当然你也可以使用代码托管仓库的原始地址来调用,这里只是想告诉你为什么会有几个不同的地址,默认的官网地址更易于记忆和访问。 + +- #### 关于软件源下载速度相关问题 + + !!! quote "" + + 首先,在[软件源列表](../mirrors/index.md)的使用帮助处有写使用推荐,这是根据以往经验总结出来的,但总有用户在纠结软件源速度的问题。 + + 软件源(镜像站)的网络延迟即 `Ping` 与下载速度没有太大的关联,双方地理位置间隔的远近不代表实际体验,有些镜像站下行总带宽很高但实际测速却并不理想,因为这与镜像站的负载策略有关。 + + 网上也有很多基于 C、Python 编写的镜像站测速开源脚本,而本项目脚本基于 Bash Shell 编写且不依赖任何第三方库,Bash 是 Linux 运维中最常用的脚本语言并且绝大部分发行版都会预装,这意味着用户不需要安装任何环境就能直接运行,这种便利性是其它高级语言无法替代的,不过目前来看 Bash 脚本可能不太容易实现精准测速的功能,使用其它高级语言编写测速功能无疑是造轮子的行为。 + +- #### 关于未启用的软件源仓库 + + !!! quote "" + + 很多系统的软件源会启用多个仓库,脚本遵循系统默认设置,默认不启用的软件源(仓库)不会在运行完本脚本后被启用,但是它们也随脚本更换了目标软件源地址,具体启用方法如下: + + === "Debian 系 / openKylin" + + 默认禁用了`deb-src`源码仓库和`proposed`预发布软件源,若需启用请将 `/etc/apt/sources.list` 文件中相关内容的所在行取消注释 + + > `Debian`   `Ubuntu`   `Kali`   `Linux Mint`   `Deepin`   `Zorin OS`   `Armbian`   `Proxmox VE`   `Raspberry Pi OS`   `openKylin` + + === "RedHat 系 / openEuler / OpenCloudOS / Anolis OS" + + 部分仓库默认没有启用,若需启用请将 `/etc/yum.repos.d` 目录下相关 repo 文件中的 `enabled` 值修改为 `1` + + > `Red Hat Enterprise Linux`   `CentOS`   `Rocky Linux`   `AlmaLinux`   `Fedora`   `openEuler`   `OpenCloudOS`   `Anolis OS` + + === "openSUSE" + + 部分仓库默认没有启用,若需启用请将 `/etc/zypp/repos.d` 目录下相关 repo 文件中的 `enabled` 值修改为 `1` + + +--- + +## 命令选项(高级用法) + + +``` +$ bash <(curl -sSL https://linuxmirrors.cn/main.sh) --help + +命令选项(名称/含义/值): + + --abroad 使用境外以及海外软件源 无 + --edu 使用中国大陆教育网软件源 无 + --source 指定软件源地址(域名或IP) 地址 + --source-epel 指定 EPEL 附加软件包仓库的软件源地址(域名或IP) 地址 + --source-security 指定 Debian / Ubuntu 系统 security 仓库的软件源地址(域名或IP) 地址 + --source-vault 指定 CentOS / AlmaLinux 系统 vault 仓库的软件源地址(域名或IP) 地址 + --source-portage 指定 Gentoo 系统 portage 仓库的软件源地址(域名或IP) 地址 + --source-base-system 指定 Linux Mint / Raspberry Pi OS 底层系统的软件源地址(域名或IP) 地址 + --branch 指定软件源仓库(路径) 仓库名 + --branch-epel 指定 EPEL 附加软件包仓库的软件源仓库(路径) 仓库名 + --branch-security 指定 Debian 系统 security 仓库的软件源仓库(路径) 仓库名 + --branch-vault 指定 CentOS / AlmaLinux 系统 vault 仓库的软件源仓库(路径) 仓库名 + --branch-portage 指定 Gentoo 系统 portage 仓库的软件源仓库(路径) 仓库名 + --branch-base-system 指定 Linux Mint / Raspberry Pi OS 底层系统的软件源仓库(路径) 仓库名 + --codename 指定 Debian 系 / openKylin 操作系统的版本代号 代号名称 + --protocol 指定 WEB 协议 http 或 https + --use-intranet-source 是否优先使用内网软件源地址 true 或 false + --use-official-source 是否使用目标操作系统的官方软件源 true 或 false + --use-official-source-epel 是否使用 EPEL 附加软件包的官方软件源 true 或 false + --install-epel 是否安装 EPEL 附加软件包 true 或 false + --backup 是否备份原有软件源 true 或 false + --upgrade-software 是否更新软件包 true 或 false + --clean-cache 是否在更新软件包后清理下载缓存 true 或 false + --clean-screen 是否在运行前清除屏幕上的所有内容 true 或 false + --only-epel 仅更换 EPEL 软件源模式 无 + --ignore-backup-tips 忽略覆盖备份提示 无 + --print-diff 打印源文件修改前后差异 无 + --pure-mode 纯净模式,精简打印内容 无 +``` + +| 名称 | 含义 | 选项值 | +| - | - | :-: | +| `--abroad` | 使用境外以及海外软件源 | 无 | +| `--edu` | 使用中国大陆教育网软件源 | 无 | +| `--source` | 指定软件源地址(域名或IP) | `地址` | +| `--source-epel` | 指定 EPEL 附加软件包仓库的软件源地址(域名或IP) | `地址` | +| `--source-security` | 指定 Debian / Ubuntu 系统 security 仓库的软件源地址(域名或IP) | `地址` | +| `--source-vault` | 指定 CentOS / AlmaLinux 系统 vault 仓库的软件源地址(域名或IP) | `地址` | +| `--source-portage` | 指定 Gentoo 系统 portage 仓库的软件源地址(域名或IP) | `地址` | +| `--source-base-system` | 指定 Linux Mint / Raspberry Pi OS 底层系统的软件源地址(域名或IP) | `地址` | +| `--branch` | 指定软件源仓库(路径) | `仓库名` | +| `--branch-epel` | 指定 EPEL 附加软件包仓库的软件源仓库(路径) | `仓库名` | +| `--branch-security` | 指定 Debian 系统 security 仓库的软件源仓库(路径) | `仓库名` | +| `--branch-vault` | 指定 CentOS / AlmaLinux 系统 vault 仓库的软件源仓库(路径) | `仓库名` | +| `--branch-portage` | 指定 Gentoo 系统 portage 仓库的软件源仓库(路径) | `仓库名` | +| `--branch-base-system` | 指定 Linux Mint / Raspberry Pi OS 底层系统的软件源仓库(路径) | `仓库名` | +| `--codename` | 指定 Debian 系 / openKylin 操作系统的版本代号 | `代号名称` | +| `--protocol` | 指定 WEB 协议 | `http` 或 `https` | +| `--use-intranet-source` | 是否优先使用内网软件源地址 | `true` 或 `false` | +| `--use-official-source` | 是否使用目标操作系统的官方软件源 | `true` 或 `false` | +| `--use-official-source-epel` | 是否使用 EPEL 附加软件包的官方软件源 | `true` 或 `false` | +| `--install-epel` | 是否安装 EPEL 附加软件包 | `true` 或 `false` | +| `--backup` | 是否备份原有软件源 | `true` 或 `false` | +| `--upgrade-software` | 是否更新软件包 | `true` 或 `false` | +| `--clean-cache` | 是否在更新软件包后清理下载缓存 | `true` 或 `false` | +| `--clean-screen` | 是否在运行前清除屏幕上的所有内容 | `true` 或 `false` | +| `--print-diff` | 是否打印源文件修改前后差异 | `true` 或 `false` | +| `--only-epel` | 仅更换 EPEL 软件源模式 | 无 | +| `--ignore-backup-tips` | 忽略覆盖备份提示(即不覆盖备份) | 无 | +| `--pure-mode` | 纯净模式,精简打印内容 | 无 | +| `--help` | 查看帮助菜单 | 无 | + +> 软件源完整格式 `://<软件源地址(域名或IP)>/<软件源仓库(路径)>` + +下面是一些高级用法的举例 + +- ### 指定软件源地址 + + ``` { .bash .no-copy } + bash <(curl -sSL https://linuxmirrors.cn/main.sh) --source mirror.example.com + ``` + +- ### 指定软件源仓库 + + 这里的软件源仓库与系统内容软件源仓库不同,指的是软件源地址后面的路径即镜像站分支仓库,虽然名义上都是仓库但是非常容易混淆 + + 主要使用场景:目标镜像站有对应的系统镜像仓库但是不符合本项目脚本关于软件源仓库设置的默认规则 + + ??? note "项目对于各操作系统所使用的默认仓库名称(点击展开查看)" + + 项目脚本为了适配大的环境不会针对某一镜像站独特的仓库名称而单独适配 + + | 系统名称 | 涉及的名称 | + | --- | :---: | + | Debian | `debian` `debian-archive` | + | Ubuntu | `ubuntu` `ubuntu-ports` | + | Kali Linux | `kali` | + | Linux Mint | `linuxmint` `ubuntu` `ubuntu-ports` `debian` | + | Deepin(深度) | `deepin` | + | Zorin OS | `ubuntu` `ubuntu-ports` | + | Armbian | `armbian` | + | Proxmox VE | `proxmox` | + | Raspberry Pi OS | `raspberrypi` `raspbian` `debian` `debian-archive` | + | Red Hat Enterprise Linux :material-information-outline:{ title="9版本使用 CentOS Stream, 7、8版本使用CentOS" } | `centos` `centos-stream` `centos-altarch` `centos-vault` | + | Fedora | `fedora` `fedora-archive` | + | CentOS | `centos` `centos-stream` `centos-altarch` `centos-vault` | + | Rocky Linux | `rocky` | + | AlmaLinux | `almalinux` `almalinux-vault` | + | openEuler(开源欧拉) | `openeuler` | + | OpenCloudOS(鸥栖) | `opencloudos` | + | openKylin(开放麒麟) | `openkylin` | + | Anolis OS(龙蜥) | `anolis` | + | openSUSE | `opensuse` | + | Arch Linux | `archlinux` `archlinuxarm` | + | Alpine Linux | `alpine` | + | Gentoo | `gentoo` `gentoo-portage` | + | NixOS | `nix-channels` | + + 请看下面的例子 + + ``` { .bash title="使用阿里云镜像站的 Rocky Linux 软件源" } + bash <(curl -sSL https://linuxmirrors.cn/main.sh) \ + --source mirrors.aliyun.com \ + --branch rockylinux + ``` + + 阿里云镜像站的 Rocky Linux 仓库名称为 [`rockylinux`](https://mirrors.aliyun.com/rockylinux),不符合默认规则,但是可以通过命令选项绕过脚本默认规则来实现。 + + > 部分系统会同时配置多个仓库的软件源,具体详见命令选项 + + > 由于软件源仓库作用在软件源地址上因此也可以使用多级路径,例如 `--branch "linux/debian"` -> `https://mirrors.example.com/linux/debian` + +- ### 单独更换 EPEL 源 + + !!! info "EPEL (Extra Packages for Enterprise Linux) 是由 Fedora 组织维护的一个附加软件包仓库,它主要适用于除 Fedora 操作系统以外的红帽系 Linux 发行版,配置 EPEL 仓库已成为广大用户的普遍需求,建议默认安装它" + + 有些时候你会发现想使用的镜像站没有 EPEL 仓库,那么你可以在第一次运行脚本时不安装或更换 EPEL 源然后再单独执行下面的命令 + + ``` bash + bash <(curl -sSL https://linuxmirrors.cn/main.sh) --only-epel + ``` + + 对于已经 EOF 的 EPEL 7 注意需要使用 [`archive`](https://dl.fedoraproject.org/pub/archive/epel) 仓库,境外以及海外网络环境建议通过命令选项 `--use-official-source-epel true` 使用官方源 + +- ### 恢复使用官方源 + + 当你不小心删除了官方源的备份时可以使用此命令来恢复,使用此命令选项后将跳过选择软件源步骤 + + ``` bash + bash <(curl -sSL https://linuxmirrors.cn/main.sh) --use-official-source true + ``` + > 部分系统不存在官方源例如 `Arch Linux`,届时会自动更换成兼容性较高的阿里云镜像站 + +- ### 特定系统的使用示例 + + - #### 关于 CentOS 停服问题 + + 脚本对于已经 EOF 的 CentOS 7/8、CentOS Stream 8 进行了适配 + +
+ + - __国内网络环境__ + + --- + + 直接正常使用即可,因为国内大部分镜像站都同步了 [`CentOS Vault`](https://vault.centos.org/) 仓库 + + - __境外以及海外网络环境__ + + --- + + 建议使用 `腾讯云` 或 `阿里云` 镜像站,或者通过 `--use-official-source true` 命令选项使用官方源 + +
+ + 另外 EPEL 7 也进入了 EOF,脚本同样对其进行了适配 + + - #### 指定 GNU/Linux Debian 操作系统的 Security 源 + + 如果你想尽可能提高服务器的安全性则建议使用官方源,因为镜像同步存在延迟 + + ``` bash + bash <(curl -sSL https://linuxmirrors.cn/main.sh) \ + --source-security security.debian.org \ + --branch-security debian-security + ``` + + - #### 指定 Debian 系 Linux 操作系统的版本代号 + + 大多数情况下自定义版本代号用于更换系统版本,请看下面的例子 + + === "升级 GNU/Linux Debian 至 12 版本 Bookworm" + + ``` bash + bash <(curl -sSL https://linuxmirrors.cn/main.sh) --codename bookworm + ``` + + === "将 GNU/Linux Debian 的版本切换到测试分支" + + ``` bash + bash <(curl -sSL https://linuxmirrors.cn/main.sh) --codename testing + ``` + + 更换软件源后还需要执行系统更新命令 `apt-get dist-upgrade`,并且建议在更新完成并重启系统后重新执行本换源脚本,因为仅更换软件源配置中的系统版本代号可能会在后期使用时产生一些兼容性问题 + + ``` { .bash title="若脚本无法实现指定版本代号,你也可以在执行脚本后手动替换" } + sed -i "s/$(lsb_release -cs)/指定版本代号/g" /etc/apt/sources.list + ``` + + - #### 更换 Ubuntu EOF版本软件源 + + !!! info "EOF 为生命周期结束的缩写(End Of Life),Ubuntu 迭代速度较快一般非LTS(长期支持)版本的生命周期只有9个月。官方会定期从主仓库移除不在生命周期内的版本仓库目录,届时可能就需要使用镜像站的 `Ubuntu Old Releases` 仓库" + + 具体版本支持情况详见官方 [Wiki](https://wiki.ubuntu.com/Releases),关于 `Ubuntu Old Releases` 仓库的支持情况详见各镜像站 + + ``` bash + bash <(curl -sSL https://linuxmirrors.cn/main.sh) \ + --source mirrors.ustc.edu.cn \ + --branch ubuntu-old-releases + ``` + +- ### 无人值守(自动化) + + 不通过交互完成换源操作,至少需要使用如下命令选项来实现,建议熟悉后再使用 + + ``` { .bash .no-copy title="参考命令" } + bash <(curl -sSL https://linuxmirrors.cn/main.sh) \ + --source mirror.example.com \ + --protocol http \ + --use-intranet-source false \ + --install-epel true \ + --backup true \ + --upgrade-software false \ + --clean-cache false \ + --ignore-backup-tips + ``` + > 如果报错 `命令选项无效` 那么请检查选项合法性以及空格字符编码,在示例中一行写一个选项是为了提高命令的可读性 + +- ### 纯净模式 + + 为了便于开发人员使用所推出的功能,启用后会精简脚本内容输出,建议搭配其它命令选项无交互使用 + + ``` bash + bash <(curl -sSL https://linuxmirrors.cn/main.sh) --pure-mode + ``` + + !!! tip "滚动输出的命令日志可能存在无法预料的显示问题,不过目前暂未发现异常" + +--- + +## 定制脚本 + +如果你是其它项目的开发者希望通过本项目来制作专属脚本那么请参考下面提到的内容,目前已经有国内教育单位镜像站的维护者这样做了。 + +1. 首先不建议修改代码的底层逻辑,应尽量与本项目源码保持同步,脚本内容执行顺序由 `main` 函数控制,代码逻辑清晰 +2. 你可以简单去除一些无关内容,例如将软件源列表(数组)`mirror_list_(default|edu|abroad|extranet|intranet)` 中的内容删除,例:`mirror_list_default=()` +3. 如果你想定制脚本打印内容可直接修改 `run_start` `run_end` `print_title` 这三个函数中的内容 +4. 如果你想添加自定义 Shell 内容详见 `main` 函数中脚本执行顺序,可以在对应位置直接插入内容也可以封装函数后调用 +5. 如果你想要缩减脚本体积那么可以删除一些不必要的内容,除了上面提到的软件源列表还有一些涉及脚本工作的部分模块内容,具体如下: + 1. 首先在删除内容时应尽可能保留脚本原始结构,直接把涉及函数中的内容删除即可,使其保留为空函数 + 2. 可以删除一些不使用(操作系统)的软件源原始内容 `gen_repo_files_xxx`,这些内容占据了脚本 `60%` 以上的体积 + 3. 如果你不使用某些功能那么可以删除对应功能模块函数中的内容,`命令选项 handle_command_options`、`备份原有软件源 backup_original_mirrors`、`更新软件包 upgrade_software` +6. 脚本主要功能配置是由统一的变量控制的,命令选项亦是如此,这些全局变量由全大写字母构成并遵循下划线命名法,具体变量详见如下表格,你只需要将这些变量声明在脚本头部(预留注释区域)即可快速完成定制 + +| 变量名 | 含义 | 值类型 | +| :-: | :-: | :-: | +| `SOURCE` | 指定软件源地址(域名或IP) | `地址` | +| `SOURCE_EPEL` | 指定 EPEL 附加软件包仓库的软件源地址(域名或IP) | `地址` | +| `SOURCE_SECURITY` | 指定 Debian / Ubuntu 系统 security 仓库的软件源地址(域名或IP) | `地址` | +| `SOURCE_VAULT` | 指定 CentOS / AlmaLinux 系统 vault 仓库的软件源地址(域名或IP) | `地址` | +| `SOURCE_PORTAGE` | 指定 Gentoo 系统 portage 仓库的软件源地址(域名或IP) | `地址` | +| `SOURCE_BASE_SYSTEM` | 指定 Linux Mint / Raspberry Pi OS 底层系统的软件源地址(域名或IP) | `地址` | +| `SOURCE_BRANCH` | 指定软件源仓库(路径) | `仓库名` | +| `SOURCE_EPEL_BRANCH` | 指定 EPEL 附加软件包仓库的软件源仓库(路径) | `仓库名` | +| `SOURCE_SECURITY_BRANCH` | 指定 Debian 系统 security 仓库的软件源仓库(路径) | `仓库名` | +| `SOURCE_VAULT_BRANCH` | 指定 CentOS / AlmaLinux 系统 vault 仓库的软件源仓库(路径) | `仓库名` | +| `SOURCE_PORTAGE_BRANCH` | 指定 Gentoo 系统 portage 仓库的软件源仓库(路径) | `仓库名` | +| `SOURCE_BASE_SYSTEM_BRANCH` | 指定 Linux Mint / Raspberry Pi OS 底层系统的软件源仓库(路径) | `仓库名` | +| `DEBIAN_CODENAME` | 指定 Debian 系 / openKylin 操作系统的版本代号 | `代号名称` | +| `USE_INTRANET_SOURCE` | 是否优先使用内网软件源地址 | `true` 或 `false` | +| `USE_OFFICIAL_SOURCE` | 是否使用目标操作系统的官方软件源 | `true` 或 `false` | +| `USE_OFFICIAL_SOURCE_EPEL` | 是否使用 EPEL 附加软件包的官方软件源 | `true` 或 `false` | +| `WEB_PROTOCOL` | 指定 WEB 协议 | `http` 或 `https` | +| `INSTALL_EPEL` | 是否安装 EPEL 附加软件包 | `true` 或 `false` | +| `ONLY_EPEL` | 仅更换 EPEL 软件源模式 | `true` 或 `false` | +| `BACKUP` | 是否备份原有软件源 | `true` 或 `false` | +| `IGNORE_BACKUP_TIPS` | 忽略覆盖备份提示(即不覆盖备份) | `true` 或 `false` | +| `UPGRADE_SOFTWARE` | 是否更新软件包 | `true` 或 `false` | +| `CLEAN_CACHE` | 是否在更新软件包后清理下载缓存 | `true` 或 `false` | +| `CLEAN_SCREEN` | 是否在运行前清除屏幕上的所有内容 | `true` 或 `false` | +| `PRINT_DIFF` | 是否打印源文件修改前后差异 | `true` 或 `false` | +| `PURE_MODE` | 纯净模式,精简打印内容 | `true` 或 `false` | + +> 部分变量存在默认值,未涉及的变量无需声明为空值(空字符串),另外如果对应功能配置不存在那么就可能会出现交互