From 04d85af40e9583cf52932350ab3976f392ea9fb6 Mon Sep 17 00:00:00 2001 From: MHSanaei Date: Mon, 24 Apr 2023 16:55:29 +0330 Subject: [PATCH] undo changes --- x-ui.sh | 61 +++++++++++---------------------------------------------- 1 file changed, 11 insertions(+), 50 deletions(-) diff --git a/x-ui.sh b/x-ui.sh index bde6eefb..da6d11fc 100644 --- a/x-ui.sh +++ b/x-ui.sh @@ -56,14 +56,6 @@ elif [[ "${release}" == "debian" ]]; then fi fi -arch3xui() { - case "$(uname -m)" in - x86_64 | x64 | amd64 ) echo 'amd64' ;; - armv8 | arm64 | aarch64 ) echo 'arm64' ;; - * ) echo -e "${red} Unsupported CPU architecture!${plain}" && exit 1 ;; - esac -} - confirm() { if [[ $# > 1 ]]; then echo && read -p "$1 [Default $2]: " temp @@ -106,49 +98,18 @@ install() { } update() { - read -rp "This function will update the X-UI panel to the latest version. Data will not be lost. Whether to continues? [Y/N]: " yn - if [[ $yn =~ "Y"|"y" ]]; then - systemctl stop x-ui - if [[ -e /usr/local/x-ui/ ]]; then - cd - rm -rf /usr/local/x-ui/ + confirm "This function will forcefully reinstall the latest version, and the data will not be lost. Do you want to continue?" "n" + if [[ $? != 0 ]]; then + LOGE "Cancelled" + if [[ $# == 0 ]]; then + before_show_menu fi - - last_version=$(curl -Ls "https://api.github.com/repos/MHSanaei/3x-ui/releases/latest" | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/') || last_version=$(curl -sm8 https://raw.githubusercontent.com/MHSanaei/3x-ui/main/config/version) - if [[ -z "$last_version" ]]; then - echo -e "${red}Detecting the X-UI version failed, please make sure your server can connect to the GitHub API ${plain}" - exit 1 - fi - - echo -e "${yellow}The latest version of X-UI is: ${last_version}, starting update...${plain}" - wget -N --no-check-certificate -O /usr/local/x-ui-linux-$(arch3xui).tar.gz https://github.com/MHSanaei/3x-ui/releases/download/${last_version}/x-ui-linux-$(arch3xui).tar.gz - if [[ $? -ne 0 ]]; then - echo -e "${red}Download the X-UI failure, please make sure your server can connect and download the files from github ${plain}" - exit 1 - fi - - cd /usr/local/ - tar zxvf x-ui-linux-$(arch3xui).tar.gz - rm -f x-ui-linux-$(arch3xui).tar.gz - - cd x-ui - chmod +x x-ui bin/xray-linux-$(arch3xui) - cp -f x-ui.service /etc/systemd/system/ - - wget -N --no-check-certificate https://raw.githubusercontent.com/MHSanaei/3x-ui/main/x-ui.sh -O /usr/bin/x-ui - chmod +x /usr/local/x-ui/x-ui.sh - chmod +x /usr/bin/x-ui - - systemctl daemon-reload - systemctl enable x-ui >/dev/null 2>&1 - systemctl start x-ui - systemctl restart x-ui - - echo -e "${green}The update is completed, and the X-UI panel has been automatically restarted ${plain}" - exit 1 - else - echo -e "${red}The upgrade X-UI panel has been canceled! ${plain}" - exit 1 + return 0 + fi + bash <(curl -Ls https://raw.githubusercontent.com/MHSanaei/3x-ui/main/install.sh) + if [[ $? == 0 ]]; then + LOGI "Update is complete, Panel has automatically restarted " + exit 0 fi }