From 71e992a31cfa800a78776290be517c641db334b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=98=9F=E5=85=89-k?= <36470587+kxgx@users.noreply.github.com> Date: Wed, 8 Jan 2025 22:33:20 +0800 Subject: [PATCH] Update install.sh --- bin/install.sh | 59 ++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 57 insertions(+), 2 deletions(-) diff --git a/bin/install.sh b/bin/install.sh index 8e96b54..f89e44d 100644 --- a/bin/install.sh +++ b/bin/install.sh @@ -1,6 +1,19 @@ #!/bin/bash -cat <<'EOF' > /etc/apt/sources.list +# 检测是否是Debian系统 +if [ -f /etc/debian_version ]; then + # 读取Debian版本号 + debian_version=$(cat /etc/debian_version) + + echo "Detected Debian system with version: $debian_version" + + # 根据版本号执行不同的操作 + case $debian_version in + 11*) + echo "Debian 11 (Bullseye)" + # 在这里执行针对Debian 11的操作 +sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak +sudo cat <<'EOF' > /etc/apt/sources.list # 默认注释了源码镜像以提高 apt update 速度,如有需要可自行取消注释 deb https://mirrors.cernet.edu.cn/debian/ bullseye main contrib non-free # deb-src https://mirrors.cernet.edu.cn/debian/ bullseye main contrib non-free @@ -18,7 +31,6 @@ deb https://mirrors.cernet.edu.cn/debian-security bullseye-security main contrib # deb https://security.debian.org/debian-security bullseye-security main contrib non-free # # deb-src https://security.debian.org/debian-security bullseye-security main contrib non-free EOF - sudo apt-get update sudo apt install -y git sudo apt-get install -y netcat* @@ -27,3 +39,46 @@ sudo apt-get install -y python3-pil sudo apt-get install -y python3-numpy sudo apt install -y python3-gpiozero sudo pip3 install spidev borax pillow requests --break-system-packages + ;; + 12*) + echo "Debian 12 (Bookworm)" + # 在这里执行针对Debian 12的操作 +sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak +sudo cat <<'EOF' > /etc/apt/sources.list +# 默认注释了源码镜像以提高 apt update 速度,如有需要可自行取消注释 +deb https://mirrors.cernet.edu.cn/debian/ bookworm main contrib non-free non-free-firmware +# deb-src https://mirrors.cernet.edu.cn/debian/ bookworm main contrib non-free non-free-firmware + +deb https://mirrors.cernet.edu.cn/debian/ bookworm-updates main contrib non-free non-free-firmware +# deb-src https://mirrors.cernet.edu.cn/debian/ bookworm-updates main contrib non-free non-free-firmware + +deb https://mirrors.cernet.edu.cn/debian/ bookworm-backports main contrib non-free non-free-firmware +# deb-src https://mirrors.cernet.edu.cn/debian/ bookworm-backports main contrib non-free non-free-firmware + +# 以下安全更新软件源包含了官方源与镜像站配置,如有需要可自行修改注释切换 +deb https://mirrors.cernet.edu.cn/debian-security bookworm-security main contrib non-free non-free-firmware +# deb-src https://mirrors.cernet.edu.cn/debian-security bookworm-security main contrib non-free non-free-firmware + +# deb https://security.debian.org/debian-security bookworm-security main contrib non-free non-free-firmware +# # deb-src https://security.debian.org/debian-security bookworm-security main contrib non-free non-free-firmware +EOF +sudo apt-get update +sudo apt install -y git +sudo apt-get install -y netcat* +sudo apt-get install -y python3-pip +sudo apt-get install -y python3-pil +sudo apt-get install -y python3-numpy +sudo apt install -y python3-gpiozero +sudo pip3 install spidev borax pillow requests --break-system-packages + ;; + *) + echo "Unknown Debian version" + # 在这里处理未知版本的情况 + exit 0 + ;; + esac +else + echo "This is not a Debian system." + # 在这里处理非Debian系统的情况 + exit 0 +fi