feat(installer): add -version flag to pin 3x-ui release

Accepts 3.4.2 or v3.4.2; validates the tag exists on GitHub before
download, falls back to latest when omitted.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
Ivan Razin
2026-07-15 16:03:13 +03:00
co-authored by Claude Fable 5
parent c3926222c2
commit 6d0876fd19
4 changed files with 19 additions and 8 deletions
+1 -1
View File
@@ -27,7 +27,7 @@ effect on servers only after push to `main`.
## What x-ui-latest.sh does
1. Checks OS (Ubuntu 24.04/26.04, Debian 12/13) and rejects QEMU-emulated CPUs
2. Parses CLI arguments (`-install y`, `-subdomain`, `-reality_domain`, `-auto_domain y`, `-uninstall y`)
2. Parses CLI arguments (`-install y`, `-subdomain`, `-reality_domain`, `-auto_domain y`, `-version <ver>`, `-uninstall y`)
3. Validates domains (panel ≠ REALITY), then stops/cleans any previous install
4. Installs packages (`install_packages`) — nginx-full, certbot, sqlite3, ufw, mtr, python3 …
5. Obtains Let's Encrypt certs via certbot standalone (`get_ssl_certs`) — panel + reality domains
+1
View File
@@ -88,6 +88,7 @@ bash x-ui-latest.sh -uninstall y
| `-subdomain <домен>` | Домен панели и подписок |
| `-reality_domain <домен>` | Домен назначения для REALITY |
| `-auto_domain y` | Автоопределение домена (без ручного ввода) |
| `-version <версия>` | Установить конкретную версию 3x-ui (например `3.4.2`), по умолчанию — последняя |
| `-uninstall y` | Полное удаление |
---
+1
View File
@@ -88,6 +88,7 @@ bash x-ui-latest.sh -uninstall y
| `-subdomain <domain>` | Panel and subscription domain |
| `-reality_domain <domain>` | REALITY destination domain |
| `-auto_domain y` | Auto-detect domain (no manual input) |
| `-version <version>` | Install specific 3x-ui version (e.g. `3.4.2`), default — latest |
| `-uninstall y` | Full uninstall |
---
+9
View File
@@ -126,6 +126,7 @@ while [ "$#" -gt 0 ]; do
-subdomain) domain="$2"; shift 2 ;;
-reality_domain) reality_domain="$2"; shift 2 ;;
-ONLY_CF_IP_ALLOW) CFALLOW="$2"; shift 2 ;;
-version) PANEL_VERSION="$2"; shift 2 ;;
-uninstall) UNINSTALL="$2"; shift 2 ;;
*) shift 1 ;;
esac
@@ -727,6 +728,13 @@ install_panel() {
cd /usr/local/
if [[ -n "$PANEL_VERSION" ]]; then
tag_version="v${PANEL_VERSION#v}"
if ! curl -fsLo /dev/null "https://api.github.com/repos/MHSanaei/3x-ui/releases/tags/${tag_version}" \
&& ! curl -4 -fsLo /dev/null "https://api.github.com/repos/MHSanaei/3x-ui/releases/tags/${tag_version}"; then
echo "3x-ui release ${tag_version} not found." && exit 1
fi
else
tag_version=$(curl -Ls "https://api.github.com/repos/MHSanaei/3x-ui/releases/latest" \
| grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/')
if [[ -z "$tag_version" ]]; then
@@ -736,6 +744,7 @@ install_panel() {
if [[ -z "$tag_version" ]]; then
echo "Failed to fetch 3x-ui version." && exit 1
fi
fi
echo "Installing 3x-ui ${tag_version} ..."
wget -N -O /usr/local/x-ui-linux-$(_arch).tar.gz \