From f68b34b99ef0ea669f8301e1ae3853b840aa4914 Mon Sep 17 00:00:00 2001 From: SuperManito <68613938+SuperManito@users.noreply.github.com> Date: Tue, 20 Jun 2023 06:04:56 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E5=91=BD=E4=BB=A4=E9=80=89?= =?UTF-8?q?=E9=A1=B9=20&=20bug=20fix?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ChangeMirrors.sh | 48 ++++++++++++++++++++++++------------- DockerInstallation.sh | 16 ++++++++++--- docs/other/index.md | 21 ++++++++-------- docs/use/command-options.md | 27 ++++++++++++++------- 4 files changed, 75 insertions(+), 37 deletions(-) diff --git a/ChangeMirrors.sh b/ChangeMirrors.sh index 8456462..b76cb3c 100755 --- a/ChangeMirrors.sh +++ b/ChangeMirrors.sh @@ -1,6 +1,6 @@ #!/bin/bash ## Author: SuperManito -## Modified: 2023-05-25 +## Modified: 2023-06-20 ## License: MIT ## Github: https://github.com/SuperManito/LinuxMirrors ## Website: https://linuxmirrors.cn @@ -217,36 +217,42 @@ function CheckCommandOptions() { "${SYSTEM_DEBIAN}") if [[ "${SYSTEM_JUDGMENT}" != "${SYSTEM_DEBIAN}" ]]; then if [[ "${SOURCE_SECURITY}" == "true" || "${SOURCE_BRANCH_SECURITY}" == "true" ]]; then - Output_Error "当前系统不支持使用 security 仓库相关参数,请确认后重试!" + Output_Error "当前系统不支持使用 security 仓库相关命令选项,请确认后重试!" fi fi if [[ "${INSTALL_EPEL}" == "true" || "${ONLY_EPEL}" == "true" ]]; then - Output_Error "当前系统不支持安装 EPEL 附件软件包故无法使用相关参数,请确认后重试!" + Output_Error "当前系统不支持安装 EPEL 附件软件包故无法使用相关命令选项,请确认后重试!" fi ;; "${SYSTEM_REDHAT}") if [[ "${SYSTEM_JUDGMENT}" != "${SYSTEM_CENTOS}" && "${SYSTEM_JUDGMENT}" != "${SYSTEM_RHEL}" && "${SYSTEM_JUDGMENT}" != "${SYSTEM_ALMALINUX}" ]]; then if [[ "${SOURCE_VAULT}" == "true" || "${SOURCE_BRANCH_VAULT}" == "true" ]]; then - Output_Error "当前系统不支持使用 vault 仓库相关参数,请确认后重试!" + Output_Error "当前系统不支持使用 vault 仓库相关命令选项,请确认后重试!" fi fi case "${SYSTEM_JUDGMENT}" in "${SYSTEM_FEDORA}") if [[ "${INSTALL_EPEL}" == "true" || "${ONLY_EPEL}" == "true" ]]; then - Output_Error "当前系统不支持安装 EPEL 附件软件包故无法使用相关参数,请确认后重试!" + Output_Error "当前系统不支持安装 EPEL 附件软件包故无法使用相关命令选项,请确认后重试!" fi ;; esac + if [[ "${DEBIAN_CODENAME}" ]]; then + Output_Error "当前系统不支持使用指定版本名称命令选项,请确认后重试!" + fi ;; "${SYSTEM_OPENCLOUDOS}" | "${SYSTEM_OPENEULER}" | "${SYSTEM_OPENSUSE}" | "${SYSTEM_ARCH}") if [[ "${SOURCE_SECURITY}" == "true" || "${SOURCE_BRANCH_SECURITY}" == "true" ]]; then - Output_Error "当前系统不支持使用 security 仓库相关参数,请确认后重试!" + Output_Error "当前系统不支持使用 security 仓库相关命令选项,请确认后重试!" fi if [[ "${SOURCE_VAULT}" == "true" || "${SOURCE_BRANCH_VAULT}" == "true" ]]; then - Output_Error "当前系统不支持安装 EPEL 附件软件包故无法使用相关参数,请确认后重试!" + Output_Error "当前系统不支持安装 EPEL 附件软件包故无法使用相关命令选项,请确认后重试!" fi if [[ "${INSTALL_EPEL}" == "true" || "${ONLY_EPEL}" == "true" ]]; then - Output_Error "当前系统不支持安装 EPEL 附件软件包故无法使用相关参数,请确认后重试!" + Output_Error "当前系统不支持安装 EPEL 附件软件包故无法使用相关命令选项,请确认后重试!" + fi + if [[ "${DEBIAN_CODENAME}" ]]; then + Output_Error "当前系统不支持使用指定版本名称命令选项,请确认后重试!" fi ;; esac @@ -292,7 +298,7 @@ function EnvJudgment() { fi fi SYSTEM_JUDGMENT="$(lsb_release -is)" - SYSTEM_VERSION_CODENAME="$(lsb_release -cs)" + SYSTEM_VERSION_CODENAME="${DEBIAN_CODENAME:-"$(lsb_release -cs)"}" ;; "${SYSTEM_REDHAT}") SYSTEM_JUDGMENT="$(cat $File_RedHatRelease | awk -F ' ' '{printf$1}')" @@ -4847,16 +4853,17 @@ function CommandOptions() { ## 命令帮助 function Output_Help_Info() { echo -e " -选项命令(参数名/含义/参数值): +命令选项(参数名/含义/参数值): - --source 指定软件源地址 地址 - --source-security 指定 debian 的 security 软件源地址 地址 - --source-vault 指定 centos/almalinux 的 vault 软件源地址 地址 - --branch 指定软件源分支(路径) 分支名 - --branch-security 指定 debian 的 security 软件源分支(路径) 分支名 - --branch-vault 指定 centos/almalinux 的 vault 软件源分支(路径) 分支名 --abroad 使用海外软件源 无 --edu 使用中国大陆教育网软件源 无 + --source 指定软件源地址 地址 + --source-security 指定 Debian 的 security 软件源地址 地址 + --source-vault 指定 CentOS/AlmaLinux 的 vault 软件源地址 地址 + --branch 指定软件源分支(路径) 分支名 + --branch-security 指定 Debian 的 security 软件源分支(路径) 分支名 + --branch-vault 指定 CentOS/AlmaLinux 的 vault 软件源分支(路径) 分支名 + --codename 指定 Debian 系操作系统的版本名称 版本名 --web-protocol 指定 WEB 协议 http 或 https --intranet 优先使用内网地址 true 或 false --install-epel 安装 EPEL 附加软件包 true 或 false @@ -4948,6 +4955,15 @@ function CommandOptions() { Output_Error "检测到 ${BLUE}$1${PLAIN} 为无效参数,请在该参数后指定软件源地址!" fi ;; + ## 指定 Debian 系操作系统的版本名称 + --codename) + if [ "$2" ]; then + DEBIAN_CODENAME="$2" + shift + else + Output_Error "检测到 ${BLUE}$1${PLAIN} 为无效参数,请在该参数后指定版本名称!" + fi + ;; ## 优先使用内网地址 --intranet) if [ "$2" ]; then diff --git a/DockerInstallation.sh b/DockerInstallation.sh index 253b636..4cda1e2 100755 --- a/DockerInstallation.sh +++ b/DockerInstallation.sh @@ -1,6 +1,6 @@ #!/bin/bash ## Author: SuperManito -## Modified: 2023-06-19 +## Modified: 2023-06-20 ## License: MIT ## Github: https://github.com/SuperManito/LinuxMirrors ## Website: https://linuxmirrors.cn @@ -158,7 +158,7 @@ function EnvJudgment() { fi fi SYSTEM_JUDGMENT="$(lsb_release -is)" - SYSTEM_VERSION_CODENAME="$(lsb_release -cs)" + SYSTEM_VERSION_CODENAME="${DEBIAN_CODENAME:-"$(lsb_release -cs)"}" ;; "${SYSTEM_REDHAT}") SYSTEM_JUDGMENT="$(cat $File_RedHatRelease | awk -F ' ' '{printf$1}')" @@ -714,10 +714,11 @@ function CommandOptions() { ## 命令帮助 function Output_Help_Info() { echo -e " -选项命令(参数名/含义/参数值): +命令选项(参数名/含义/参数值): --source 指定 Docker CE 源地址 地址 --source-registry 指定 Docker Hub 源地址 地址 + --codename 指定 Debian 系操作系统的版本名称 版本名 --install-latested 控制是否安装最新版本的 Docker Engine true 或 false --ignore-backup-tips 忽略覆盖备份提示 无 @@ -756,6 +757,15 @@ function CommandOptions() { Output_Error "检测到 ${BLUE}$1${PLAIN} 为无效参数,请在该参数后指定软件源地址!" fi ;; + ## 指定 Debian 版本名称 + --codename) + if [ "$2" ]; then + DEBIAN_CODENAME="$2" + shift + else + Output_Error "检测到 ${BLUE}$1${PLAIN} 为无效参数,请在该参数后指定版本名称!" + fi + ;; ## 安装最新版本 --install-latested) if [ "$2" ]; then diff --git a/docs/other/index.md b/docs/other/index.md index 318b615..8df5e86 100644 --- a/docs/other/index.md +++ b/docs/other/index.md @@ -34,20 +34,27 @@ hide: bash <(curl -sSL https://linuxmirrors.cn/docker.sh) ``` +??? quote "原始执行脚本方法" + + ``` bash + bash <(curl -sSL https://gitee.com/SuperManito/LinuxMirrors/raw/main/DockerInstallation.sh) + ``` + !!! node "" - 脚本集成安装 [`Docker Engine`](https://docs.docker.com/engine),可手动选择安装版本、下载软件源、镜像加速器,支持海内外服务器环境和 `arm` 架构处理器环境使用 + 脚本集成安装 [`Docker Engine`](https://docs.docker.com/engine),可选择安装版本、下载软件源、镜像加速器,支持海内外服务器环境和 `arm` 架构处理器环境使用 `Docker CE` 软件镜像仓库,全称 Docker Community Edition ,用于下载并安装 Docker 相关软件包 - `Docker Hub` 容器镜像仓库,默认为官方提供的公共库,用于控制下载镜像的来源存储仓库,又称镜像加速器 + `Docker Hub` 镜像仓库,默认为官方提供的公共库,用于控制下载镜像的来源存储仓库,又称镜像加速器 ### 命令选项 | 名称 | 含义 | 选项值 | | :-: | :-: | :-: | | `--source` | 指定 `Docker CE` 源地址 | 地址 | -| `--source-registry` | 指定 Docker Hub 源地址 | 地址 | -| `--install-latested` | 控制是否安装最新版本的 Docker Engine | 地址 | +| `--source-registry` | 指定镜像仓库地址 | 地址 | +| `--codename` | 指定 Debian 系操作系统的版本名称 | 版本名 | +| `--install-latested` | 控制是否安装最新版本的 Docker Engine | `true` 或 `false` | | `--ignore-backup-tips` | 忽略覆盖备份提示(即不覆盖备份) | 无 | ### 关于服务报错无法启动 @@ -75,9 +82,3 @@ bash <(curl -sSL https://linuxmirrors.cn/docker.sh) > `Red Hat Enterprise Linux`   `CentOS`   `Rocky Linux`   `AlmaLinux`   `Fedora`   `OpenCloudOS`   `openEuler` 卸载完成后重新执行脚本安装即可 - -??? quote "原始执行脚本方法" - - ``` bash - bash <(curl -sSL https://gitee.com/SuperManito/LinuxMirrors/raw/main/DockerInstallation.sh) - ``` diff --git a/docs/use/command-options.md b/docs/use/command-options.md index 70a2d36..340e983 100644 --- a/docs/use/command-options.md +++ b/docs/use/command-options.md @@ -1,13 +1,14 @@ | 名称 | 含义 | 选项值 | | :-: | :-: | :-: | -| `--source` | 指定软件源地址 | 地址 | -| `--source-security` | 指定 debian 的 security 软件源地址 | 地址 | -| `--source-vault` | 指定 centos/almalinux 的 vault 软件源地址 | 地址 | -| `--branch` | 指定软件源分支(路径) | 分支名 | -| `--branch-security` | 指定 debian 的 security 软件源分支(路径) | 分支名 | -| `--branch-vault` | 指定 centos/almalinux 的 vault 软件源分支(路径) | 分支名 | | `--abroad` | 使用海外软件源 | 无 | -| `--abroad` | 使用中国大陆教育网软件源 | 无 | +| `--edu` | 使用中国大陆教育网软件源 | 无 | +| `--source` | 指定软件源地址 | 地址 | +| `--source-security` | 指定 Debian 的 security 软件源地址 | 地址 | +| `--source-vault` | 指定 CentOS/AlmaLinux 的 vault 软件源地址 | 地址 | +| `--branch` | 指定软件源分支(路径) | 分支名 | +| `--branch-security` | 指定 Debian 的 security 软件源分支(路径) | 分支名 | +| `--branch-vault` | 指定 CentOS/AlmaLinux 的 vault 软件源分支(路径) | 分支名 | +| `--codename` | 指定 Debian 系操作系统的版本名称 | 版本名 | | `--web-protocol` | 指定 WEB 协议 | `http` 或 `https` | | `--intranet` | 优先使用内网地址 | `true` 或 `false` | | `--install-epel` | 安装 EPEL 附加软件包 | `true` 或 `false` | @@ -100,7 +101,7 @@ bash <(curl -sSL https://linuxmirrors.cn/main.sh) \ ### 单独更换 EPEL 源 -有些时候你会发现想使用的镜像站没有 epel 镜像仓库,那么你可以在第一次运行脚本时不安装或不更换 epel 源,然后再单独执行下面的命令 +有些时候你会发现想使用的镜像站没有 epel 镜像仓库,那么你可以在第一次运行脚本时不安装或不更换 epel 源然后再单独执行下面的命令 ``` bash bash <(curl -sSL https://linuxmirrors.cn/main.sh) --only-epel @@ -116,6 +117,16 @@ bash <(curl -sSL https://linuxmirrors.cn/main.sh) \ --branch-security debian-security ``` +### 指定 Debian 系操作系统的版本名称 + +你可以自定义该版本名称,大多数情况下用于升级系统版本,请看下面的例子 + +``` { .bash .no-copy title="升级 Debian 至最新 12 版本 Bookworm" } +bash <(curl -sSL https://linuxmirrors.cn/main.sh) \ + --codename bookworm +``` +更换软件源后还需要执行系统更新命令才能实现更新操作,并且建议在更新完成并重启系统后重新执行本换源脚本,因为仅更换软件源配置中的系统版本名称可能会在后期使用时产生一些兼容性问题 + ## 无人值守 不通过交互完成换源操作,需要使用大量命令选项来实现,建议熟悉后再使用