forked from NodeSeekDev/NodeScriptKit
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
74 lines (60 loc) · 1.98 KB
/
install.sh
File metadata and controls
74 lines (60 loc) · 1.98 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#!/bin/bash
# 功能: NodeScriptKit 安装和更新脚本
goos=$(uname -s | tr '[:upper:]' '[:lower:]')
goarch=$(uname -m)
echo "Current OS: $goos"
echo "Current Architecture: $goarch"
# 判断操作系统是否支持
case "$goos" in
darwin|linux|freebsd)
ext=""
;;
*)
echo "Unsupported OS: $goos"
exit 1
;;
esac
# 映射架构到标准格式
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##*/}
BIN_FILENAME="nskCore-$goos-$arch$ext"
BIN_URL="https://github.com/NodeSeekDev/NskCore/releases/download/$BIN_VERSION/$BIN_FILENAME"
curl -Lso /usr/bin/nskCore $BIN_URL
chmod u+x /usr/bin/nskCore
if tar --version 2>&1 | grep -qi 'busybox'; then
if command -v apk >/dev/null 2>&1; then
apk add --no-cache tar
fi
fi
MENU_URL="$(curl -Ls -o /dev/null -w %{url_effective} https://github.com/NodeSeekDev/NodeScriptKit/releases/latest)"
MENU_VERSION="${MENU_URL##*/}"
mkdir -p /etc/nsk/modules.d/default
mkdir -p /etc/nsk/modules.d/extend
cd /tmp
temp_dir=$(mktemp -d)
curl -sLo - $temp_download_file "https://github.com/NodeSeekDev/NodeScriptKit/archive/refs/tags/$MENU_VERSION.tar.gz" | \
tar -xzv -C $temp_dir
[ -f "/etc/nsk/config.toml" ] || cp $temp_dir/*/menu.toml /etc/nsk/config.toml
rm -rf /etc/nsk/modules.d/default/* # Remove old scripts to prevent conflicts
cp $temp_dir/*/modules.d/* /etc/nsk/modules.d/default/
echo $MENU_VERSION > /etc/nsk/version
cp $temp_dir/*/nsk.sh /usr/bin/nsk
chmod u+x /usr/bin/nsk
[ -f "/usr/bin/n" ] || ln -s /usr/bin/nsk /usr/bin/n
rm -rf $temp_dir
echo -e "\e[1;32mnsk脚本安装成功啦,可以输入n或者nsk命令唤出菜单\e[0m"