From 39d74d03cfa1c0b3ef8b77655313ceeb48df9670 Mon Sep 17 00:00:00 2001 From: gooaclok819 Date: Tue, 22 Oct 2024 01:43:09 +0800 Subject: [PATCH] 1.6.1 --- install.sh | 69 +++++++++++------------------------------------------- 1 file changed, 14 insertions(+), 55 deletions(-) diff --git a/install.sh b/install.sh index 4f27746..208a739 100644 --- a/install.sh +++ b/install.sh @@ -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 @@ -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