From 1a440773fdf10c3b8257df4a74f9b98fbc6e7e73 Mon Sep 17 00:00:00 2001 From: sushen339 Date: Mon, 20 Oct 2025 16:11:33 +0800 Subject: [PATCH] --- jdckup.sh => AutoUpdateJdCookie.sh | 31 +++++++++++++++++------------- README.md | 6 +++--- 2 files changed, 21 insertions(+), 16 deletions(-) rename jdckup.sh => AutoUpdateJdCookie.sh (92%) diff --git a/jdckup.sh b/AutoUpdateJdCookie.sh similarity index 92% rename from jdckup.sh rename to AutoUpdateJdCookie.sh index 3516fb6..9b5a585 100644 --- a/jdckup.sh +++ b/AutoUpdateJdCookie.sh @@ -1,16 +1,16 @@ #!/bin/bash -# jdckup.sh - 京东Cookie自动更新工具安装脚本 +# AutoUpdateJdCookie.sh - 京东Cookie自动更新工具安装脚本 set -euo pipefail # ============================================ # 配置变量 # ============================================ -readonly SCRIPT_NAME="JdCkup Installer" +readonly SCRIPT_NAME="AutoUpdateJdCookie Installer" readonly REPO_URL="https://github.com/icepage/AutoUpdateJdCookie.git" readonly PROJECT_DIR="AutoUpdateJdCookie" PYTHON_CMD="" -LOG_FILE="jdckup_install_$(date +%Y%m%d_%H%M%S).log" +LOG_FILE="AutoUpdateJdCookie_install_$(date +%Y%m%d_%H%M%S).log" readonly LOG_FILE readonly COLOR_RED='\033[0;31m' readonly COLOR_GREEN='\033[0;32m' @@ -73,8 +73,9 @@ command_exists() { } check_result() { - if [ $? -ne 0 ]; then - log_error "$1" + local exit_code=$? + if [ $exit_code -ne 0 ]; then + log_error "$1 失败" exit 1 fi } @@ -115,11 +116,16 @@ check_system_dependencies() { if [ "$EUID" -ne 0 ]; then log_warning "建议使用 root 权限运行此脚本" - read -p "是否继续?(y/n) " -n 1 -r - echo - if [[ ! $REPLY =~ ^[Yy]$ ]]; then - exit 1 - fi + read -r -p "是否继续?[y/N] " response + case "$response" in + [yY][eE][sS]|[yY]) + log_info "继续执行..." + ;; + *) + log_info "已取消安装" + exit 1 + ;; + esac fi log_success "系统依赖检查完成" @@ -138,9 +144,8 @@ install_system_packages() { echo "" run_with_progress "📦 安装系统包 (${base_packages[*]})" "apt install -y ${base_packages[*]}" "$LOG_FILE" - check_result "基础系统包安装失败" + check_result "基础系统包安装" - echo "" log_success "系统包安装完成" } @@ -239,7 +244,7 @@ generate_config() { echo "============================================" echo "" - python make_config.py 2>&1 | tee -a "../$LOG_FILE" + $PYTHON_CMD make_config.py 2>&1 | tee -a "../$LOG_FILE" if [ "${PIPESTATUS[0]}" -eq 0 ]; then echo "" diff --git a/README.md b/README.md index f564d55..8d02938 100644 --- a/README.md +++ b/README.md @@ -84,18 +84,18 @@ bash <(curl -fsSL "https://gh-proxy.net/https://raw.githubusercontent.com/sushen --- -### 6. jdckup.sh —— 京东 Cookie 自动更新工具安装 +### 6. AutoUpdateJdCookie.sh —— 京东 Cookie 自动更新工具安装 一键安装: ```bash -bash <(curl -fsSL "https://raw.githubusercontent.com/sushen339/tools/main/jdckup.sh") +bash <(curl -fsSL "https://raw.githubusercontent.com/sushen339/tools/main/AutoUpdateJdCookie.sh") ``` 代理加速: ```bash -bash <(curl -fsSL "https://gh-proxy.net/https://raw.githubusercontent.com/sushen339/tools/main/jdckup.sh") +bash <(curl -fsSL "https://gh-proxy.net/https://raw.githubusercontent.com/sushen339/tools/main/AutoUpdateJdCookie.sh") ``` > 建议所有脚本以 root 权限运行,详细参数和说明请阅读各脚本头部注释。