-
Notifications
You must be signed in to change notification settings - Fork 64
/
install.sh
64 lines (50 loc) · 1.68 KB
/
install.sh
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
#!/bin/bash
# 检查用户是否为root
if [ "$(id -u)" != "0" ]; then
echo -e "${RED}该脚本必须以root身份运行。${NC}"
exit 1
fi
# 创建一个程序目录
INSTALL_DIR="/usr/local/bin/sublink"
if [ ! -d "$INSTALL_DIR" ]; then
mkdir -p "$INSTALL_DIR"
fi
# 获取最新的发行版标签
latest_release=$(curl --silent "https://api.github.com/repos/gooaclok819/sublinkX/releases/latest" | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/')
echo "最新版本: $latest_release"
# 检测机器类型
machine_type=$(uname -m)
if [ "$machine_type" = "x86_64" ]; then
file_name="sublink_amd64"
elif [ "$machine_type" = "aarch64" ]; then
file_name="sublink_arm64"
else
echo "不支持的机器类型: $machine_type"
exit 1
fi
# 下载文件
cd ~
curl -LO "https://github.com/gooaclok819/sublinkX/releases/download/$latest_release/$file_name"
# 设置文件为可执行
chmod +x $file_name
# 移动文件到指定目录
mv $file_name "$INSTALL_DIR/sublink"
# 创建systemctl服务
echo "[Unit]
Description=Sublink Service
[Service]
ExecStart=$INSTALL_DIR/sublink
WorkingDirectory=$INSTALL_DIR
[Install]
WantedBy=multi-user.target" | tee /etc/systemd/system/sublink.service
# 重新加载systemd守护进程
systemctl daemon-reload
# 启动并启用服务
systemctl start sublink
systemctl enable sublink
echo "服务已启动并已设置为开机启动"
echo "默认账号admin密码123456 默认端口8000"
echo "安装完成已经启动输入sublink可以呼出菜单"
# 下载menu.sh并设置权限
curl -o /usr/bin/sublink -H "Cache-Control: no-cache" -H "Pragma: no-cache" https://raw.githubusercontent.com/gooaclok819/sublinkX/main/menu.sh
chmod 755 "/usr/bin/sublink"