From f2605a550f734e9ae51bdf21fb486097d3dd9c2a Mon Sep 17 00:00:00 2001 From: Alireza Ahmadi Date: Mon, 6 Jan 2025 00:10:17 +0100 Subject: [PATCH] update scripts --- install.sh | 27 ++++++++++++++---- s-ui.sh | 80 +++++++++++++++++++----------------------------------- 2 files changed, 49 insertions(+), 58 deletions(-) diff --git a/install.sh b/install.sh index d4d4b89..c74334a 100755 --- a/install.sh +++ b/install.sh @@ -176,6 +176,21 @@ config_after_install() { fi } +prepare_services() { + if [[ -f "/etc/systemd/system/sing-box.service" ]]; then + echo -e "${yellow}Stopping sing-box service... ${plain}" + systemctl stop sing-box + rm -f /usr/local/s-ui/bin/sing-box /usr/local/s-ui/bin/runSingbox.sh /usr/local/s-ui/bin/signal + fi + if [[ -e "/usr/local/s-ui/bin" ]]; then + echo -e "###############################################################" + echo -e "${green}/usr/local/s-ui/bin${red} directory exists yet!" + echo -e "Please check the content and delete it manually after migration ${plain}" + echo -e "###############################################################" + fi + systemctl daemon-reload +} + install_s-ui() { cd /tmp/ @@ -204,26 +219,26 @@ install_s-ui() { if [[ -e /usr/local/s-ui/ ]]; then systemctl stop s-ui - systemctl stop sing-box fi tar zxvf s-ui-linux-$(arch).tar.gz rm s-ui-linux-$(arch).tar.gz -f - wget --no-check-certificate -O /usr/bin/s-ui https://raw.githubusercontent.com/alireza0/s-ui/main/s-ui.sh - - chmod +x s-ui/sui s-ui/bin/sing-box s-ui/bin/runSingbox.sh /usr/bin/s-ui + chmod +x s-ui/sui /s-ui/s-ui.sh + cp s-ui/s-ui.sh /usr/bin/s-ui cp -rf s-ui /usr/local/ cp -f s-ui/*.service /etc/systemd/system/ rm -rf s-ui config_after_install + prepare_services - systemctl daemon-reload systemctl enable s-ui --now - systemctl enable sing-box --now echo -e "${green}s-ui v${last_version}${plain} installation finished, it is up and running now..." + echo -e "You may access the Panel with following URL(s):${yellow}" + /usr/local/s-ui/sui uri + echo -e "${plain}" echo -e "" s-ui help } diff --git a/s-ui.sh b/s-ui.sh index 7dfdab2..f10e105 100644 --- a/s-ui.sh +++ b/s-ui.sh @@ -172,7 +172,7 @@ custom_version() { } uninstall() { - confirm "Are you sure you want to uninstall the panel? sing-box will also uninstalled!" "n" + confirm "Are you sure you want to uninstall the panel?" "n" if [[ $? != 0 ]]; then if [[ $# == 0 ]]; then show_menu @@ -181,10 +181,7 @@ uninstall() { fi systemctl stop s-ui systemctl disable s-ui - systemctl stop sing-box - systemctl disable sing-box rm /etc/systemd/system/s-ui.service -f - rm /etc/systemd/system/sing-box.service -f systemctl daemon-reload systemctl reset-failed rm /etc/s-ui/ -rf @@ -257,6 +254,16 @@ view_setting() { before_show_menu } +view_uri() { + info=$(/usr/local/s-ui/sui uri) + if [[ $? != 0 ]]; then + LOGE "Get current uri error" + before_show_menu + fi + LOGI "You may access the Panel with following URL(s):" + echo -e "${yellow}${info}${reset}" +} + start() { check_status $1 if [[ $? == 0 ]]; then @@ -315,7 +322,6 @@ restart() { status() { systemctl status s-ui -l - systemctl status sing-box -l if [[ $# == 0 ]]; then before_show_menu fi @@ -763,10 +769,10 @@ show_usage() { echo -e "------------------------------------------" echo -e "SUBCOMMANDS:" echo -e "s-ui - Admin Management Script" - echo -e "s-ui start - Start s-ui and sing-box" - echo -e "s-ui stop - Stop s-ui and sing-box" - echo -e "s-ui restart - Restart s-ui and sing-box" - echo -e "s-ui status - Current Status of s-ui and sing-box" + echo -e "s-ui start - Start s-ui" + echo -e "s-ui stop - Stop s-ui" + echo -e "s-ui restart - Restart s-ui" + echo -e "s-ui status - Current Status of s-ui" echo -e "s-ui enable - Enable Autostart on OS Startup" echo -e "s-ui disable - Disable Autostart on OS Startup" echo -e "s-ui log - Check s-ui Logs" @@ -804,22 +810,13 @@ show_menu() { ${green}16.${plain} S-UI Enable Autostart ${green}17.${plain} S-UI Disable Autostart ———————————————————————————————— - ${green}18.${plain} Sing-Box Start - ${green}19.${plain} Sing-Box Stop - ${green}20.${plain} Sing-Box Restart - ${green}21.${plain} Sing-Box Check State - ${green}22.${plain} Sing-Box Check Logs - ${green}23.${plain} Sing-Box Enable Autostart - ${green}24.${plain} Sing-Box Disable Autostart -———————————————————————————————— - ${green}25.${plain} Enable or Disable BBR - ${green}26.${plain} SSL Certificate Management - ${green}27.${plain} Cloudflare SSL Certificate + ${green}18.${plain} Enable or Disable BBR + ${green}19.${plain} SSL Certificate Management + ${green}20.${plain} Cloudflare SSL Certificate ———————————————————————————————— " show_status s-ui - show_status sing-box - echo && read -p "Please enter your selection [0-27]: " num + echo && read -p "Please enter your selection [0-20]: " num case "${num}" in 0) @@ -853,7 +850,7 @@ show_menu() { check_install && set_setting ;; 10) - check_install && view_setting + check_install && view_setting && view_uri ;; 11) check_install && start s-ui @@ -877,37 +874,16 @@ show_menu() { check_install && disable s-ui ;; 18) - check_install && start sing-box - ;; - 19) - check_install && stop sing-box - ;; - 20) - check_install && restart sing-box - ;; - 21) - check_install && status sing-box - ;; - 22) - check_install && show_log sing-box - ;; - 23) - check_install && enable sing-box - ;; - 24) - check_install && disable sing-box - ;; - 25) bbr_menu ;; - 26) + 19) ssl_cert_issue_main ;; - 27) + 20) ssl_cert_issue_CF ;; *) - LOGE "Please enter the correct number [0-27]" + LOGE "Please enter the correct number [0-20]" ;; esac } @@ -915,22 +891,22 @@ show_menu() { if [[ $# > 0 ]]; then case $1 in "start") - check_install 0 && start s-ui 0 && start sing-box 0 + check_install 0 && start s-ui 0 ;; "stop") - check_install 0 && stop s-ui 0 && stop sing-box 0 + check_install 0 && stop s-ui 0 ;; "restart") - check_install 0 && restart s-ui 0 && restart sing-box 0 + check_install 0 && restart s-ui 0 ;; "status") check_install 0 && status 0 ;; "enable") - check_install 0 && enable s-ui 0 && enable sing-box 0 + check_install 0 && enable s-ui 0 ;; "disable") - check_install 0 && disable s-ui 0 && disable sing-box 0 + check_install 0 && disable s-ui 0 ;; "log") check_install 0 && show_log s-ui 0