From e62927a45c5188379381f73eee1b8bfeaee715dd Mon Sep 17 00:00:00 2001 From: link Date: Fri, 11 Jul 2025 20:36:49 +0800 Subject: [PATCH] refactor(install): improve OS and architecture detection - Replace if-else statements with case statements for better readability - Add support for more architectures (i686, aarch64, ARM64) --- install.sh | 44 ++++++++++++++++++++++++++------------------ 1 file changed, 26 insertions(+), 18 deletions(-) diff --git a/install.sh b/install.sh index 186962b..3f4efd7 100644 --- a/install.sh +++ b/install.sh @@ -7,25 +7,33 @@ goarch=$(uname -m) echo "Current OS: $goos" echo "Current Architecture: $goarch" -if [ "$goos" == "darwin" ]; then - ext="" -elif [ "$goos" == "linux" ] || [ "$goos" == "freebsd" ]; then - ext="" -else - echo "Unsupported OS: $goos" - exit 1 -fi +# 判断操作系统是否支持 +case "$goos" in + darwin|linux|freebsd) + ext="" + ;; + *) + echo "Unsupported OS: $goos" + exit 1 + ;; +esac -if [ "$goarch" == "x86_64" ]; then - arch="amd64" -elif [ "$goarch" == "i386" ]; then - arch="386" -elif [ "$goarch" == "arm64" ]; then - arch="arm64" -else - echo "Unsupported Architecture: $goarch" - exit 1 -fi +# 映射架构到标准格式 +case "$goarch" in + x86_64|amd64) + arch="amd64" + ;; + i386|i686) + arch="386" + ;; + aarch64|arm64|ARM64) + arch="arm64" + ;; + *) + echo "Unsupported Architecture: $goarch" + exit 1 + ;; +esac BIN_VERSION="$(curl -Ls -o /dev/null -w %{url_effective} https://github.com/NodeSeekDev/NskCore/releases/latest)" BIN_VERSION=${BIN_VERSION##*/}