From 74e0a8bf5c4e814756da6392c697b95de9f7c839 Mon Sep 17 00:00:00 2001 From: mini2024 Date: Tue, 11 Mar 2025 22:21:48 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E7=B3=BB=E7=BB=9F=E7=B1=BB?= =?UTF-8?q?=E5=9E=8B=E6=A3=80=E6=B5=8B=E9=80=BB=E8=BE=91=EF=BC=8C=E6=94=B9?= =?UTF-8?q?=E8=BF=9B=20Debian=20=E5=92=8C=20Alpine=20=E7=B3=BB=E7=BB=9F?= =?UTF-8?q?=E8=AF=86=E5=88=AB=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 1.sh | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/1.sh b/1.sh index b5e6759..0e1ef4f 100644 --- a/1.sh +++ b/1.sh @@ -9,23 +9,21 @@ set -e # 遇到错误即退出 trap 'echo "Error on line $LINENO"' ERR # 先检查是 Debian 还是 Alpine -if [ -f /etc/os-release ]; then - . /etc/os-release - OS=$NAME - VERSION=$VERSION_ID +if [ -f /etc/debian_version ]; then + SYSTEM_TYPE="debian" +elif [ -f /etc/alpine-release ]; then + SYSTEM_TYPE="alpine" else - echo "无法检测系统类型,请确保系统支持 /etc/os-release" + echo "不支持的系统类型" exit 1 fi # 检查系统类型 -if [[ $OS == *"Debian"* ]]; then - echo "检测到 Debian 系统,版本: $VERSION" - SYSTEM_TYPE="debian" -elif [[ $OS == *"Alpine"* ]]; then - echo "检测到 Alpine 系统,版本: $VERSION" - SYSTEM_TYPE="alpine" +if [[ $SYSTEM_TYPE == *"Debian"* ]]; then + echo "检测到 Debian 系统" +elif [[ $SYSTEM_TYPE == *"Alpine"* ]]; then + echo "检测到 Alpine 系统" else - echo "不支持的系统类型: $OS" + echo "不支持的系统类型: $SYSTEM_TYPE" exit 1 fi