update scripts

This commit is contained in:
Alireza Ahmadi
2025-01-06 00:10:17 +01:00
parent e92cf56557
commit f2605a550f
2 changed files with 49 additions and 58 deletions
+21 -6
View File
@@ -176,6 +176,21 @@ config_after_install() {
fi 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() { install_s-ui() {
cd /tmp/ cd /tmp/
@@ -204,26 +219,26 @@ install_s-ui() {
if [[ -e /usr/local/s-ui/ ]]; then if [[ -e /usr/local/s-ui/ ]]; then
systemctl stop s-ui systemctl stop s-ui
systemctl stop sing-box
fi fi
tar zxvf s-ui-linux-$(arch).tar.gz tar zxvf s-ui-linux-$(arch).tar.gz
rm s-ui-linux-$(arch).tar.gz -f 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/s-ui.sh
cp s-ui/s-ui.sh /usr/bin/s-ui
chmod +x s-ui/sui s-ui/bin/sing-box s-ui/bin/runSingbox.sh /usr/bin/s-ui
cp -rf s-ui /usr/local/ cp -rf s-ui /usr/local/
cp -f s-ui/*.service /etc/systemd/system/ cp -f s-ui/*.service /etc/systemd/system/
rm -rf s-ui rm -rf s-ui
config_after_install config_after_install
prepare_services
systemctl daemon-reload
systemctl enable s-ui --now 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 "${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 "" echo -e ""
s-ui help s-ui help
} }
+28 -52
View File
@@ -172,7 +172,7 @@ custom_version() {
} }
uninstall() { 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
if [[ $# == 0 ]]; then if [[ $# == 0 ]]; then
show_menu show_menu
@@ -181,10 +181,7 @@ uninstall() {
fi fi
systemctl stop s-ui systemctl stop s-ui
systemctl disable 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/s-ui.service -f
rm /etc/systemd/system/sing-box.service -f
systemctl daemon-reload systemctl daemon-reload
systemctl reset-failed systemctl reset-failed
rm /etc/s-ui/ -rf rm /etc/s-ui/ -rf
@@ -257,6 +254,16 @@ view_setting() {
before_show_menu 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() { start() {
check_status $1 check_status $1
if [[ $? == 0 ]]; then if [[ $? == 0 ]]; then
@@ -315,7 +322,6 @@ restart() {
status() { status() {
systemctl status s-ui -l systemctl status s-ui -l
systemctl status sing-box -l
if [[ $# == 0 ]]; then if [[ $# == 0 ]]; then
before_show_menu before_show_menu
fi fi
@@ -763,10 +769,10 @@ show_usage() {
echo -e "------------------------------------------" echo -e "------------------------------------------"
echo -e "SUBCOMMANDS:" echo -e "SUBCOMMANDS:"
echo -e "s-ui - Admin Management Script" echo -e "s-ui - Admin Management Script"
echo -e "s-ui start - Start s-ui and sing-box" echo -e "s-ui start - Start s-ui"
echo -e "s-ui stop - Stop s-ui and sing-box" echo -e "s-ui stop - Stop s-ui"
echo -e "s-ui restart - Restart s-ui and sing-box" echo -e "s-ui restart - Restart s-ui"
echo -e "s-ui status - Current Status of s-ui and sing-box" echo -e "s-ui status - Current Status of s-ui"
echo -e "s-ui enable - Enable Autostart on OS Startup" echo -e "s-ui enable - Enable Autostart on OS Startup"
echo -e "s-ui disable - Disable Autostart on OS Startup" echo -e "s-ui disable - Disable Autostart on OS Startup"
echo -e "s-ui log - Check s-ui Logs" echo -e "s-ui log - Check s-ui Logs"
@@ -804,22 +810,13 @@ show_menu() {
${green}16.${plain} S-UI Enable Autostart ${green}16.${plain} S-UI Enable Autostart
${green}17.${plain} S-UI Disable Autostart ${green}17.${plain} S-UI Disable Autostart
———————————————————————————————— ————————————————————————————————
${green}18.${plain} Sing-Box Start ${green}18.${plain} Enable or Disable BBR
${green}19.${plain} Sing-Box Stop ${green}19.${plain} SSL Certificate Management
${green}20.${plain} Sing-Box Restart ${green}20.${plain} Cloudflare SSL Certificate
${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
———————————————————————————————— ————————————————————————————————
" "
show_status s-ui show_status s-ui
show_status sing-box echo && read -p "Please enter your selection [0-20]: " num
echo && read -p "Please enter your selection [0-27]: " num
case "${num}" in case "${num}" in
0) 0)
@@ -853,7 +850,7 @@ show_menu() {
check_install && set_setting check_install && set_setting
;; ;;
10) 10)
check_install && view_setting check_install && view_setting && view_uri
;; ;;
11) 11)
check_install && start s-ui check_install && start s-ui
@@ -877,37 +874,16 @@ show_menu() {
check_install && disable s-ui check_install && disable s-ui
;; ;;
18) 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 bbr_menu
;; ;;
26) 19)
ssl_cert_issue_main ssl_cert_issue_main
;; ;;
27) 20)
ssl_cert_issue_CF ssl_cert_issue_CF
;; ;;
*) *)
LOGE "Please enter the correct number [0-27]" LOGE "Please enter the correct number [0-20]"
;; ;;
esac esac
} }
@@ -915,22 +891,22 @@ show_menu() {
if [[ $# > 0 ]]; then if [[ $# > 0 ]]; then
case $1 in case $1 in
"start") "start")
check_install 0 && start s-ui 0 && start sing-box 0 check_install 0 && start s-ui 0
;; ;;
"stop") "stop")
check_install 0 && stop s-ui 0 && stop sing-box 0 check_install 0 && stop s-ui 0
;; ;;
"restart") "restart")
check_install 0 && restart s-ui 0 && restart sing-box 0 check_install 0 && restart s-ui 0
;; ;;
"status") "status")
check_install 0 && status 0 check_install 0 && status 0
;; ;;
"enable") "enable")
check_install 0 && enable s-ui 0 && enable sing-box 0 check_install 0 && enable s-ui 0
;; ;;
"disable") "disable")
check_install 0 && disable s-ui 0 && disable sing-box 0 check_install 0 && disable s-ui 0
;; ;;
"log") "log")
check_install 0 && show_log s-ui 0 check_install 0 && show_log s-ui 0