From 0b888f873462b31992a98b54ab221064aa4c8c7a Mon Sep 17 00:00:00 2001 From: mhsanaei Date: Thu, 25 Sep 2025 14:34:12 +0200 Subject: [PATCH] Add IPv4 for wget in install --- install.sh | 40 ++++++++++++++++++++++++++++++++++------ 1 file changed, 34 insertions(+), 6 deletions(-) diff --git a/install.sh b/install.sh index 2c1a6822..dfd80975 100644 --- a/install.sh +++ b/install.sh @@ -149,14 +149,22 @@ install_x-ui() { if [ $# == 0 ]; then tag_version=$(curl -Ls "https://api.github.com/repos/MHSanaei/3x-ui/releases/latest" | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/') if [[ ! -n "$tag_version" ]]; then - echo -e "${red}Failed to fetch x-ui version, it may be due to GitHub API restrictions, please try it later${plain}" - exit 1 + echo -e "${yellow}Trying to fetch version with IPv4...${plain}" + tag_version=$(curl -4 -Ls "https://api.github.com/repos/MHSanaei/3x-ui/releases/latest" | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/') + if [[ ! -n "$tag_version" ]]; then + echo -e "${red}Failed to fetch x-ui version, it may be due to GitHub API restrictions, please try it later${plain}" + exit 1 + fi fi echo -e "Got x-ui latest version: ${tag_version}, beginning the installation..." wget -N -O /usr/local/x-ui-linux-$(arch).tar.gz https://github.com/MHSanaei/3x-ui/releases/download/${tag_version}/x-ui-linux-$(arch).tar.gz if [[ $? -ne 0 ]]; then - echo -e "${red}Downloading x-ui failed, please be sure that your server can access GitHub ${plain}" - exit 1 + echo -e "${yellow}Trying to download with IPv4...${plain}" + wget -N -O /usr/local/x-ui-linux-$(arch).tar.gz --inet4-only https://github.com/MHSanaei/3x-ui/releases/download/${tag_version}/x-ui-linux-$(arch).tar.gz + if [[ $? -ne 0 ]]; then + echo -e "${red}Downloading x-ui failed, please be sure that your server can access GitHub ${plain}" + exit 1 + fi fi else tag_version=$1 @@ -172,11 +180,23 @@ install_x-ui() { echo -e "Beginning to install x-ui $1" wget -N -O /usr/local/x-ui-linux-$(arch).tar.gz ${url} if [[ $? -ne 0 ]]; then - echo -e "${red}Download x-ui $1 failed, please check if the version exists ${plain}" - exit 1 + echo -e "${yellow}Trying to download with IPv4...${plain}" + wget -N -O /usr/local/x-ui-linux-$(arch).tar.gz --inet4-only ${url} + if [[ $? -ne 0 ]]; then + echo -e "${red}Download x-ui $1 failed, please check if the version exists ${plain}" + exit 1 + fi fi fi wget -O /usr/bin/x-ui-temp https://raw.githubusercontent.com/MHSanaei/3x-ui/main/x-ui.sh + if [[ $? -ne 0 ]]; then + echo -e "${yellow}Trying to download x-ui.sh with IPv4...${plain}" + wget -O /usr/bin/x-ui-temp --inet4-only https://raw.githubusercontent.com/MHSanaei/3x-ui/main/x-ui.sh + if [[ $? -ne 0 ]]; then + echo -e "${red}Failed to download x-ui.sh${plain}" + exit 1 + fi + fi # Stop x-ui service and remove old resources if [[ -e /usr/local/x-ui/ ]]; then @@ -210,6 +230,14 @@ install_x-ui() { if [[ $release == "alpine" ]]; then wget -O /etc/init.d/x-ui https://raw.githubusercontent.com/MHSanaei/3x-ui/main/x-ui.rc + if [[ $? -ne 0 ]]; then + echo -e "${yellow}Trying to download x-ui.rc with IPv4...${plain}" + wget -O /etc/init.d/x-ui --inet4-only https://raw.githubusercontent.com/MHSanaei/3x-ui/main/x-ui.rc + if [[ $? -ne 0 ]]; then + echo -e "${red}Failed to download x-ui.rc${plain}" + exit 1 + fi + fi chmod +x /etc/init.d/x-ui rc-update add x-ui rc-service x-ui start