From 54b4a998f54c487db570651d62852b699f55eb6b Mon Sep 17 00:00:00 2001 From: dichgrem Date: Mon, 10 Nov 2025 10:05:39 +0800 Subject: [PATCH] feat:on&off style:menu --- script/singbox.sh | 50 ++++++++++++++++++++++++++++++++--------------- 1 file changed, 34 insertions(+), 16 deletions(-) diff --git a/script/singbox.sh b/script/singbox.sh index d3a9cdf..a278a5a 100644 --- a/script/singbox.sh +++ b/script/singbox.sh @@ -165,6 +165,20 @@ status_singbox() { fi } +# 开启服务 +start_singbox() { + systemctl daemon-reload + systemctl enable sing-box.service 2>/dev/null || true + systemctl start sing-box.service 2>/dev/null || true +} + +# 停止服务 +stop_singbox(){ + systemctl stop sing-box.service 2>/dev/null || true + systemctl disable sing-box.service 2>/dev/null || true + systemctl daemon-reload +} + # 显示 VLESS Reality 链接 + 二维码 show_link() { printf "${CYAN}===== 您的 VLESS Reality 链接 =====${NC}\n" @@ -379,28 +393,32 @@ printf "${BLUE}当前 Sing-box 版本:${SINGBOX_VERSION}${NC}\n" while true; do printf "${BOLD}${BLUE}请选择操作:${NC}\n" - printf " ${YELLOW}1)${NC} 安装 Sing-box 并生成配置\n" + printf " ${YELLOW}1)${NC} 安装 Sing-box&&Reality\n" printf " ${YELLOW}2)${NC} 查看服务状态\n" - printf " ${YELLOW}3)${NC} 显示 VLESS Reality 链接\n" - printf " ${YELLOW}4)${NC} 卸载 Sing-box\n" - printf " ${YELLOW}5)${NC} 重新安装 Sing-box\n" - printf " ${YELLOW}6)${NC} 升级 Sing-box 二进制\n" - printf " ${YELLOW}7)${NC} 更换 SNI 域名\n" - printf " ${YELLOW}8)${NC} 设置 BBR 算法\n" - printf " ${YELLOW}9)${NC} 更新脚本自身\n" + printf " ${YELLOW}3)${NC} 开启服务\n" + printf " ${YELLOW}4)${NC} 停止服务\n" + printf " ${YELLOW}5)${NC} 卸载服务\n" + printf " ${YELLOW}6)${NC} 显示节点链接\n" + printf " ${YELLOW}7)${NC} 重新安装 Sing-box\n" + printf " ${YELLOW}8)${NC} 升级 Sing-box 二进制\n" + printf " ${YELLOW}9)${NC} 更换 SNI 域名\n" + printf " ${YELLOW}10)${NC} 设置 BBR 算法\n" + printf " ${YELLOW}11)${NC} 更新脚本自身\n" printf " ${YELLOW}0)${NC} 退出\n" - printf "${BOLD}输入数字 [1-8]: ${NC}" + printf "${BOLD}输入数字 [0-11]: ${NC}" read -r choice case "$choice" in 1) install_singbox ;; 2) status_singbox ;; - 3) show_link ;; - 4) uninstall_singbox ;; - 5) reinstall_singbox ;; - 6) update_singbox ;; - 7) change_sni ;; - 8) set_bbr ;; - 9) update_self ;; + 3) start_singbox ;; + 4) stop_singbox ;; + 5) uninstall_singbox ;; + 6) show_link ;; + 7) reinstall_singbox ;; + 8) update_singbox ;; + 9) change_sni ;; + 10) set_bbr ;; + 11) update_self ;; 0) printf "${GREEN}退出。${NC}\n" exit 0