[PR #6152] [MERGED] fix(install): preserve custom bin/ files (e.g. hand-added geoip) across updates #6115

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

📋 Pull Request Information

Original PR: https://github.com/MHSanaei/3x-ui/pull/6152
Author: @kuzzrus
Created: 7/29/2026
Status: ✅ Merged
Merged: 8/14/2026
Merged by: @MHSanaei

Base: main ← Head: upstream-pr/preserve-custom-bin-files


📝 Commits (2)

  • e62e0dc fix(install): preserve custom bin/ files (e.g. hand-added geoip) across updates
  • dc377d0 fix: harden the bin/ snapshot-and-restore against the review round on #6152

📊 Changes

2 files changed (+77 additions, -0 deletions)

View changed files

📝 deploy/test/smoke-noninteractive.sh (+18 -0)
📝 install.sh (+59 -0)

📄 Description

Problem

Every reinstall/update (install_x-ui) stops the panel and then wipes
/usr/local/x-ui/ wholesale before re-extracting the release tarball:

rm ${xui_folder}/ -rf

The release tarball only ships the assets 3x-ui itself bundles (the
xray/mtg binaries, the default geoip.dat/geosite.dat set). Anything
else an admin has placed in bin/ — most commonly a hand-added custom
geoip/geosite file referenced from a routing rule via ext:<file>:<code> —
has no owner other than the admin, and is silently deleted by this wipe.

Real-world impact: after an update, Xray refuses to start at all, with
every inbound down, because a routing rule now points at a file that no
longer exists (failed to open <file>: no such file or directory). The
only way back is restoring the missing file from a separate backup — the
installer itself gives no warning that this will happen or has happened.

Fix

install_x-ui now backs up the existing bin/ directory before the wipe,
and after extracting the fresh release, restores only the files the new
release doesn't already provide. Bundled assets (geoip.dat, xray-linux-*,
etc.) always end up as the fresh release's copy — nothing about the update
path for standard files changes. Anything extra that was in bin/ and
isn't part of the new release (custom geoip/geosite files, or anything else
hand-placed there) survives the update untouched, and the installer prints
which file(s) it restored so the admin can see it happened.

Also cleans up the temporary backup on the existing early-exit error paths
(failed extraction, missing x-ui binary after extraction) so a failed
update doesn't leave a stray temp directory behind.

Testing

  • bash -n install.sh — syntax check passes.
  • shellcheck install.sh — no new warnings introduced by this change
    (one pre-existing-style SC2086 info note, consistent with how the
    surrounding function already handles ${xui_folder} elsewhere).
  • Verified in isolation: standard files (geoip.dat, the xray binary)
    end up as the fresh release's copy after an update; a custom file that
    isn't part of the release survives an update untouched.

🔄 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/6152 **Author:** [@kuzzrus](https://github.com/kuzzrus) **Created:** 7/29/2026 **Status:** ✅ Merged **Merged:** 8/14/2026 **Merged by:** [@MHSanaei](https://github.com/MHSanaei) **Base:** `main` ← **Head:** `upstream-pr/preserve-custom-bin-files` --- ### 📝 Commits (2) - [`e62e0dc`](https://github.com/MHSanaei/3x-ui/commit/e62e0dc0340bd2205ab99880df4a537dbc91e777) fix(install): preserve custom bin/ files (e.g. hand-added geoip) across updates - [`dc377d0`](https://github.com/MHSanaei/3x-ui/commit/dc377d06901ccd9da3a30fbe95751614bf040412) fix: harden the bin/ snapshot-and-restore against the review round on #6152 ### 📊 Changes **2 files changed** (+77 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `deploy/test/smoke-noninteractive.sh` (+18 -0) 📝 `install.sh` (+59 -0) </details> ### 📄 Description ## Problem Every reinstall/update (`install_x-ui`) stops the panel and then wipes `/usr/local/x-ui/` wholesale before re-extracting the release tarball: ```bash rm ${xui_folder}/ -rf ``` The release tarball only ships the assets 3x-ui itself bundles (the `xray`/`mtg` binaries, the default `geoip.dat`/`geosite.dat` set). Anything else an admin has placed in `bin/` — most commonly a hand-added custom geoip/geosite file referenced from a routing rule via `ext:<file>:<code>` — has no owner other than the admin, and is silently deleted by this wipe. Real-world impact: after an update, Xray refuses to start at all, with every inbound down, because a routing rule now points at a file that no longer exists (`failed to open <file>: no such file or directory`). The only way back is restoring the missing file from a separate backup — the installer itself gives no warning that this will happen or has happened. ## Fix `install_x-ui` now backs up the existing `bin/` directory before the wipe, and after extracting the fresh release, restores only the files the new release doesn't already provide. Bundled assets (`geoip.dat`, `xray-linux-*`, etc.) always end up as the fresh release's copy — nothing about the update path for standard files changes. Anything extra that was in `bin/` and isn't part of the new release (custom geoip/geosite files, or anything else hand-placed there) survives the update untouched, and the installer prints which file(s) it restored so the admin can see it happened. Also cleans up the temporary backup on the existing early-exit error paths (failed extraction, missing `x-ui` binary after extraction) so a failed update doesn't leave a stray temp directory behind. ## Testing - `bash -n install.sh` — syntax check passes. - `shellcheck install.sh` — no new warnings introduced by this change (one pre-existing-style `SC2086` info note, consistent with how the surrounding function already handles `${xui_folder}` elsewhere). - Verified in isolation: standard files (`geoip.dat`, the `xray` binary) end up as the fresh release's copy after an update; a custom file that isn't part of the release survives an update untouched. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-02 04:06:28 +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#6115
No description provided.