|
@@ -924,6 +924,13 @@ setup_fail2ban() {
|
|
|
return 0
|
|
return 0
|
|
|
fi
|
|
fi
|
|
|
|
|
|
|
|
|
|
+ # Scripts older than v3.4.0 have no setup-fail2ban and exit 0 from the
|
|
|
|
|
+ # usage banner, which would read as success here.
|
|
|
|
|
+ if ! grep -q '"setup-fail2ban")' /usr/bin/x-ui; then
|
|
|
|
|
+ echo -e "${yellow}This x-ui.sh predates 'x-ui setup-fail2ban'; skipping Fail2ban auto-setup.${plain}"
|
|
|
|
|
+ return 0
|
|
|
|
|
+ fi
|
|
|
|
|
+
|
|
|
echo -e "${green}Setting up Fail2ban for the IP Limit feature...${plain}"
|
|
echo -e "${green}Setting up Fail2ban for the IP Limit feature...${plain}"
|
|
|
if /usr/bin/x-ui setup-fail2ban; then
|
|
if /usr/bin/x-ui setup-fail2ban; then
|
|
|
echo -e "${green}Fail2ban setup complete.${plain}"
|
|
echo -e "${green}Fail2ban setup complete.${plain}"
|
|
@@ -967,6 +974,21 @@ _install_xui_service_unit() {
|
|
|
return 0
|
|
return 0
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+# Older tags predate some of these files (x-ui.rc arrived in v2.8.4). Serving
|
|
|
|
|
+# main's copy against an old binary is the mismatch this pinning exists to
|
|
|
|
|
+# prevent, so probe before the old install is removed and refuse the tag.
|
|
|
|
|
+require_repo_files() {
|
|
|
|
|
+ local ref="$1" name status
|
|
|
|
|
+ shift
|
|
|
|
|
+ [[ "${ref}" == "main" ]] && return 0
|
|
|
|
|
+ for name in "$@"; do
|
|
|
|
|
+ status=$(${curl_bin} -sIL --retry 3 --connect-timeout 15 -o /dev/null -w '%{http_code}' "https://raw.githubusercontent.com/MHSanaei/3x-ui/${ref}/${name}")
|
|
|
|
|
+ if [[ "${status}" != "200" ]]; then
|
|
|
|
|
+ _fail "ERROR: ${name} is not available for ${ref} (HTTP ${status}). Update to a release that ships it, or to 'dev-latest'. The current installation is untouched."
|
|
|
|
|
+ fi
|
|
|
|
|
+ done
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
update_x-ui() {
|
|
update_x-ui() {
|
|
|
cd ${xui_folder%/x-ui}/
|
|
cd ${xui_folder%/x-ui}/
|
|
|
|
|
|
|
@@ -993,6 +1015,17 @@ update_x-ui() {
|
|
|
fi
|
|
fi
|
|
|
fi
|
|
fi
|
|
|
echo -e "Got x-ui latest version: ${tag_version}, beginning the installation..."
|
|
echo -e "Got x-ui latest version: ${tag_version}, beginning the installation..."
|
|
|
|
|
+ # x-ui.sh, x-ui.rc and the unit files must come from the same release as
|
|
|
|
|
+ # the binary; only the rolling dev build tracks main.
|
|
|
|
|
+ script_ref="${tag_version}"
|
|
|
|
|
+ if [[ "${tag_version}" == "dev-latest" ]]; then
|
|
|
|
|
+ script_ref="main"
|
|
|
|
|
+ fi
|
|
|
|
|
+ # The unit files are only fetched when the release tarball lacks them, so
|
|
|
|
|
+ # they are checked at that point instead of here.
|
|
|
|
|
+ local required_files=("x-ui.sh")
|
|
|
|
|
+ [[ $release == "alpine" ]] && required_files+=("x-ui.rc")
|
|
|
|
|
+ require_repo_files "${script_ref}" "${required_files[@]}"
|
|
|
${curl_bin} -fLRo ${xui_folder}-linux-$(arch).tar.gz https://github.com/MHSanaei/3x-ui/releases/download/${tag_version}/x-ui-linux-$(arch).tar.gz 2> /dev/null
|
|
${curl_bin} -fLRo ${xui_folder}-linux-$(arch).tar.gz https://github.com/MHSanaei/3x-ui/releases/download/${tag_version}/x-ui-linux-$(arch).tar.gz 2> /dev/null
|
|
|
if [[ $? -ne 0 ]]; then
|
|
if [[ $? -ne 0 ]]; then
|
|
|
_fail "ERROR: Failed to download x-ui, please be sure that your server can access GitHub"
|
|
_fail "ERROR: Failed to download x-ui, please be sure that your server can access GitHub"
|
|
@@ -1086,7 +1119,7 @@ update_x-ui() {
|
|
|
echo -e "${green}Downloading and installing x-ui.sh script...${plain}"
|
|
echo -e "${green}Downloading and installing x-ui.sh script...${plain}"
|
|
|
local xui_script_temp="/usr/bin/x-ui-temp.$$"
|
|
local xui_script_temp="/usr/bin/x-ui-temp.$$"
|
|
|
rm -f "${xui_script_temp}"
|
|
rm -f "${xui_script_temp}"
|
|
|
- ${curl_bin} -fLRo "${xui_script_temp}" https://raw.githubusercontent.com/MHSanaei/3x-ui/main/x-ui.sh > /dev/null 2>&1
|
|
|
|
|
|
|
+ ${curl_bin} -fLRo "${xui_script_temp}" "https://raw.githubusercontent.com/MHSanaei/3x-ui/${script_ref}/x-ui.sh" > /dev/null 2>&1
|
|
|
if [[ $? -ne 0 ]]; then
|
|
if [[ $? -ne 0 ]]; then
|
|
|
rm -f "${xui_script_temp}"
|
|
rm -f "${xui_script_temp}"
|
|
|
_fail "ERROR: Failed to download x-ui.sh script, please be sure that your server can access GitHub"
|
|
_fail "ERROR: Failed to download x-ui.sh script, please be sure that your server can access GitHub"
|
|
@@ -1117,7 +1150,7 @@ update_x-ui() {
|
|
|
echo -e "${green}Downloading and installing startup unit x-ui.rc...${plain}"
|
|
echo -e "${green}Downloading and installing startup unit x-ui.rc...${plain}"
|
|
|
xui_rc_temp="/etc/init.d/x-ui.tmp.$$"
|
|
xui_rc_temp="/etc/init.d/x-ui.tmp.$$"
|
|
|
rm -f "${xui_rc_temp}"
|
|
rm -f "${xui_rc_temp}"
|
|
|
- ${curl_bin} -fLRo "${xui_rc_temp}" https://raw.githubusercontent.com/MHSanaei/3x-ui/main/x-ui.rc > /dev/null 2>&1
|
|
|
|
|
|
|
+ ${curl_bin} -fLRo "${xui_rc_temp}" "https://raw.githubusercontent.com/MHSanaei/3x-ui/${script_ref}/x-ui.rc" > /dev/null 2>&1
|
|
|
if [[ $? -ne 0 ]]; then
|
|
if [[ $? -ne 0 ]]; then
|
|
|
rm -f "${xui_rc_temp}"
|
|
rm -f "${xui_rc_temp}"
|
|
|
_fail "ERROR: Failed to download startup unit x-ui.rc, please be sure that your server can access GitHub"
|
|
_fail "ERROR: Failed to download startup unit x-ui.rc, please be sure that your server can access GitHub"
|
|
@@ -1176,18 +1209,18 @@ update_x-ui() {
|
|
|
echo -e "${yellow}Service files not found in tar.gz, downloading from GitHub...${plain}"
|
|
echo -e "${yellow}Service files not found in tar.gz, downloading from GitHub...${plain}"
|
|
|
case "${release}" in
|
|
case "${release}" in
|
|
|
ubuntu | debian | armbian)
|
|
ubuntu | debian | armbian)
|
|
|
- service_unit_url="https://raw.githubusercontent.com/MHSanaei/3x-ui/main/x-ui.service.debian"
|
|
|
|
|
|
|
+ service_unit_url="https://raw.githubusercontent.com/MHSanaei/3x-ui/${script_ref}/x-ui.service.debian"
|
|
|
;;
|
|
;;
|
|
|
arch | manjaro | parch)
|
|
arch | manjaro | parch)
|
|
|
- service_unit_url="https://raw.githubusercontent.com/MHSanaei/3x-ui/main/x-ui.service.arch"
|
|
|
|
|
|
|
+ service_unit_url="https://raw.githubusercontent.com/MHSanaei/3x-ui/${script_ref}/x-ui.service.arch"
|
|
|
;;
|
|
;;
|
|
|
*)
|
|
*)
|
|
|
- service_unit_url="https://raw.githubusercontent.com/MHSanaei/3x-ui/main/x-ui.service.rhel"
|
|
|
|
|
|
|
+ service_unit_url="https://raw.githubusercontent.com/MHSanaei/3x-ui/${script_ref}/x-ui.service.rhel"
|
|
|
;;
|
|
;;
|
|
|
esac
|
|
esac
|
|
|
|
|
|
|
|
if ! _install_xui_service_unit "$service_unit_url" "true"; then
|
|
if ! _install_xui_service_unit "$service_unit_url" "true"; then
|
|
|
- echo -e "${red}Failed to install x-ui.service from GitHub${plain}"
|
|
|
|
|
|
|
+ echo -e "${red}Failed to install x-ui.service from GitHub (${script_ref}) -- the release tarball did not ship one either${plain}"
|
|
|
exit 1
|
|
exit 1
|
|
|
fi
|
|
fi
|
|
|
fi
|
|
fi
|