Add XUI.ONE 1.5.13 installer with self-hosted Gitea mirror
Bootstrap installer that downloads the pre-patched XUI 1.5.13 package from our Gitea generic-package mirror (GitHub fallback), checksum-verifies it, and runs the bundled ./install. Includes preflight checks (root, Ubuntu 20/22/24, x86_64, RAM/disk, re-install guard). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Executable
+191
@@ -0,0 +1,191 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# XUI.ONE 1.5.13 Installer (bootstrap)
|
||||
# -----------------------------------
|
||||
# Downloads the pre-patched XUI.ONE 1.5.13 release, extracts it, and runs the
|
||||
# bundled installer. Modeled on the midesi.net installxui.sh wrapper, but pulls
|
||||
# the package directly from the XUIPatch GitHub release.
|
||||
#
|
||||
# Usage (as root):
|
||||
# bash <(wget -qO- https://raw.githubusercontent.com/<you>/xui_installer/main/install_xui.sh)
|
||||
# -- or --
|
||||
# chmod +x install_xui.sh && ./install_xui.sh
|
||||
#
|
||||
set -euo pipefail
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# Config
|
||||
# ---------------------------------------------------------------------------
|
||||
RELEASE_NAME="XUI_1.5.13.zip"
|
||||
|
||||
# Primary download source: self-hosted Gitea generic-package mirror (fast, under
|
||||
# our control). Override with the XUI_URL env var to point elsewhere.
|
||||
DEFAULT_URL="https://git.ops01.hprx.zip/api/packages/seed/generic/xui/1.5.13/${RELEASE_NAME}"
|
||||
URL="${XUI_URL:-$DEFAULT_URL}"
|
||||
|
||||
# Fallback source: the upstream XUIPatch GitHub release. Tried automatically if
|
||||
# the primary mirror is unreachable. Override with XUI_FALLBACK_URL.
|
||||
FALLBACK_URL="${XUI_FALLBACK_URL:-https://github.com/xuione/XUIPatch/releases/download/main/${RELEASE_NAME}}"
|
||||
|
||||
# Integrity check: known-good SHA-256 of XUI_1.5.13.zip. Verified before extract.
|
||||
# Override/clear with the XUI_SHA256 env var (set to "" to skip).
|
||||
EXPECTED_SHA256="${XUI_SHA256-a92e5f21a338c56190d7580f449492c970b5d4219474548ca5ec2f06bc57b2e7}"
|
||||
|
||||
WORKDIR="${XUI_WORKDIR:-/opt/xui_install}"
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# Helpers
|
||||
# ---------------------------------------------------------------------------
|
||||
c_reset=$'\033[0m'; c_blue=$'\033[1;34m'; c_green=$'\033[1;32m'
|
||||
c_yellow=$'\033[1;33m'; c_red=$'\033[1;31m'
|
||||
|
||||
info() { printf '%s[*]%s %s\n' "$c_blue" "$c_reset" "$*"; }
|
||||
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; }
|
||||
|
||||
banner() {
|
||||
cat <<'EOF'
|
||||
|
||||
===============================================
|
||||
XUI.ONE 1.5.13 Installer
|
||||
===============================================
|
||||
|
||||
EOF
|
||||
}
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# Pre-flight checks
|
||||
# ---------------------------------------------------------------------------
|
||||
preflight() {
|
||||
# Must be root
|
||||
if [ "$(id -u)" -ne 0 ]; then
|
||||
die "This installer must be run as root. Try: sudo su - then re-run."
|
||||
fi
|
||||
|
||||
# OS / version check (XUI 1.5.13 is tested on Ubuntu 20.04 / 22.04 / 24.04)
|
||||
if [ -r /etc/os-release ]; then
|
||||
# shellcheck disable=SC1091
|
||||
. /etc/os-release
|
||||
if [ "${ID:-}" != "ubuntu" ]; then
|
||||
warn "This package is tested on Ubuntu only (detected: ${PRETTY_NAME:-unknown})."
|
||||
warn "Continuing anyway, but the install may fail."
|
||||
else
|
||||
case "${VERSION_ID:-}" in
|
||||
20.04|22.04|24.04) ok "Ubuntu ${VERSION_ID} detected (supported)." ;;
|
||||
*) warn "Ubuntu ${VERSION_ID:-?} is untested for this build (supported: 20.04 / 22.04 / 24.04)." ;;
|
||||
esac
|
||||
fi
|
||||
else
|
||||
warn "Could not detect OS (no /etc/os-release). Proceeding cautiously."
|
||||
fi
|
||||
|
||||
# Architecture
|
||||
arch="$(uname -m)"
|
||||
[ "$arch" = "x86_64" ] || warn "Architecture is '$arch'; XUI expects x86_64."
|
||||
|
||||
# Resource warnings (non-fatal)
|
||||
mem_gb=$(awk '/MemTotal/ {printf "%d", $2/1024/1024}' /proc/meminfo 2>/dev/null || echo 0)
|
||||
[ "${mem_gb:-0}" -ge 8 ] || warn "Only ${mem_gb}GB RAM detected; 16GB+ recommended for production."
|
||||
disk_gb=$(df -BG --output=avail / 2>/dev/null | tail -1 | tr -dc '0-9' || echo 0)
|
||||
[ "${disk_gb:-0}" -ge 20 ] || warn "Only ${disk_gb}GB free on /; 40GB+ recommended."
|
||||
|
||||
# Re-install guard
|
||||
if [ -d /home/xui ]; then
|
||||
warn "/home/xui already exists — XUI may already be installed."
|
||||
printf 'Continue and re-run the installer anyway? (y/N): '
|
||||
read -r ans
|
||||
case "$ans" in y|Y) ;; *) die "Aborted by user." ;; esac
|
||||
fi
|
||||
}
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# Dependencies
|
||||
# ---------------------------------------------------------------------------
|
||||
ensure_deps() {
|
||||
local missing=()
|
||||
for bin in wget unzip tar; do
|
||||
command -v "$bin" >/dev/null 2>&1 || missing+=("$bin")
|
||||
done
|
||||
if [ "${#missing[@]}" -gt 0 ]; then
|
||||
info "Installing missing dependencies: ${missing[*]}"
|
||||
export DEBIAN_FRONTEND=noninteractive
|
||||
apt-get update -qq
|
||||
apt-get install -y -qq "${missing[@]}"
|
||||
fi
|
||||
}
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# Download + verify
|
||||
# ---------------------------------------------------------------------------
|
||||
fetch() {
|
||||
mkdir -p "$WORKDIR"
|
||||
cd "$WORKDIR"
|
||||
|
||||
info "Downloading XUI release package..."
|
||||
info "Primary source: $URL"
|
||||
if ! wget --tries=3 --timeout=60 --quiet --show-progress \
|
||||
--progress=bar:force:noscroll "$URL" -O "$RELEASE_NAME"; then
|
||||
warn "Primary source failed; trying fallback: $FALLBACK_URL"
|
||||
rm -f "$RELEASE_NAME"
|
||||
if ! wget --tries=3 --timeout=60 --quiet --show-progress \
|
||||
--progress=bar:force:noscroll "$FALLBACK_URL" -O "$RELEASE_NAME"; then
|
||||
die "Download failed from both primary and fallback sources."
|
||||
fi
|
||||
fi
|
||||
[ -s "$RELEASE_NAME" ] || die "Downloaded file is empty: $RELEASE_NAME"
|
||||
|
||||
if [ -n "$EXPECTED_SHA256" ]; then
|
||||
info "Verifying checksum..."
|
||||
actual=$(sha256sum "$RELEASE_NAME" | awk '{print $1}')
|
||||
[ "$actual" = "$EXPECTED_SHA256" ] \
|
||||
|| die "Checksum mismatch! expected=$EXPECTED_SHA256 actual=$actual"
|
||||
ok "Checksum verified."
|
||||
fi
|
||||
}
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# Extract + run
|
||||
# ---------------------------------------------------------------------------
|
||||
extract_and_run() {
|
||||
cd "$WORKDIR"
|
||||
info "Extracting files..."
|
||||
unzip -o -q "$RELEASE_NAME" || die "Extraction failed."
|
||||
|
||||
[ -f install ] || die "Expected 'install' script not found in package."
|
||||
|
||||
info "Cleaning up archive..."
|
||||
rm -f "$RELEASE_NAME"
|
||||
|
||||
info "Setting permissions..."
|
||||
chmod +x install
|
||||
|
||||
cat <<'EOF'
|
||||
|
||||
-----------------------------------------------
|
||||
Handing over to the XUI installer.
|
||||
You will be prompted for:
|
||||
- your license key
|
||||
- sysctl overwrite (answer Y — recommended)
|
||||
After it finishes, MySQL credentials are saved
|
||||
to /root/credentials.txt
|
||||
-----------------------------------------------
|
||||
|
||||
EOF
|
||||
info "Starting XUI install..."
|
||||
./install
|
||||
}
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# Main
|
||||
# ---------------------------------------------------------------------------
|
||||
main() {
|
||||
banner
|
||||
preflight
|
||||
ensure_deps
|
||||
fetch
|
||||
extract_and_run
|
||||
ok "Installer finished. Check /root/credentials.txt for your panel details."
|
||||
}
|
||||
|
||||
main "$@"
|
||||
Reference in New Issue
Block a user