mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2025-12-23 06:42:41 +00:00
Compare commits
No commits in common. "b8dc7b2c714e51f847070127a83ad1e21ab44870" and "e9757350f340e677127aeff1093fc2dd55c63c61" have entirely different histories.
b8dc7b2c71
...
e9757350f3
3 changed files with 23 additions and 21 deletions
|
|
@ -1,22 +1,19 @@
|
|||
#!/bin/sh
|
||||
|
||||
set -eu
|
||||
|
||||
: "${MAX_GEODATA_DIR_WAIT:=30}"
|
||||
: "${WAIT_INTERVAL:=10}"
|
||||
: "${GEODATA_DIR:?GEODATA_DIR is required}"
|
||||
|
||||
FINISH_FILE="$GEODATA_DIR/cron-job-finished.txt"
|
||||
ELAPSED=0
|
||||
|
||||
while [ ! -f "$FINISH_FILE" ] && [ "$ELAPSED" -lt "$MAX_GEODATA_DIR_WAIT" ]; do
|
||||
echo "Waiting for geodata initialization... ($ELAPSED/$MAX_GEODATA_DIR_WAIT seconds)"
|
||||
sleep $WAIT_INTERVAL
|
||||
ELAPSED=$((ELAPSED + WAIT_INTERVAL))
|
||||
MAX_WAIT=300 # 5 minutes
|
||||
ELAPSED=0
|
||||
INTERVAL=10
|
||||
|
||||
while [ ! -f "$FINISH_FILE" ] && [ $ELAPSED -lt $MAX_WAIT ]; do
|
||||
echo "Still waiting for geodata initialization... ($ELAPSED/$MAX_WAIT seconds)"
|
||||
sleep $INTERVAL
|
||||
ELAPSED=$((ELAPSED + INTERVAL))
|
||||
done
|
||||
|
||||
if [ ! -f "$FINISH_FILE" ]; then
|
||||
echo "ERROR: Geodata initialization timed out after $MAX_GEODATA_DIR_WAIT seconds"
|
||||
echo "ERROR: Geodata initialization timed out after $MAX_WAIT seconds"
|
||||
echo "Container startup aborted."
|
||||
exit 1
|
||||
fi
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ RUN apk add --no-cache \
|
|||
|
||||
COPY xray-tools.sh entrypoint.sh cron-job-script.sh ./
|
||||
|
||||
#RUN mkdir -p "$XRAY_BUILD_DIR"
|
||||
RUN chmod +x /app/xray-tools.sh /app/entrypoint.sh /app/cron-job-script.sh \
|
||||
&& mkdir -p "$XRAY_BUILD_DIR" \
|
||||
&& ./xray-tools.sh install_xray_core "$TARGETARCH" "$XRAY_BUILD_DIR" "$XRAY_VERSION" \
|
||||
|
|
|
|||
|
|
@ -126,20 +126,24 @@ install_xray_core() {
|
|||
# Validate the downloaded zip file
|
||||
if [ ! -f "Xray-linux-${ARCH}.zip" ] || [ ! -s "Xray-linux-${ARCH}.zip" ]; then
|
||||
echo "[ERR] Failed to download Xray-core zip or file is empty"
|
||||
exit 1
|
||||
cd "$OLD_DIR"
|
||||
return 1
|
||||
fi
|
||||
|
||||
unzip -q "Xray-linux-${ARCH}.zip" -d ./xray-unzip
|
||||
|
||||
# Validate the extracted xray binary
|
||||
if [ -f "./xray-unzip/xray" ]; then
|
||||
cp ./xray-unzip/xray ./"xray-linux-${FNAME}"
|
||||
rm -r xray-unzip
|
||||
rm "Xray-linux-${ARCH}.zip"
|
||||
else
|
||||
echo "[ERR] Failed to extract xray binary"
|
||||
exit 1
|
||||
if [ ! -f "./xray-unzip/xray" ] || [ ! -s "./xray-unzip/xray" ]; then
|
||||
echo "[ERR] Failed to extract xray binary"
|
||||
rm -rf ./xray-unzip
|
||||
rm -f "Xray-linux-${ARCH}.zip"
|
||||
cd "$OLD_DIR"
|
||||
return 1
|
||||
fi
|
||||
|
||||
cp ./xray-unzip/xray ./"xray-linux-${FNAME}"
|
||||
rm -r xray-unzip
|
||||
rm "Xray-linux-${ARCH}.zip"
|
||||
}
|
||||
|
||||
if [ "${0##*/}" = "xray-tools.sh" ]; then
|
||||
|
|
@ -162,7 +166,7 @@ if [ "${0##*/}" = "xray-tools.sh" ]; then
|
|||
echo "Usage:"
|
||||
echo " $0 install_xray_core TARGETARCH XRAYDIR XRAY_VERSION"
|
||||
echo " $0 update_geodata_in_docker XRAYDIR"
|
||||
exit 0
|
||||
exit 1
|
||||
;;
|
||||
*)
|
||||
echo "Unknown command: $cmd" >&2
|
||||
|
|
|
|||
Loading…
Reference in a new issue