Run XUI installer non-interactively with auto-generated license

XUI 1.5.13 is the post-shutdown license-free build: the installer's
isValidLicense() only checks len==16 + hex, and the license servers are
offline. Auto-generate a 16-hex key (openssl rand -hex 8), inject it, and
answer the sysctl prompt — fully unattended by default. Adds XUI_LICENSE,
XUI_SYSCTL, XUI_INTERACTIVE env vars and surfaces the panel setup URL.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Joel Mattison
2026-06-25 20:32:23 -04:00
co-authored by Claude Opus 4.8
parent 796fa5fbd4
commit 863a050413
2 changed files with 100 additions and 15 deletions
+74 -8
View File
@@ -33,6 +33,21 @@ EXPECTED_SHA256="${XUI_SHA256-a92e5f21a338c56190d7580f449492c970b5d4219474548ca5
WORKDIR="${XUI_WORKDIR:-/opt/xui_install}"
# License key. XUI 1.5.13 is the post-shutdown, license-free build: the patched
# extensions removed all license verification and the GTAXUI license servers are
# offline. The bundled installer only checks that the key is exactly 16 hex chars
# (isValidLicense: len==16 and all hex) — it never phones home. So any valid hex
# works; we auto-generate one unless XUI_LICENSE is provided.
XUI_LICENSE="${XUI_LICENSE:-}"
# Answer to the installer's "Overwrite sysctl configuration?" prompt (Y/N).
# Y is recommended (sets XUI's TCP tuning + open-file limits).
XUI_SYSCTL="${XUI_SYSCTL:-Y}"
# Set XUI_INTERACTIVE=1 to answer the installer's prompts yourself instead of
# letting this wrapper drive them non-interactively.
XUI_INTERACTIVE="${XUI_INTERACTIVE:-0}"
# ---------------------------------------------------------------------------
# Helpers
# ---------------------------------------------------------------------------
@@ -44,6 +59,22 @@ ok() { printf '%s[+]%s %s\n' "$c_green" "$c_reset" "$*"; }
warn() { printf '%s[!]%s %s\n' "$c_yellow" "$c_reset" "$*"; }
die() { printf '%s[x]%s %s\n' "$c_red" "$c_reset" "$*" >&2; exit 1; }
# Return a valid 16-char hex license: use XUI_LICENSE if set (validated), else
# generate a random one.
resolve_license() {
if [ -n "$XUI_LICENSE" ]; then
if printf '%s' "$XUI_LICENSE" | grep -Eq '^[0-9a-fA-F]{16}$'; then
printf '%s' "$XUI_LICENSE"; return 0
fi
die "XUI_LICENSE must be exactly 16 hex chars (got: '$XUI_LICENSE')."
fi
if command -v openssl >/dev/null 2>&1; then
openssl rand -hex 8
else
head -c 8 /dev/urandom | od -An -tx1 | tr -d ' \n'
fi
}
banner() {
cat <<'EOF'
@@ -160,20 +191,42 @@ extract_and_run() {
info "Setting permissions..."
chmod +x install
cat <<'EOF'
if [ "$XUI_INTERACTIVE" = "1" ]; then
cat <<'EOF'
-----------------------------------------------
Handing over to the XUI installer.
Handing over to the XUI installer (interactive).
You will be prompted for:
- your license key
- your license key (any 16-char hex works)
- sysctl overwrite (answer Y — recommended)
After it finishes, MySQL credentials are saved
to /root/credentials.txt
-----------------------------------------------
EOF
info "Starting XUI install..."
./install
info "Starting XUI install..."
./install
return
fi
LICENSE="$(resolve_license)"
local log="$WORKDIR/install.log"
cat <<EOF
-----------------------------------------------
Running the XUI installer non-interactively.
License key : $LICENSE
sysctl : answering '$XUI_SYSCTL'
(license servers are offline; any valid 16-hex
key works — this build never phones home)
-----------------------------------------------
EOF
info "Starting XUI install... (full log: $log)"
# Feed: license key, then the sysctl answer. The extra answers cover any
# conditional Y/N prompt without blocking. pipefail propagates install errors.
printf '%s\n%s\nY\nY\n' "$LICENSE" "$XUI_SYSCTL" | ./install 2>&1 | tee "$log"
# Surface the panel setup URL the installer prints at the end.
SETUP_URL="$(grep -aoE 'http://[0-9.]+/[A-Za-z0-9]+' "$log" | tail -1 || true)"
}
# ---------------------------------------------------------------------------
@@ -185,7 +238,20 @@ main() {
ensure_deps
fetch
extract_and_run
ok "Installer finished. Check /root/credentials.txt for your panel details."
echo
ok "XUI installation finished."
if [ "$XUI_INTERACTIVE" != "1" ]; then
printf '%s\n' "-----------------------------------------------"
[ -n "${SETUP_URL:-}" ] && printf ' Panel setup URL : %s\n' "$SETUP_URL"
printf ' License key : %s\n' "${LICENSE:-<entered interactively>}"
printf ' MySQL creds : %s/credentials.txt\n' "$WORKDIR"
printf ' Full log : %s/install.log\n' "$WORKDIR"
printf '%s\n' "-----------------------------------------------"
warn "Save credentials.txt somewhere safe, then open the setup URL to finish."
else
info "Check ${WORKDIR}/credentials.txt and the 'Continue Setup' URL above."
fi
}
main "$@"