From 34d2591e50911ac57aa03b524bf5f62241eb1b1b Mon Sep 17 00:00:00 2001 From: Intervence <16687477+Intervence@users.noreply.github.com> Date: Wed, 29 Jul 2026 00:11:27 +0300 Subject: [PATCH] fix (install.sh): use realpath instead of script name (#6075) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix (install.sh): use realpath instead of script name ###Description: During arch() sctipt tries to delete itself in case no compatible arch found. This may lead to unexpected file deletion if executed outside root dir; also cur_dir is declared but doesn't seem to be used anywhere ###Way to reproduce: ```bash cd "/some/other_dir_with_install_sh" /3x-ui/project/dir/install.sh ``` * fix(install): quote the script path before the self-delete realpath was handed an unquoted $0, so a script living under a path that contains spaces was split into several arguments: realpath printed a partial path plus an error, and rm -f then targeted a name matching nothing at all. The unsupported-arch branch silently kept the script it means to remove — the very case the surrounding fix exists for. --- install.sh | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/install.sh b/install.sh index cced76048..38878873c 100644 --- a/install.sh +++ b/install.sh @@ -6,8 +6,6 @@ blue='\033[0;34m' yellow='\033[0;33m' plain='\033[0m' -cur_dir=$(pwd) - xui_folder="${XUI_MAIN_FOLDER:=/usr/local/x-ui}" xui_service="${XUI_SERVICE:=/etc/systemd/system}" @@ -36,7 +34,7 @@ arch() { armv6* | armv6) echo 'armv6' ;; armv5* | armv5) echo 'armv5' ;; s390x) echo 's390x' ;; - *) echo -e "${green}Unsupported CPU architecture! ${plain}" && rm -f install.sh && exit 1 ;; + *) echo -e "${green}Unsupported CPU architecture! ${plain}" && rm -f "$(realpath "$0")" && exit 1 ;; esac }