parent
39e464c754
commit
43b69c62c9
|
|
@ -98,41 +98,41 @@ pre_check() {
|
|||
######################################
|
||||
# 安装必要依赖(屏蔽冗余日志,仅捕错)
|
||||
install_dependencies() {
|
||||
print_step "正在安装依赖工具"
|
||||
log "INFO" "正在安装依赖工具"
|
||||
# apt-get 静默执行,日志重定向到/dev/null,仅保留错误输出
|
||||
if ! apt-get update -qq >/dev/null 2>&1; then
|
||||
print_error "更新软件源失败"
|
||||
log "ERROR" "更新软件源失败"
|
||||
exit 1
|
||||
fi
|
||||
if ! apt-get install -qq -y ca-certificates curl gnupg lsb-release >/dev/null 2>&1; then
|
||||
print_error "安装依赖(ca-certificates/curl等)失败"
|
||||
log "ERROR" "安装依赖(ca-certificates/curl等)失败"
|
||||
exit 1
|
||||
fi
|
||||
print_success "依赖工具安装完成"
|
||||
log "INFO" "依赖工具安装完成"
|
||||
}
|
||||
|
||||
# 添加Docker GPG密钥(自动覆盖,屏蔽日志)
|
||||
add_gpg_key() {
|
||||
print_step "正在添加Docker GPG密钥"
|
||||
log "INFO" "正在添加Docker GPG密钥"
|
||||
mkdir -p /etc/apt/keyrings
|
||||
# curl+gpg 静默执行,自动覆盖现有文件
|
||||
if ! curl -fsSL https://download.docker.com/linux/ubuntu/gpg | gpg --dearmor --yes -o /etc/apt/keyrings/docker.gpg >/dev/null 2>&1; then
|
||||
print_error "添加GPG密钥失败(网络或密钥地址异常)"
|
||||
log "ERROR" "添加GPG密钥失败(网络或密钥地址异常)"
|
||||
exit 1
|
||||
fi
|
||||
print_success "GPG密钥添加完成"
|
||||
log "INFO" s "GPG密钥添加完成"
|
||||
}
|
||||
|
||||
# 添加Docker源(屏蔽日志)
|
||||
add_docker_repo() {
|
||||
print_step "正在配置Docker软件源"
|
||||
log "INFO" "正在配置Docker软件源"
|
||||
# 写入源配置,更新源时静默执行
|
||||
echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | tee /etc/apt/sources.list.d/docker.list >/dev/null 2>&1
|
||||
if ! apt-get update -qq >/dev/null 2>&1; then
|
||||
print_error "更新Docker软件源失败"
|
||||
log "ERROR" "更新Docker软件源失败"
|
||||
exit 1
|
||||
fi
|
||||
print_success "Docker软件源配置完成"
|
||||
log "INFO" "Docker软件源配置完成"
|
||||
}
|
||||
|
||||
#######################################
|
||||
|
|
|
|||
Loading…
Reference in New Issue