Skip to content

Commit

Permalink
1.6.1
Browse files Browse the repository at this point in the history
  • Loading branch information
gooaclok819 committed Oct 21, 2024
1 parent 27c2f0b commit 39d74d0
Showing 1 changed file with 14 additions and 55 deletions.
69 changes: 14 additions & 55 deletions install.sh
Original file line number Diff line number Diff line change
@@ -1,57 +1,3 @@
#!/bin/bash
# 检查用户是否为root
if [ "$(id -u)" != "0" ]; then
echo -e "${RED}该脚本必须以root身份运行。${NC}"
exit 1
fi

#创建一个程序目录
cd /usr/local/bin
mkdir sublink
cd sublink

# 获取最新的发行版标签
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

# 下载文件
curl -LO "https://github.com/gooaclok819/sublinkX/releases/download/$latest_release/$file_name"

# 设置文件为可执行
chmod +x $file_name

# 移动文件到/usr/local/bin
sudo mv $file_name /usr/local/bin/sublink/sublink

# 创建systemctl服务
echo "[Unit]
Description=Sublink Service
[Service]
ExecStart=/usr/local/bin/sublink/sublink
WorkingDirectory=/usr/local/bin/sublink
[Install]
WantedBy=multi-user.target" | sudo tee /etc/systemd/system/sublink.service

# 启动并启用服务
sudo systemctl start sublink
sudo systemctl enable sublink
sudo systemctl daemon-reload
echo "服务已启动并已设置为开机启动"
echo "默认账号admin密码123456 端口8000"
echo "安装完成已经启动输入sudo sublink可以呼出菜单"

# 创建sublink_menu.sh脚本
echo '#!/bin/bash
Expand Down Expand Up @@ -104,4 +50,17 @@ while true; do
/usr/local/bin/sublink/sublink run --port "$new_port"
;;
7)
read -
read -p "请输入新的用户名 (默认:admin): " new_username
new_username=${new_username:-admin}
read -p "请输入新的密码 (默认:123456): " new_password
new_password=${new_password:-123456}
/usr/local/bin/sublink/sublink setting --username "$new_username" --password "$new_password"
;;
0)
exit 0
;;
*)
echo "无效的选项"
;;
esac
done' > sublink_menu.sh

0 comments on commit 39d74d0

Please sign in to comment.