mirror of
https://gitee.com/SuperManito/LinuxMirrors
synced 2025-11-01 23:10:28 +08:00
优化
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
#!/bin/bash
|
||||
## Author: SuperManito
|
||||
## Modified: 2025-10-20
|
||||
## Modified: 2025-11-01
|
||||
## License: MIT
|
||||
## GitHub: https://github.com/SuperManito/LinuxMirrors
|
||||
## Website: https://linuxmirrors.cn
|
||||
@@ -1088,7 +1088,7 @@ function check_command_options() {
|
||||
function choose_display_language() {
|
||||
local result
|
||||
if command_exists tput; then
|
||||
local lang_key_labels=()
|
||||
local -a lang_key_labels=()
|
||||
local language_text
|
||||
for ((i = 0; i < ${#MESSAGE_LANG_KEYS[@]}; i++)); do
|
||||
language_text="${MESSAGE_LANG_DISPLAY[${MESSAGE_LANG_KEYS[$i]}]}"
|
||||
@@ -1136,22 +1136,21 @@ function choose_mirrors() {
|
||||
local text=$1
|
||||
echo "${#text}"
|
||||
}
|
||||
|
||||
local list_arr=()
|
||||
local -a list_arr=()
|
||||
local list_arr_sum="$(eval echo \${#$1[@]})"
|
||||
for ((i = 0; i < $list_arr_sum; i++)); do
|
||||
list_arr[$i]="$(eval echo \${$1[i]})"
|
||||
done
|
||||
local name_width=${2:-"30"}
|
||||
local __labels=()
|
||||
local -a list_labels=()
|
||||
if [[ "${3}" ]]; then
|
||||
eval "__labels=(\"\${${3}[@]}\")"
|
||||
eval "list_labels=(\"\${${3}[@]}\")"
|
||||
fi
|
||||
if command_exists printf; then
|
||||
local tmp_uchar_1 tmp_uchar_2 tmp_uchar_3 tmp_uchar_4 tmp_default_length tmp_length tmp_unicode_length tmp_spaces_nums tmp_max_length
|
||||
for ((i = 0; i < ${#list_arr[@]}; i++)); do
|
||||
if [[ "${__labels[$i]}" ]]; then
|
||||
tmp_name="${__labels[$i]}"
|
||||
if [[ "${list_labels[$i]}" ]]; then
|
||||
tmp_name="${list_labels[$i]}"
|
||||
else
|
||||
tmp_name="${list_arr[i]}"
|
||||
fi
|
||||
@@ -1176,8 +1175,8 @@ function choose_mirrors() {
|
||||
done
|
||||
else
|
||||
for ((i = 0; i < ${#list_arr[@]}; i++)); do
|
||||
if [[ "${__labels[$i]}" ]]; then
|
||||
tmp_name="${__labels[$i]}"
|
||||
if [[ "${list_labels[$i]}" ]]; then
|
||||
tmp_name="${list_labels[$i]}"
|
||||
else
|
||||
tmp_name="${list_arr[i]}"
|
||||
fi
|
||||
@@ -1248,7 +1247,7 @@ function choose_mirrors() {
|
||||
mirror_list_label_msg_prefix="mirrors.default"
|
||||
mirror_list_print_length=32
|
||||
fi
|
||||
local mirror_list_labels=()
|
||||
local -a mirror_list_labels=()
|
||||
local mirror_list_length=$(eval "echo \${#${mirror_list_name}[@]}")
|
||||
local label_msg_index label_msg_content
|
||||
for ((i = 0; i < ${mirror_list_length}; i++)); do
|
||||
@@ -1611,7 +1610,7 @@ function remove_original_mirrors() {
|
||||
mkdir -p "${Dir_YumRepos}"
|
||||
return
|
||||
fi
|
||||
local repo_patterns=()
|
||||
local -a repo_patterns=()
|
||||
if [[ "${SYSTEM_JUDGMENT}" == "${SYSTEM_FEDORA}" ]]; then
|
||||
repo_patterns=(
|
||||
"fedora.repo"
|
||||
@@ -1849,7 +1848,7 @@ function change_mirrors_main() {
|
||||
print_diff
|
||||
fi
|
||||
## 更新软件源
|
||||
local commands=()
|
||||
local -a commands=()
|
||||
case "${SYSTEM_FACTIONS}" in
|
||||
"${SYSTEM_DEBIAN}" | "${SYSTEM_OPENKYLIN}")
|
||||
commands+=("apt-get update")
|
||||
@@ -1972,7 +1971,7 @@ function upgrade_software() {
|
||||
esac
|
||||
fi
|
||||
fi
|
||||
local commands=()
|
||||
local -a commands=()
|
||||
case "${SYSTEM_FACTIONS}" in
|
||||
"${SYSTEM_DEBIAN}" | "${SYSTEM_OPENKYLIN}")
|
||||
commands+=("apt-get upgrade -y")
|
||||
@@ -2793,7 +2792,7 @@ function change_mirrors_openSUSE() {
|
||||
|
||||
## 修改源
|
||||
cd $Dir_ZYppRepos
|
||||
local opensuse_repo_files=()
|
||||
local -a opensuse_repo_files=()
|
||||
case "${SYSTEM_ID}" in
|
||||
opensuse-leap)
|
||||
case "${SYSTEM_VERSION_ID_MAJOR}" in
|
||||
@@ -3071,8 +3070,8 @@ function get_package_manager() {
|
||||
|
||||
function interactive_select_list() {
|
||||
_SELECT_RESULT=""
|
||||
eval "local __values=(\"\${${1}[@]}\")"
|
||||
local __labels=()
|
||||
eval "local -a __values=(\"\${${1}[@]}\")"
|
||||
local -a __labels=()
|
||||
local message="${2}"
|
||||
local selected=0
|
||||
local start=0
|
||||
@@ -3306,7 +3305,7 @@ function animate_exec() {
|
||||
exit 130
|
||||
}
|
||||
function make_temp_file() {
|
||||
local temp_dirs=("." "/tmp")
|
||||
local -a temp_dirs=("." "/tmp")
|
||||
local tmp_file=""
|
||||
for dir in "${temp_dirs[@]}"; do
|
||||
[[ ! -d "${dir}" || ! -w "${dir}" ]] && continue
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#!/bin/bash
|
||||
## Author: SuperManito
|
||||
## Modified: 2025-10-23
|
||||
## Modified: 2025-11-01
|
||||
## License: MIT
|
||||
## GitHub: https://github.com/SuperManito/LinuxMirrors
|
||||
## Website: https://linuxmirrors.cn
|
||||
@@ -697,7 +697,7 @@ function collect_system_info() {
|
||||
function choose_display_language() {
|
||||
local result
|
||||
if command_exists tput; then
|
||||
local lang_key_labels=()
|
||||
local -a lang_key_labels=()
|
||||
local language_text
|
||||
for ((i = 0; i < ${#MESSAGE_LANG_KEYS[@]}; i++)); do
|
||||
language_text="${MESSAGE_LANG_DISPLAY[${MESSAGE_LANG_KEYS[$i]}]}"
|
||||
@@ -744,14 +744,13 @@ function choose_mirrors() {
|
||||
local text=$1
|
||||
echo "${#text}"
|
||||
}
|
||||
|
||||
local list_arr=()
|
||||
local -a list_arr=()
|
||||
local list_arr_sum="$(eval echo \${#$1[@]})"
|
||||
for ((i = 0; i < $list_arr_sum; i++)); do
|
||||
list_arr[$i]="$(eval echo \${$1[i]})"
|
||||
done
|
||||
local name_width=${2:-"30"}
|
||||
local list_labels=()
|
||||
local -a list_labels=()
|
||||
if [[ "${3}" ]]; then
|
||||
eval "list_labels=(\"\${${3}[@]}\")"
|
||||
fi
|
||||
@@ -837,7 +836,7 @@ function choose_mirrors() {
|
||||
}
|
||||
|
||||
local mirror_list_name mirror_list_length
|
||||
local mirror_list_labels=()
|
||||
local -a mirror_list_labels=()
|
||||
local label_msg_index label_msg_content
|
||||
if [[ -z "${SOURCE}" ]] && [[ "${ONLY_REGISTRY}" != "true" ]]; then
|
||||
mirror_list_name="mirror_list_docker_ce"
|
||||
@@ -1087,7 +1086,7 @@ function install_dependency_packages() {
|
||||
|
||||
## 配置 Docker CE 源
|
||||
function configure_docker_ce_mirror() {
|
||||
local commands=()
|
||||
local -a commands=()
|
||||
case "${SYSTEM_FACTIONS}" in
|
||||
"${SYSTEM_DEBIAN}")
|
||||
## 处理 GPG 密钥
|
||||
@@ -1277,7 +1276,7 @@ function install_docker_engine() {
|
||||
function install_main() {
|
||||
local target_docker_version
|
||||
local pkgs=""
|
||||
local commands=()
|
||||
local -a commands=()
|
||||
if [[ "${INSTALL_LATESTED_DOCKER}" == "true" ]]; then
|
||||
pkgs="docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin"
|
||||
else
|
||||
@@ -1295,7 +1294,7 @@ function install_docker_engine() {
|
||||
target_docker_version="${DESIGNATED_DOCKER_VERSION}"
|
||||
else
|
||||
if [[ "${CAN_USE_ADVANCED_INTERACTIVE_SELECTION}" == "true" ]]; then
|
||||
local version_list=(
|
||||
local -a version_list=(
|
||||
$(cat $File_DockerVersionTmp | sort -t '.' -k1,1nr -k2,2nr -k3,3nr | tr '\n' ' ' | sed 's/ $//')
|
||||
)
|
||||
local mirror_list_name="version_list"
|
||||
@@ -1526,7 +1525,7 @@ function only_change_docker_registry_mirror() {
|
||||
if ! command_exists jq; then
|
||||
## 更新软件源
|
||||
local package_manager
|
||||
local commands=()
|
||||
local -a commands=()
|
||||
case "${SYSTEM_FACTIONS}" in
|
||||
"${SYSTEM_DEBIAN}")
|
||||
package_manager="apt-get"
|
||||
@@ -1582,7 +1581,6 @@ function only_change_docker_registry_mirror() {
|
||||
|
||||
function handleRegistryMirrorsValue() {
|
||||
local content="$1"
|
||||
local delimiter=","
|
||||
local result=""
|
||||
content="$(echo "${content}" | sed 's| ||g')"
|
||||
local -a items=(${content//,/ })
|
||||
@@ -1669,8 +1667,8 @@ function get_package_manager() {
|
||||
|
||||
function interactive_select_list() {
|
||||
_SELECT_RESULT=""
|
||||
eval "local __values=(\"\${${1}[@]}\")"
|
||||
local __labels=()
|
||||
eval "local -a __values=(\"\${${1}[@]}\")"
|
||||
local -a __labels=()
|
||||
local message="${2}"
|
||||
local selected=0
|
||||
local start=0
|
||||
@@ -1904,7 +1902,7 @@ function animate_exec() {
|
||||
exit 130
|
||||
}
|
||||
function make_temp_file() {
|
||||
local temp_dirs=("." "/tmp")
|
||||
local -a temp_dirs=("." "/tmp")
|
||||
local tmp_file=""
|
||||
for dir in "${temp_dirs[@]}"; do
|
||||
[[ ! -d "${dir}" || ! -w "${dir}" ]] && continue
|
||||
|
||||
Reference in New Issue
Block a user