#!/bin/bash # 确保脚本以root用户运行 if [ "$EUID" -ne 0 ]; then echo "请以root用户运行或使用sudo" exit 1 fi # 默认语言环境 DEFAULT_LANG="en_US.UTF-8" # 检查是否使用中国镜像源 USE_CN_MIRROR=false # 控制调试输出 DEBUG=false # 解析命令行参数 while [ "$#" -gt 0 ]; do case "$1" in --cn) USE_CN_MIRROR=true ;; --debug) DEBUG=true ;; *) echo "未知参数: $1" exit 1 ;; esac shift done # 系统语言环境设置 echo "请选择系统语言环境:" echo "1. 中文 (zh_CN.UTF-8)" echo "2. 英文 (en_US.UTF-8)" read -p "输入选项 (1/2): " lang_choice case $lang_choice in 1) DEFAULT_LANG="zh_CN.UTF-8" ;; 2) DEFAULT_LANG="en_US.UTF-8" ;; *) echo "无效的选项,将使用默认系统语言环境: $DEFAULT_LANG" ;; esac export LANG=$DEFAULT_LANG export LC_ALL=$DEFAULT_LANG echo "$DEFAULT_LANG UTF-8" >> /etc/locale.gen dpkg-reconfigure --frontend=noninteractive locales locale-gen # Debian版本相关命令 DEBIAN_VERSION=$(cat /etc/debian_version) # 检查是否是Raspberry Pi系统 is_raspberry_pi() { if grep -q 'Raspberry Pi' /proc/cpuinfo; then return 0 else return 1 fi } # 定义链接变量 DEBIAN_MIRROR="http://deb.debian.org/debian/" DEBIAN_SECURITY_MIRROR="http://security.debian.org/" PI_SUGAR_POWER_MANAGER_URL="https://cdn.pisugar.com/release/pisugar-power-manager.sh" INK_SCREEN_CLOCK_REPO_URL="https://gitee.com/xingguangk/2.13-Ink-screen-clock.git" PIPY_MIRROR="https://pypi.org/simple" # 如果使用中国镜像源,则更新链接变量 if [ "$USE_CN_MIRROR" = true ]; then DEBIAN_MIRROR="https://mirrors.cernet.edu.cn/debian/" DEBIAN_SECURITY_MIRROR="https://mirrors.cernet.edu.cn/debian-security" PIPY_MIRROR="https://mirrors.tuna.tsinghua.edu.cn/pypi/web/simple" fi # 更新源列表函数 update_sources_list() { local version=$1 if [ "$DEBUG" = true ]; then echo "正在更新版本 $version 的源列表" fi sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak sudo bash -c "cat > /etc/apt/sources.list <