From fbc4ba1ba0e8798b8621d402fd1643e478219b13 Mon Sep 17 00:00:00 2001 From: Jalal Saberi <130910450+jalalsaberi@users.noreply.github.com> Date: Tue, 13 Feb 2024 21:06:35 +0330 Subject: [PATCH] Update Uninstall Option (#942) after uninstall, script will delete itself and show Install & Upgrade command for installing again if user need that. --- x-ui.sh | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/x-ui.sh b/x-ui.sh index 0b09b4d0..e042ce85 100644 --- a/x-ui.sh +++ b/x-ui.sh @@ -133,8 +133,14 @@ custom_version() { eval $install_command } +# Function to handle the deletion of the script file +delete_script() { + rm "$0" # Remove the script file itself + exit 1 +} + uninstall() { - confirm "Are you sure you want to uninstall the panel? xray will also uninstalled!" "n" + confirm "Are you sure you want to uninstall the panel? xray will also uninstalled!" " n" if [[ $? != 0 ]]; then if [[ $# == 0 ]]; then show_menu @@ -148,14 +154,14 @@ uninstall() { systemctl reset-failed rm /etc/x-ui/ -rf rm /usr/local/x-ui/ -rf - + echo -e "\nUninstalled Successfully." echo "" - echo -e "Uninstalled Successfully,If you want to remove this script,then after exiting the script run ${green}rm /usr/bin/x-ui -f${plain} to delete it." + echo -e "If you need to install this panel again, you can use below command:" + echo -e "${green}bash <(curl -Ls https://raw.githubusercontent.com/alireza0/x-ui/master/install.sh)${plain}" echo "" - - if [[ $# == 0 ]]; then - before_show_menu - fi + # Trap the SIGTERM signal + trap delete_script SIGTERM + delete_script } reset_user() {