Skip to content

Commit

Permalink
undo changes
Browse files Browse the repository at this point in the history
  • Loading branch information
MHSanaei committed Apr 24, 2023
1 parent fca882e commit 04d85af
Showing 1 changed file with 11 additions and 50 deletions.
61 changes: 11 additions & 50 deletions x-ui.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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/
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
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

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
}

Expand Down

0 comments on commit 04d85af

Please sign in to comment.