mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2025-10-30 20:02:51 +00:00
Compare commits
2 commits
f7a3ebf2f3
...
f910aa814a
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f910aa814a | ||
|
|
ef7a68abea |
2 changed files with 57 additions and 23 deletions
|
|
@ -1,37 +1,69 @@
|
|||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
IFS=$'\n\t'
|
||||
#!/bin/sh
|
||||
# POSIX-compatible script to download Xray binary and GeoIP/GeoSite databases
|
||||
|
||||
<<<<<<< HEAD
|
||||
set -eu
|
||||
|
||||
XRAY_VERSION="v25.6.8"
|
||||
BASE_URL="https://github.com/XTLS/Xray-core/releases/download/${XRAY_VERSION}"
|
||||
DAT_DIR="build/bin"
|
||||
ARCH="${1:-amd64}" # Default to amd64 if not provided
|
||||
=======
|
||||
# ------------------------------------------------------------------------------
|
||||
# DockerInit.sh <20> download and prepare Xray binaries and geolocation databases
|
||||
# ------------------------------------------------------------------------------
|
||||
|
||||
# Xray version
|
||||
readonly XRAY_VERSION="v25.6.8"
|
||||
>>>>>>> f7a3ebf2f3c28d40c1ae126f73ac6a8c9e22c2c6
|
||||
|
||||
# URL template for downloading Xray
|
||||
readonly XRAY_URL_TEMPLATE="https://github.com/XTLS/Xray-core/releases/download/${XRAY_VERSION}/Xray-linux-%s.zip"
|
||||
# Map architecture
|
||||
case "$ARCH" in
|
||||
amd64) ARCH_SUFFIX="64"; FNAME="amd64" ;;
|
||||
i386) ARCH_SUFFIX="32"; FNAME="i386" ;;
|
||||
armv8|arm64|aarch64) ARCH_SUFFIX="arm64-v8a"; FNAME="arm64" ;;
|
||||
armv7|arm|arm32) ARCH_SUFFIX="arm32-v7a"; FNAME="arm32" ;;
|
||||
armv6) ARCH_SUFFIX="arm32-v6"; FNAME="armv6" ;;
|
||||
*) ARCH_SUFFIX="64"; FNAME="amd64" ;;
|
||||
esac
|
||||
|
||||
# Directories
|
||||
readonly BUILD_DIR="build/bin"
|
||||
readonly ROOT_DIR="$(pwd)"
|
||||
echo "Selected architecture: $ARCH → $ARCH_SUFFIX → $FNAME"
|
||||
|
||||
# Check for required utilities
|
||||
check_dependencies() {
|
||||
local deps=(wget unzip)
|
||||
for cmd in "${deps[@]}"; do
|
||||
if ! command -v "$cmd" &> /dev/null; then
|
||||
echo "Error: Required utility '$cmd' is not installed. Please install it and try again." >&2
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
# Create directory
|
||||
mkdir -p "$DAT_DIR"
|
||||
cd "$DAT_DIR"
|
||||
|
||||
# Download and unpack Xray
|
||||
XRAY_ZIP="Xray-linux-${ARCH_SUFFIX}.zip"
|
||||
echo "Downloading Xray: $XRAY_ZIP"
|
||||
wget -q "${BASE_URL}/${XRAY_ZIP}"
|
||||
unzip -q "$XRAY_ZIP"
|
||||
rm -f "$XRAY_ZIP" geoip.dat geosite.dat
|
||||
mv xray "xray-linux-${FNAME}"
|
||||
chmod +x "xray-linux-${FNAME}"
|
||||
echo "Xray extracted and renamed"
|
||||
|
||||
# Download primary databases
|
||||
echo "Downloading official geoip/geosite..."
|
||||
wget -q https://github.com/Loyalsoldier/v2ray-rules-dat/releases/latest/download/geoip.dat
|
||||
wget -q https://github.com/Loyalsoldier/v2ray-rules-dat/releases/latest/download/geosite.dat
|
||||
|
||||
# Download region-specific datasets
|
||||
download_variant() {
|
||||
REGION="$1"
|
||||
BASE_URL="$2"
|
||||
echo "Downloading $REGION GeoIP/GeoSite..."
|
||||
wget -q -O "geoip_${REGION}.dat" "${BASE_URL}/geoip.dat"
|
||||
wget -q -O "geosite_${REGION}.dat" "${BASE_URL}/geosite.dat"
|
||||
}
|
||||
|
||||
# Print usage help
|
||||
usage() {
|
||||
cat <<EOF
|
||||
Usage: $0 <architecture>
|
||||
download_variant "IR" "https://github.com/chocolate4u/Iran-v2ray-rules/releases/latest/download"
|
||||
download_variant "RU" "https://github.com/runetfreedom/russia-v2ray-rules-dat/releases/latest/download"
|
||||
|
||||
<<<<<<< HEAD
|
||||
echo "All files downloaded successfully."
|
||||
cd ../../
|
||||
=======
|
||||
Supported architectures:
|
||||
amd64 ? 64-bit x86
|
||||
i386 ? 32-bit x86
|
||||
|
|
@ -152,4 +184,5 @@ if [[ "${1-}" == "-h" || "${1-}" == "--help" ]]; then
|
|||
fi
|
||||
|
||||
# Run main with the provided argument (if any)
|
||||
main "${1-}"
|
||||
main "${1-}"
|
||||
>>>>>>> f7a3ebf2f3c28d40c1ae126f73ac6a8c9e22c2c6
|
||||
|
|
|
|||
|
|
@ -9,7 +9,8 @@ RUN apk --no-cache --update add \
|
|||
build-base \
|
||||
gcc \
|
||||
wget \
|
||||
unzip
|
||||
unzip \
|
||||
bash
|
||||
|
||||
COPY . .
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue