Compare commits

...

2 commits

Author SHA1 Message Date
TorotinJenkins
f910aa814a Merge branch 'main' of https://github.com/Torotin/3x-ui 2025-06-25 14:55:57 +03:00
TorotinJenkins
ef7a68abea DockerInit rewritten, bash added to dockerfile at build stage 2025-06-25 14:55:02 +03:00
2 changed files with 57 additions and 23 deletions

View file

@ -1,37 +1,69 @@
#!/usr/bin/env bash #!/bin/sh
set -euo pipefail # POSIX-compatible script to download Xray binary and GeoIP/GeoSite databases
IFS=$'\n\t'
<<<<<<< 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 # DockerInit.sh <20> download and prepare Xray binaries and geolocation databases
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
# Xray version # Xray version
readonly XRAY_VERSION="v25.6.8" readonly XRAY_VERSION="v25.6.8"
>>>>>>> f7a3ebf2f3c28d40c1ae126f73ac6a8c9e22c2c6
# URL template for downloading Xray # Map architecture
readonly XRAY_URL_TEMPLATE="https://github.com/XTLS/Xray-core/releases/download/${XRAY_VERSION}/Xray-linux-%s.zip" 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 echo "Selected architecture: $ARCH$ARCH_SUFFIX$FNAME"
readonly BUILD_DIR="build/bin"
readonly ROOT_DIR="$(pwd)"
# Check for required utilities # Create directory
check_dependencies() { mkdir -p "$DAT_DIR"
local deps=(wget unzip) cd "$DAT_DIR"
for cmd in "${deps[@]}"; do
if ! command -v "$cmd" &> /dev/null; then # Download and unpack Xray
echo "Error: Required utility '$cmd' is not installed. Please install it and try again." >&2 XRAY_ZIP="Xray-linux-${ARCH_SUFFIX}.zip"
exit 1 echo "Downloading Xray: $XRAY_ZIP"
fi wget -q "${BASE_URL}/${XRAY_ZIP}"
done 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 download_variant "IR" "https://github.com/chocolate4u/Iran-v2ray-rules/releases/latest/download"
usage() { download_variant "RU" "https://github.com/runetfreedom/russia-v2ray-rules-dat/releases/latest/download"
cat <<EOF
Usage: $0 <architecture>
<<<<<<< HEAD
echo "All files downloaded successfully."
cd ../../
=======
Supported architectures: Supported architectures:
amd64 ? 64-bit x86 amd64 ? 64-bit x86
i386 ? 32-bit x86 i386 ? 32-bit x86
@ -152,4 +184,5 @@ if [[ "${1-}" == "-h" || "${1-}" == "--help" ]]; then
fi fi
# Run main with the provided argument (if any) # Run main with the provided argument (if any)
main "${1-}" main "${1-}"
>>>>>>> f7a3ebf2f3c28d40c1ae126f73ac6a8c9e22c2c6

View file

@ -9,7 +9,8 @@ RUN apk --no-cache --update add \
build-base \ build-base \
gcc \ gcc \
wget \ wget \
unzip unzip \
bash
COPY . . COPY . .