新增适配 I18n

This commit is contained in:
Super Manito
2025-10-12 07:22:53 +08:00
parent f896adb8b6
commit bf2adc1adf
16 changed files with 3376 additions and 640 deletions

View File

@@ -13,39 +13,39 @@ hide:
=== ":linuxmirrors: Official Site (Recommended)"
``` bash
bash <(curl -sSL https://linuxmirrors.cn/main.sh)
bash <(curl -sSL https://linuxmirrors.cn/main.sh) --en
```
=== ":simple-github: GitHub"
``` bash
bash <(curl -sSL https://raw.githubusercontent.com/SuperManito/LinuxMirrors/main/ChangeMirrors.sh)
bash <(curl -sSL https://raw.githubusercontent.com/SuperManito/LinuxMirrors/main/ChangeMirrors.sh) --en
```
=== ":simple-gitee: Gitee"
``` bash
bash <(curl -sSL https://gitee.com/SuperManito/LinuxMirrors/raw/main/ChangeMirrors.sh)
bash <(curl -sSL https://gitee.com/SuperManito/LinuxMirrors/raw/main/ChangeMirrors.sh) --en
```
> Real-time sync, no delay. Recommended for use in Chinese mainland network environments.
=== ":simple-gitcode: GitCode"
``` bash
bash <(curl -sSL https://raw.gitcode.com/SuperManito/LinuxMirrors/raw/main/ChangeMirrors.sh)
bash <(curl -sSL https://raw.gitcode.com/SuperManito/LinuxMirrors/raw/main/ChangeMirrors.sh) --en
```
> 1-hour sync delay.
=== ":simple-jsdelivr: jsDelivr (CDN)"
``` bash
bash <(curl -sSL https://cdn.jsdelivr.net/gh/SuperManito/LinuxMirrors@main/ChangeMirrors.sh)
bash <(curl -sSL https://cdn.jsdelivr.net/gh/SuperManito/LinuxMirrors@main/ChangeMirrors.sh) --en
```
=== ":tencent-cloud: Tencent Cloud EO (CDN)"
``` bash
bash <(curl -sSL https://edgeone.linuxmirrors.cn/main.sh)
bash <(curl -sSL https://edgeone.linuxmirrors.cn/main.sh) --en
```
> Not recommended in Chinese mainland network environments.
@@ -56,33 +56,33 @@ hide:
=== ":linuxmirrors: Official Site (Recommended)"
``` bash
bash <(curl -sSL https://linuxmirrors.cn/main.sh) --abroad
bash <(curl -sSL https://linuxmirrors.cn/main.sh) --en --abroad
```
=== ":simple-github: GitHub"
``` bash
bash <(curl -sSL https://raw.githubusercontent.com/SuperManito/LinuxMirrors/main/ChangeMirrors.sh) --abroad
bash <(curl -sSL https://raw.githubusercontent.com/SuperManito/LinuxMirrors/main/ChangeMirrors.sh) --en --abroad
```
=== ":simple-gitee: Gitee"
``` bash
bash <(curl -sSL https://gitee.com/SuperManito/LinuxMirrors/raw/main/ChangeMirrors.sh) --abroad
bash <(curl -sSL https://gitee.com/SuperManito/LinuxMirrors/raw/main/ChangeMirrors.sh) --en --abroad
```
> Real-time sync, no delay. Recommended for use in Chinese mainland network environments.
=== ":simple-gitcode: GitCode"
``` bash
bash <(curl -sSL https://raw.gitcode.com/SuperManito/LinuxMirrors/raw/main/ChangeMirrors.sh) --abroad
bash <(curl -sSL https://raw.gitcode.com/SuperManito/LinuxMirrors/raw/main/ChangeMirrors.sh) --en --abroad
```
> 1-hour sync delay.
=== ":simple-jsdelivr: jsDelivr (CDN)"
``` bash
bash <(curl -sSL https://cdn.jsdelivr.net/gh/SuperManito/LinuxMirrors@main/ChangeMirrors.sh) --abroad
bash <(curl -sSL https://cdn.jsdelivr.net/gh/SuperManito/LinuxMirrors@main/ChangeMirrors.sh) --en --abroad
```
=== ":tencent-cloud: Tencent Cloud EO (CDN)"
@@ -99,39 +99,39 @@ hide:
=== ":linuxmirrors: Official Site (Recommended)"
``` bash
bash <(curl -sSL https://linuxmirrors.cn/main.sh) --edu
bash <(curl -sSL https://linuxmirrors.cn/main.sh) --en --edu
```
=== ":simple-github: GitHub"
``` bash
bash <(curl -sSL https://raw.githubusercontent.com/SuperManito/LinuxMirrors/main/ChangeMirrors.sh) --edu
bash <(curl -sSL https://raw.githubusercontent.com/SuperManito/LinuxMirrors/main/ChangeMirrors.sh) --en --edu
```
=== ":simple-gitee: Gitee"
``` bash
bash <(curl -sSL https://gitee.com/SuperManito/LinuxMirrors/raw/main/ChangeMirrors.sh) --edu
bash <(curl -sSL https://gitee.com/SuperManito/LinuxMirrors/raw/main/ChangeMirrors.sh) --en --edu
```
> Real-time sync, no delay. Recommended for use in Chinese mainland network environments.
=== ":simple-gitcode: GitCode"
``` bash
bash <(curl -sSL https://raw.gitcode.com/SuperManito/LinuxMirrors/raw/main/ChangeMirrors.sh) --edu
bash <(curl -sSL https://raw.gitcode.com/SuperManito/LinuxMirrors/raw/main/ChangeMirrors.sh) --en --edu
```
> 1-hour sync delay.
=== ":simple-jsdelivr: jsDelivr (CDN)"
``` bash
bash <(curl -sSL https://cdn.jsdelivr.net/gh/SuperManito/LinuxMirrors@main/ChangeMirrors.sh) --edu
bash <(curl -sSL https://cdn.jsdelivr.net/gh/SuperManito/LinuxMirrors@main/ChangeMirrors.sh) --en --edu
```
=== ":tencent-cloud: Tencent Cloud EO (CDN)"
``` bash
bash <(curl -sSL https://edgeone.linuxmirrors.cn/main.sh) --edu
bash <(curl -sSL https://edgeone.linuxmirrors.cn/main.sh) --en --edu
```
> Not recommended in Chinese mainland network environments.
@@ -436,7 +436,7 @@ hide:
<!-- termynal -->
```
$ bash <(curl -sSL https://linuxmirrors.cn/main.sh) --help
$ bash <(curl -sSL https://linuxmirrors.cn/main.sh) --en --help
Command options(name/meaning/value):
@@ -464,6 +464,7 @@ Command options(name/meaning/value):
--upgrade-software Upgrade packages true or false
--clean-cache Clean cache after upgrade true or false
--clean-screen Clear screen before running true or false
--lang Specify the language of the script output language
--only-epel Only switch EPEL repo none
--ignore-backup-tips Ignore backup overwrite prompt none
--print-diff Print diff before and after modification none
@@ -497,6 +498,7 @@ Command options(name/meaning/value):
| `--upgrade-software` | Upgrade packages | `true` or `false` |
| `--clean-cache` | Clean cache after upgrade | `true` or `false` |
| `--clean-screen` | Clear screen before running | `true` or `false` |
| `--lang` | Specify the language of the script output | `language id (see docs below)` |
| `--only-epel` | Only switch EPEL repo | none |
| `--ignore-backup-tips` | Ignore backup overwrite prompt | none |
| `--print-diff` | Print diff before and after modification | none |
@@ -510,7 +512,7 @@ Below are some advanced usage examples
- ### Specify mirror address
``` { .bash .no-copy }
bash <(curl -sSL https://linuxmirrors.cn/main.sh) --source mirror.example.com
bash <(curl -sSL https://linuxmirrors.cn/main.sh) --en --source mirror.example.com
```
- ### Specify mirror repository directory
@@ -554,7 +556,7 @@ Below are some advanced usage examples
Example:
``` { .bash title="Use Aliyun mirror for Rocky Linux" }
bash <(curl -sSL https://linuxmirrors.cn/main.sh) \
bash <(curl -sSL https://linuxmirrors.cn/main.sh) --en \
--source mirrors.aliyun.com \
--branch rockylinux
```
@@ -572,7 +574,7 @@ Below are some advanced usage examples
Sometimes your desired mirror does not have EPEL. You can skip EPEL during the first run and then run:
``` bash
bash <(curl -sSL https://linuxmirrors.cn/main.sh) --only-epel
bash <(curl -sSL https://linuxmirrors.cn/main.sh) --en --only-epel
```
For EPEL 7 (EOL), use the [`archive`](https://dl.fedoraproject.org/pub/archive/epel) repo. For overseas networks, use `--use-official-source-epel true` to use the official repo.
@@ -582,7 +584,7 @@ Below are some advanced usage examples
If you accidentally deleted the backup of the official mirror, use this command to restore. This skips mirror selection.
``` bash
bash <(curl -sSL https://linuxmirrors.cn/main.sh) --use-official-source true
bash <(curl -sSL https://linuxmirrors.cn/main.sh) --en --use-official-source true
```
> Some systems (e.g., `Arch Linux`) have no official mirror, so Aliyun will be used as a fallback.
@@ -615,7 +617,7 @@ Below are some advanced usage examples
For maximum security, use the official repo due to mirror sync delays.
``` bash
bash <(curl -sSL https://linuxmirrors.cn/main.sh) \
bash <(curl -sSL https://linuxmirrors.cn/main.sh) --en \
--source-security security.debian.org \
--branch-security debian-security
```
@@ -629,7 +631,7 @@ Below are some advanced usage examples
- Change version code
``` bash
bash <(curl -sSL https://linuxmirrors.cn/main.sh) \
bash <(curl -sSL https://linuxmirrors.cn/main.sh) --en \
--codename trixie \
--upgrade-software false
```
@@ -653,13 +655,13 @@ Below are some advanced usage examples
# Clear the original software sources (If there is any non-system software source content, please back it up manually first)
sed -i '1,$d' /etc/apt/sources.list
# Rerun the mirror switching script
bash <(curl -sSL https://linuxmirrors.cn/main.sh)
bash <(curl -sSL https://linuxmirrors.cn/main.sh) --en
```
=== "Switch GNU/Linux Debian to testing branch"
``` bash
bash <(curl -sSL https://linuxmirrors.cn/main.sh) \
bash <(curl -sSL https://linuxmirrors.cn/main.sh) --en \
--codename testing \
--upgrade-software false
```
@@ -675,7 +677,7 @@ Below are some advanced usage examples
See the official [Wiki](https://wiki.ubuntu.com/Releases) for version support and check each mirror for `Ubuntu Old Releases` support.
``` bash
bash <(curl -sSL https://linuxmirrors.cn/main.sh) \
bash <(curl -sSL https://linuxmirrors.cn/main.sh) --en \
--source mirrors.ustc.edu.cn \
--branch ubuntu-old-releases
```
@@ -689,12 +691,41 @@ Below are some advanced usage examples
grep -q "\[archlinuxcn\]" /etc/pacman.conf || echo -e "[archlinuxcn]\nServer = ${SOURCE}/\$arch" >>/etc/pacman.conf
```
- ### Unattended (automation)
- ### I18n (Internationalization)
The script provides multi-language support. Currently, there are three built-in display languages: `简体中文`、`繁體中文`、`English`. The default is `简体中文`.
- #### Specify Language
``` { .bash .no-copy }
bash <(curl -sSL https://linuxmirrors.cn/main.sh) --lang xxx
```
| Type | Value |
| :-: | :-: |
| 简体中文 | `zh-hans` `zh-cn` `zh` |
| 繁體中文 | `zh-hant` `zh-tw` `zh-hk` |
| English | `en` `en-us` |
It can also be used directly as a command option
``` bash
bash <(curl -sSL https://linuxmirrors.cn/main.sh) --zh-hant
```
> `--en` `--en-us` `--zh` `--zh-cn` `--zh-hans` `--zh-hant`
- #### Select through interaction
``` bash
bash <(curl -sSL https://linuxmirrors.cn/main.sh) --lang auto
```
- ### Unattended (Automation)
To run without interaction, use at least the following options. Recommended for experienced users.
``` { .bash .no-copy title="Example Command" }
bash <(curl -sSL https://linuxmirrors.cn/main.sh) \
bash <(curl -sSL https://linuxmirrors.cn/main.sh) --en \
--source mirror.example.com \
--protocol http \
--use-intranet-source false \
@@ -711,7 +742,7 @@ Below are some advanced usage examples
This feature is introduced to facilitate the use of developers and operation and maintenance personnel. After it is enabled, the script content output will be simplified. It is recommended to use it with other command options without interaction.
``` bash
bash <(curl -sSL https://linuxmirrors.cn/main.sh) --pure-mode
bash <(curl -sSL https://linuxmirrors.cn/main.sh) --en --pure-mode
```
!!! tip "Scrolling command logs may have unpredictable display issues, but no problems have been found so far."
@@ -730,6 +761,7 @@ If you are a developer of another project and want to create a custom script bas
1. Keep the original structure; empty out the function bodies if not needed.
2. Remove unused OS repo content `gen_repo_files_xxx`, which takes up over 60% of the script.
3. Remove unused feature modules, e.g., `handle_command_options`, `backup_original_mirrors`, `upgrade_software`.
4. Remove unnecessary language packs, for example: `function msg_pack_en() {}`
6. Main configuration is controlled by unified variables, as are command options. These global variables are all uppercase and use underscores. See the table below. Declare them at the top of the script (reserved comment area) for quick customization.
| Variable | Meaning | Value Type |

View File

@@ -466,6 +466,7 @@ $ bash <(curl -sSL https://linuxmirrors.cn/main.sh) --help
--upgrade-software 是否更新软件包 true 或 false
--clean-cache 是否在更新软件包后清理下载缓存 true 或 false
--clean-screen 是否在运行前清除屏幕上的所有内容 true 或 false
--lang 指定脚本输出的语言 语言
--only-epel 仅更换 EPEL 软件源模式 无
--ignore-backup-tips 忽略覆盖备份提示 无
--print-diff 打印源文件修改前后差异 无
@@ -499,6 +500,7 @@ $ bash <(curl -sSL https://linuxmirrors.cn/main.sh) --help
| `--upgrade-software` | 是否更新软件包 | `true` 或 `false` |
| `--clean-cache` | 是否在更新软件包后清理下载缓存 | `true` 或 `false` |
| `--clean-screen` | 是否在运行前清除屏幕上的所有内容 | `true` 或 `false` |
| `--lang` | 指定脚本输出的语言 | `语言ID详见下方文档` |
| `--only-epel` | 仅更换 EPEL 软件源模式 | 无 |
| `--ignore-backup-tips` | 忽略覆盖备份提示(即不覆盖备份) | 无 |
| `--print-diff` | 是否打印源文件修改前后差异 | 无 |
@@ -691,6 +693,35 @@ $ bash <(curl -sSL https://linuxmirrors.cn/main.sh) --help
grep -q "\[archlinuxcn\]" /etc/pacman.conf || echo -e "[archlinuxcn]\nServer = ${SOURCE}/\$arch" >>/etc/pacman.conf # 一键配置命令
```
- ### 国际化I18n
脚本提供多语言支持,当前内置 `简体中文`、`繁體中文`、`English` 共三种显示语言,默认为 `简体中文`
- #### 指定语言
``` { .bash .no-copy }
bash <(curl -sSL https://linuxmirrors.cn/main.sh) --lang xxx
```
| 类型 | 值 |
| :-: | :-: |
| 简体中文 | `zh-hans` `zh-cn` `zh` |
| 繁體中文 | `zh-hant` `zh-tw` `zh-hk` |
| English | `en` `en-us` |
也可以直接作为命令选项使用
``` bash
bash <(curl -sSL https://linuxmirrors.cn/main.sh) --en
```
> `--en` `--en-us` `--zh` `--zh-cn` `--zh-hans` `--zh-hant`
- #### 通过交互进行选择
``` bash
bash <(curl -sSL https://linuxmirrors.cn/main.sh) --lang auto
```
- ### 无人值守(自动化)
不通过交互完成换源操作,至少需要使用如下命令选项来实现,建议熟悉后再使用
@@ -732,6 +763,7 @@ $ bash <(curl -sSL https://linuxmirrors.cn/main.sh) --help
1. 首先在删除内容时应尽可能保留脚本原始结构,直接把涉及函数中的内容删除即可,使其保留为空函数
2. 可以删除一些不使用(操作系统)的软件源原始内容 `gen_repo_files_xxx`,这些内容占据了脚本 `60%` 以上的体积
3. 如果你不使用某些功能那么可以删除对应功能模块函数中的内容,`命令选项 handle_command_options`、`备份原有软件源 backup_original_mirrors`、`更新软件包 upgrade_software`
4. 移除不需要的语言包,例:`function msg_pack_en() {}`
6. 脚本主要功能配置是由统一的变量控制的,命令选项亦是如此,这些全局变量由全大写字母构成并遵循下划线命名法,具体变量详见如下表格,你只需要将这些变量声明在脚本头部(预留注释区域)即可快速完成定制
| 变量名 | 含义 | 值类型 |

View File

@@ -13,39 +13,39 @@ hide:
=== ":linuxmirrors: 官網 (推薦)"
``` bash
bash <(curl -sSL https://linuxmirrors.cn/main.sh)
bash <(curl -sSL https://linuxmirrors.cn/main.sh) --zh-hant
```
=== ":simple-github: GitHub"
``` bash
bash <(curl -sSL https://raw.githubusercontent.com/SuperManito/LinuxMirrors/main/ChangeMirrors.sh)
bash <(curl -sSL https://raw.githubusercontent.com/SuperManito/LinuxMirrors/main/ChangeMirrors.sh) --zh-hant
```
=== ":simple-gitee: Gitee 碼雲 (鏡像倉庫)"
``` bash
bash <(curl -sSL https://gitee.com/SuperManito/LinuxMirrors/raw/main/ChangeMirrors.sh)
bash <(curl -sSL https://gitee.com/SuperManito/LinuxMirrors/raw/main/ChangeMirrors.sh) --zh-hant
```
> 即時同步、無延遲,中國大陸網路環境下推薦使用
=== ":simple-gitcode: GitCode (鏡像倉庫)"
``` bash
bash <(curl -sSL https://raw.gitcode.com/SuperManito/LinuxMirrors/raw/main/ChangeMirrors.sh)
bash <(curl -sSL https://raw.gitcode.com/SuperManito/LinuxMirrors/raw/main/ChangeMirrors.sh) --zh-hant
```
> 同步存在1小時延遲
=== ":simple-jsdelivr: jsDelivr (CDN)"
``` bash
bash <(curl -sSL https://cdn.jsdelivr.net/gh/SuperManito/LinuxMirrors@main/ChangeMirrors.sh)
bash <(curl -sSL https://cdn.jsdelivr.net/gh/SuperManito/LinuxMirrors@main/ChangeMirrors.sh) --zh-hant
```
=== ":tencent-cloud: 騰訊雲 EO (CDN)"
``` bash
bash <(curl -sSL https://edgeone.linuxmirrors.cn/main.sh)
bash <(curl -sSL https://edgeone.linuxmirrors.cn/main.sh) --zh-hant
```
> 不建議在中國大陸網路環境下使用
@@ -56,26 +56,26 @@ hide:
=== ":linuxmirrors: 官網 (推薦)"
``` bash
bash <(curl -sSL https://linuxmirrors.cn/main.sh) --abroad
bash <(curl -sSL https://linuxmirrors.cn/main.sh) --zh-hant --abroad
```
=== ":simple-github: GitHub"
``` bash
bash <(curl -sSL https://raw.githubusercontent.com/SuperManito/LinuxMirrors/main/ChangeMirrors.sh) --abroad
bash <(curl -sSL https://raw.githubusercontent.com/SuperManito/LinuxMirrors/main/ChangeMirrors.sh) --zh-hant --abroad
```
=== ":simple-gitee: Gitee 碼雲 (鏡像倉庫)"
``` bash
bash <(curl -sSL https://gitee.com/SuperManito/LinuxMirrors/raw/main/ChangeMirrors.sh) --abroad
bash <(curl -sSL https://gitee.com/SuperManito/LinuxMirrors/raw/main/ChangeMirrors.sh) --zh-hant --abroad
```
> 即時同步、無延遲,中國大陸網路環境下推薦使用
=== ":simple-gitcode: GitCode (鏡像倉庫)"
``` bash
bash <(curl -sSL https://raw.gitcode.com/SuperManito/LinuxMirrors/raw/main/ChangeMirrors.sh) --abroad
bash <(curl -sSL https://raw.gitcode.com/SuperManito/LinuxMirrors/raw/main/ChangeMirrors.sh) --zh-hant --abroad
```
> 同步存在1小時延遲
@@ -83,13 +83,13 @@ hide:
=== ":simple-jsdelivr: jsDelivr (CDN)"
``` bash
bash <(curl -sSL https://cdn.jsdelivr.net/gh/SuperManito/LinuxMirrors@main/ChangeMirrors.sh) --abroad
bash <(curl -sSL https://cdn.jsdelivr.net/gh/SuperManito/LinuxMirrors@main/ChangeMirrors.sh) --zh-hant --abroad
```
=== ":tencent-cloud: 騰訊雲 EO (CDN)"
``` bash
bash <(curl -sSL https://edgeone.linuxmirrors.cn/main.sh) --abroad
bash <(curl -sSL https://edgeone.linuxmirrors.cn/main.sh) --zh-hant --abroad
```
> 不建議在中國大陸網路環境下使用
@@ -100,26 +100,26 @@ hide:
=== ":linuxmirrors: 官網 (推薦)"
``` bash
bash <(curl -sSL https://linuxmirrors.cn/main.sh) --edu
bash <(curl -sSL https://linuxmirrors.cn/main.sh) --zh-hant --edu
```
=== ":simple-github: GitHub"
``` bash
bash <(curl -sSL https://raw.githubusercontent.com/SuperManito/LinuxMirrors/main/ChangeMirrors.sh) --edu
bash <(curl -sSL https://raw.githubusercontent.com/SuperManito/LinuxMirrors/main/ChangeMirrors.sh) --zh-hant --edu
```
=== ":simple-gitee: Gitee 碼雲 (鏡像倉庫)"
``` bash
bash <(curl -sSL https://gitee.com/SuperManito/LinuxMirrors/raw/main/ChangeMirrors.sh) --edu
bash <(curl -sSL https://gitee.com/SuperManito/LinuxMirrors/raw/main/ChangeMirrors.sh) --zh-hant --edu
```
> 即時同步、無延遲,中國大陸網路環境下推薦使用
=== ":simple-gitcode: GitCode (鏡像倉庫)"
``` bash
bash <(curl -sSL https://raw.gitcode.com/SuperManito/LinuxMirrors/raw/main/ChangeMirrors.sh) --edu
bash <(curl -sSL https://raw.gitcode.com/SuperManito/LinuxMirrors/raw/main/ChangeMirrors.sh) --zh-hant --edu
```
> 同步存在1小時延遲
@@ -127,13 +127,13 @@ hide:
=== ":simple-jsdelivr: jsDelivr (CDN)"
``` bash
bash <(curl -sSL https://cdn.jsdelivr.net/gh/SuperManito/LinuxMirrors@main/ChangeMirrors.sh) --edu
bash <(curl -sSL https://cdn.jsdelivr.net/gh/SuperManito/LinuxMirrors@main/ChangeMirrors.sh) --zh-hant --edu
```
=== ":tencent-cloud: 騰訊雲 EO (CDN)"
``` bash
bash <(curl -sSL https://edgeone.linuxmirrors.cn/main.sh) --edu
bash <(curl -sSL https://edgeone.linuxmirrors.cn/main.sh) --zh-hant --edu
```
> 不建議在中國大陸網路環境下使用
@@ -438,7 +438,7 @@ hide:
<!-- termynal -->
```
$ bash <(curl -sSL https://linuxmirrors.cn/main.sh) --help
$ bash <(curl -sSL https://linuxmirrors.cn/main.sh) --zh-hant --help
命令選項(名稱/含義/值)
@@ -466,6 +466,7 @@ $ bash <(curl -sSL https://linuxmirrors.cn/main.sh) --help
--upgrade-software 是否更新軟體包 true 或 false
--clean-cache 是否在更新軟體包後清理下載快取 true 或 false
--clean-screen 是否在運行前清除螢幕上的所有內容 true 或 false
--lang 指定腳本輸出的語言 语言
--only-epel 僅更換 EPEL 軟體源模式 無
--ignore-backup-tips 忽略覆蓋備份提示 無
--print-diff 是否列印原始文件修改前後差異 無
@@ -499,6 +500,7 @@ $ bash <(curl -sSL https://linuxmirrors.cn/main.sh) --help
| `--upgrade-software` | 是否更新軟體套件 | `true` 或 `false` |
| `--clean-cache` | 是否在更新軟體包後清理下載快取 | `true` 或 `false` |
| `--clean-screen` | 是否在運行前清除螢幕上的所有內容 | `true` 或 `false` |
| `--lang` | 指定腳本輸出的語言 | `語言ID詳見下方文件` |
| `--only-epel` | 僅更換 EPEL 軟體源模式 | 無 |
| `--ignore-backup-tips` | 忽略覆蓋備份提示(即不覆蓋備份) | 無 |
| `--print-diff` | 是否列印原始文件修改前後差異 | 無 |
@@ -512,7 +514,7 @@ $ bash <(curl -sSL https://linuxmirrors.cn/main.sh) --help
- ### 指定軟體源位址
``` { .bash .no-copy }
bash <(curl -sSL https://linuxmirrors.cn/main.sh) --source mirror.example.com
bash <(curl -sSL https://linuxmirrors.cn/main.sh) --zh-hant --source mirror.example.com
```
- ### 指定軟體源倉庫目錄
@@ -556,7 +558,7 @@ $ bash <(curl -sSL https://linuxmirrors.cn/main.sh) --help
請看下面的例子
``` { .bash title="使用阿里雲鏡像站的 Rocky Linux 軟體源" }
bash <(curl -sSL https://linuxmirrors.cn/main.sh) \
bash <(curl -sSL https://linuxmirrors.cn/main.sh) --zh-hant \
--source mirrors.aliyun.com \
--branch rockylinux
```
@@ -574,7 +576,7 @@ $ bash <(curl -sSL https://linuxmirrors.cn/main.sh) --help
有些時候你會發現想使用的鏡像站沒有 EPEL 倉庫,那麼你可以在第一次運行腳本時不安裝或更換 EPEL 軟體源,然後再單獨執行下面的命令
``` bash
bash <(curl -sSL https://linuxmirrors.cn/main.sh) --only-epel
bash <(curl -sSL https://linuxmirrors.cn/main.sh) --zh-hant --only-epel
```
對於已經 EOL 的 EPEL 7注意需要使用 [`archive`](https://dl.fedoraproject.org/pub/archive/epel) 倉庫,境外以及海外網絡環境建議通過命令選項 `--use-official-source-epel true` 使用官方源
@@ -584,7 +586,7 @@ $ bash <(curl -sSL https://linuxmirrors.cn/main.sh) --help
當你不小心刪除了官方軟體源的備份時可以使用此命令來恢復,使用此命令選項後將跳過選擇軟體源步驟
``` bash
bash <(curl -sSL https://linuxmirrors.cn/main.sh) --use-official-source true
bash <(curl -sSL https://linuxmirrors.cn/main.sh) --zh-hant --use-official-source true
```
> 部分系統不存在官方軟體源例如 `Arch Linux`,屆時會自動更換成相容性較高的阿里雲鏡像站
@@ -617,7 +619,7 @@ $ bash <(curl -sSL https://linuxmirrors.cn/main.sh) --help
如果你想盡可能提高伺服器的安全性建議使用官方軟體源,因為鏡像同步存在延遲
``` bash
bash <(curl -sSL https://linuxmirrors.cn/main.sh) \
bash <(curl -sSL https://linuxmirrors.cn/main.sh) --zh-hant \
--source-security security.debian.org \
--branch-security debian-security
```
@@ -631,7 +633,7 @@ $ bash <(curl -sSL https://linuxmirrors.cn/main.sh) --help
- 更換版本代號
``` bash
bash <(curl -sSL https://linuxmirrors.cn/main.sh) \
bash <(curl -sSL https://linuxmirrors.cn/main.sh) --zh-hant \
--codename trixie \
--upgrade-software false
```
@@ -655,13 +657,13 @@ $ bash <(curl -sSL https://linuxmirrors.cn/main.sh) --help
# 清空原有軟體源(如有非系統軟體源內容請先自行手動備份)
sed -i '1,$d' /etc/apt/sources.list
# 重新執行換源腳本
bash <(curl -sSL https://linuxmirrors.cn/main.sh)
bash <(curl -sSL https://linuxmirrors.cn/main.sh) --zh-hant
```
=== "將 GNU/Linux Debian 的版本切換到測試分支"
``` bash
bash <(curl -sSL https://linuxmirrors.cn/main.sh) \
bash <(curl -sSL https://linuxmirrors.cn/main.sh) --zh-hant \
--codename testing \
--upgrade-software false
```
@@ -677,7 +679,7 @@ $ bash <(curl -sSL https://linuxmirrors.cn/main.sh) --help
具體版本支援情況詳見官方 [Wiki](https://wiki.ubuntu.com/Releases),關於 `Ubuntu Old Releases` 倉庫的支援情況詳見各鏡像站
``` bash
bash <(curl -sSL https://linuxmirrors.cn/main.sh) \
bash <(curl -sSL https://linuxmirrors.cn/main.sh) --zh-hant \
--source mirrors.ustc.edu.cn \
--branch ubuntu-old-releases
```
@@ -691,12 +693,41 @@ $ bash <(curl -sSL https://linuxmirrors.cn/main.sh) --help
grep -q "\[archlinuxcn\]" /etc/pacman.conf || echo -e "[archlinuxcn]\nServer = ${SOURCE}/\$arch" >>/etc/pacman.conf # 一鍵配置命令
```
- ### 國際化I18n
腳本提供多語言支持,目前內建 `簡體中文`、`繁體中文`、`English` 共三種顯示語言,預設為 `簡體中文`
- #### 指定語言
``` { .bash .no-copy }
bash <(curl -sSL https://linuxmirrors.cn/main.sh) --lang xxx
```
| 類型 | 值 |
| :-: | :-: |
| 简体中文 | `zh-hans` `zh-cn` `zh` |
| 繁體中文 | `zh-hant` `zh-tw` `zh-hk` |
| English | `en` `en-us` |
也可以直接作為指令選項使用
``` bash
bash <(curl -sSL https://linuxmirrors.cn/main.sh) --en
```
> `--en` `--en-us` `--zh` `--zh-cn` `--zh-hans` `--zh-hant`
- #### 透過互動進行選擇
``` bash
bash <(curl -sSL https://linuxmirrors.cn/main.sh) --lang auto
```
- ### 無人值守(自動化)
不透過交互完成換源操作,至少需要使用以下命令選項來實現,建議熟悉後再使用
``` { .bash .no-copy title="参考命令" }
bash <(curl -sSL https://linuxmirrors.cn/main.sh) \
bash <(curl -sSL https://linuxmirrors.cn/main.sh) --zh-hant \
--source mirror.example.com \
--protocol http \
--use-intranet-source false \
@@ -713,7 +744,7 @@ $ bash <(curl -sSL https://linuxmirrors.cn/main.sh) --help
推出此功能是為了方便開發以及运維人員使用,啟用後會精簡腳本內容輸出,建議搭配其它指令選項無互動使用
``` bash
bash <(curl -sSL https://linuxmirrors.cn/main.sh) --pure-mode
bash <(curl -sSL https://linuxmirrors.cn/main.sh) --zh-hant --pure-mode
```
!!! tip "滾動輸出的命令日誌可能有無法預料的顯示問題,不過目前暫未發現異常"
@@ -732,4 +763,5 @@ $ bash <(curl -sSL https://linuxmirrors.cn/main.sh) --help
1. 首先在刪除內容時應盡可能保留腳本原始結構,直接把涉及函數中的內容刪除即可,使其保留為空函數
2. 可以刪除一些不使用(作業系統)的軟體源原始內容 `gen_repo_files_xxx`,這些內容佔據了腳本 `60%` 以上的體積
3. 如果你不使用某些功能,那麼可以刪除對應功能模組函數中的內容,`命令選項 handle_command_options`、`備份原有軟體源 backup_original_mirrors`、`更新軟體包 upgrade_software`
4. 移除不需要的語言包,例:`function msg_pack_en() {}`
6. 腳本主要功能配置是由統一的變量控制的,命令選項亦是如此,這些全局變量由全大寫字母構成並遵循下劃線命名法,具體變量詳見如下表格,你只需要將這些變量聲明在腳本頭部(預留註釋區域)即可快速完成定制