[PR #6904] [CLOSED] .sh files reviewed and fixed #6512

Closed
opened 2026-11-02 04:09:18 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/MHSanaei/3x-ui/pull/6904
Author: @jalalsaberi
Created: 10/22/2026
Status: ❌ Closed

Base: main ← Head: main


📝 Commits (8)

📊 Changes

6 files changed (+352 additions, -125 deletions)

View changed files

📝 DockerEntrypoint.sh (+4 -1)
📝 DockerInit.sh (+28 -17)
📝 Dockerfile (+2 -1)
📝 install.sh (+89 -27)
📝 update.sh (+85 -32)
📝 x-ui.sh (+144 -47)

📄 Description

fix(scripts): harden install/update/menu scripts and Docker arch mapping

install.sh

  • Validate the panel port (1-65535) before x-ui setting. A blank or
    non-numeric port made the Go flag parser exit, so username, password
    and webBasePath were never applied: the panel stayed on admin/admin
    with base path "/" while the installer printed (and saved to
    install-result.env) credentials that did not exist. Abort if the
    settings call fails. XUI_PANEL_PORT is validated the same way.
  • Re-issuing a domain/IP certificate no longer deletes /root/cert/
    before issuance. On failure the panel kept pointing at deleted files
    and silently fell back to plain HTTP.
  • Restart (not start) the service at the end of install: on a reinstall
    the SSL step could already have started the panel under the old unit,
    so start was a no-op and the new unit/sandbox drop-in never applied.
  • Keep the bin/ backup when install fails or is interrupted (it is the
    only copy of custom geo files once the old folder is removed); INT and
    TERM now exit instead of continuing the script.
  • Require XUI_MAIN_FOLDER to end in /x-ui and check cd, instead of
    deleting the old install and then failing to extract.
  • Unsupported CPU: exit from the main shell (exit inside $(arch) only
    left the subshell) and stop deleting $0.
  • Read the env file with a parser instead of source, so a DSN with
    & ; $( ) is neither mangled nor executed.

update.sh

  • Drop the second x-ui migrate in config_after_update; it ran against
    the live service, re-introducing the race fixed in #6728.
  • Download x-ui.sh before stopping the service and removing the old
    unit/binaries, so a GitHub failure leaves the panel running.
  • Resolve the latest tag via the releases/latest redirect with API
    fallback (as install.sh does) and add retry/stall timeouts to the
    tarball download (the web updater runs detached).
  • Probe the service-unit folder in require_writable_update_paths.
  • Show the server IP, not "ip", in the access URL for IP certificates.
  • Same arch, XUI_MAIN_FOLDER and safe env-file fixes as install.sh.

x-ui.sh

  • Define LOGW (used 3x, undefined -> exit 127 aborted SSL issuing on
    unlisted distros); check socat by presence, not by the case's $?.
  • Validate the port in "Change Port" (out-of-range locked admins out).
  • Do not delete the live certificate folder before (re)issuing.
  • Firewall install: open the real SSH port(s) and the panel's actual
    port instead of 22/2053, refuse to enable if the port is unknown, and
    install ufw on non-Debian distros.
  • IP-limit jail: detect SSH ports with sshd -T (handles Include files)
    and without grep -P (absent in busybox), so a custom SSH port is
    exempted from bans.
  • Block uninstall inside Docker (it only wiped the data volume).
  • Exact match (grep -Fxq) for domain selection; "a", "." or ".." used to
    pass the regex word match.
  • legacy_version: validate the version and drop eval.
  • x-ui update/update-dev no longer drop into the menu; open/delete
    ports return instead of exiting the menu; guard empty os_version;
    quote/validate the Cloudflare domain; numeric $# -gt comparisons.

Docker

  • DockerInit.sh: map buildx TARGETARCH/TARGETVARIANT correctly. linux/386
    got the amd64 Xray under the wrong name, linux/arm/v6 got the ARMv7
    Xray, and every 32-bit ARM image saved mtg as mtg-linux-arm32 while
    the panel looks for mtg-linux-arm. Unknown arches now fail the build.
  • Dockerfile: pass TARGETVARIANT to DockerInit.sh.
  • DockerEntrypoint.sh: allow XUI_SSH_PORTS to exempt the host's SSH port
    from IP-limit bans (the container has no sshd_config of its own).

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/MHSanaei/3x-ui/pull/6904 **Author:** [@jalalsaberi](https://github.com/jalalsaberi) **Created:** 10/22/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `main` --- ### 📝 Commits (8) - [`11dc010`](https://github.com/MHSanaei/3x-ui/commit/11dc010564a849bc8e19b076baf1dc05bfb3c83a) bug fix for install.sh - [`085aa8d`](https://github.com/MHSanaei/3x-ui/commit/085aa8d9c21d10a0e3613620991458fec702732a) bug fix for update.sh - [`ebe7b0a`](https://github.com/MHSanaei/3x-ui/commit/ebe7b0a1285517076d62e42c80bb77d5eccab674) bug fix for x-ui.sh - [`7c5fa72`](https://github.com/MHSanaei/3x-ui/commit/7c5fa726e4c05d5342499e8d0c95a5957cb23c7a) bug fix for DockerInit.sh - [`9946b62`](https://github.com/MHSanaei/3x-ui/commit/9946b624c9f2d8e71099cc208e9c9f0cd8e9fa33) fix for Dockerfile - [`e667643`](https://github.com/MHSanaei/3x-ui/commit/e6676435ce1e160344e5fc686ca58fffbc87c60f) fix for DockerEntrypoint.sh - [`83520b8`](https://github.com/MHSanaei/3x-ui/commit/83520b8e9522ed7f3b0267dd53a9ff197b59d35e) Update Dockerfile - [`151036e`](https://github.com/MHSanaei/3x-ui/commit/151036e718f69f6760c5bca4fcd3e2afad2e33b7) fix findings ### 📊 Changes **6 files changed** (+352 additions, -125 deletions) <details> <summary>View changed files</summary> 📝 `DockerEntrypoint.sh` (+4 -1) 📝 `DockerInit.sh` (+28 -17) 📝 `Dockerfile` (+2 -1) 📝 `install.sh` (+89 -27) 📝 `update.sh` (+85 -32) 📝 `x-ui.sh` (+144 -47) </details> ### 📄 Description fix(scripts): harden install/update/menu scripts and Docker arch mapping install.sh - Validate the panel port (1-65535) before `x-ui setting`. A blank or non-numeric port made the Go flag parser exit, so username, password and webBasePath were never applied: the panel stayed on admin/admin with base path "/" while the installer printed (and saved to install-result.env) credentials that did not exist. Abort if the settings call fails. XUI_PANEL_PORT is validated the same way. - Re-issuing a domain/IP certificate no longer deletes /root/cert/<name> before issuance. On failure the panel kept pointing at deleted files and silently fell back to plain HTTP. - Restart (not start) the service at the end of install: on a reinstall the SSL step could already have started the panel under the old unit, so `start` was a no-op and the new unit/sandbox drop-in never applied. - Keep the bin/ backup when install fails or is interrupted (it is the only copy of custom geo files once the old folder is removed); INT and TERM now exit instead of continuing the script. - Require XUI_MAIN_FOLDER to end in /x-ui and check `cd`, instead of deleting the old install and then failing to extract. - Unsupported CPU: exit from the main shell (exit inside $(arch) only left the subshell) and stop deleting $0. - Read the env file with a parser instead of `source`, so a DSN with & ; $( ) is neither mangled nor executed. update.sh - Drop the second `x-ui migrate` in config_after_update; it ran against the live service, re-introducing the race fixed in #6728. - Download x-ui.sh before stopping the service and removing the old unit/binaries, so a GitHub failure leaves the panel running. - Resolve the latest tag via the releases/latest redirect with API fallback (as install.sh does) and add retry/stall timeouts to the tarball download (the web updater runs detached). - Probe the service-unit folder in require_writable_update_paths. - Show the server IP, not "ip", in the access URL for IP certificates. - Same arch, XUI_MAIN_FOLDER and safe env-file fixes as install.sh. x-ui.sh - Define LOGW (used 3x, undefined -> exit 127 aborted SSL issuing on unlisted distros); check socat by presence, not by the case's $?. - Validate the port in "Change Port" (out-of-range locked admins out). - Do not delete the live certificate folder before (re)issuing. - Firewall install: open the real SSH port(s) and the panel's actual port instead of 22/2053, refuse to enable if the port is unknown, and install ufw on non-Debian distros. - IP-limit jail: detect SSH ports with `sshd -T` (handles Include files) and without `grep -P` (absent in busybox), so a custom SSH port is exempted from bans. - Block `uninstall` inside Docker (it only wiped the data volume). - Exact match (grep -Fxq) for domain selection; "a", "." or ".." used to pass the regex word match. - legacy_version: validate the version and drop `eval`. - `x-ui update`/`update-dev` no longer drop into the menu; open/delete ports return instead of exiting the menu; guard empty os_version; quote/validate the Cloudflare domain; numeric `$# -gt` comparisons. Docker - DockerInit.sh: map buildx TARGETARCH/TARGETVARIANT correctly. linux/386 got the amd64 Xray under the wrong name, linux/arm/v6 got the ARMv7 Xray, and every 32-bit ARM image saved mtg as mtg-linux-arm32 while the panel looks for mtg-linux-arm. Unknown arches now fail the build. - Dockerfile: pass TARGETVARIANT to DockerInit.sh. - DockerEntrypoint.sh: allow XUI_SSH_PORTS to exempt the host's SSH port from IP-limit bans (the container has no sshd_config of its own). --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-02 04:09:18 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
MHSanaei/3x-ui#6512
No description provided.