Compare commits

..

4 commits

Author SHA1 Message Date
Michael S2pac
e9757350f3 fixed copilot suggestion 2025-12-03 20:55:05 +03:00
nagibator_archivator
fcf86063f3
Update docker-compose.yml
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2025-12-03 20:47:51 +03:00
nagibator_archivator
20ca19233a
Update docker-cron-runner/xray-tools.sh
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2025-12-03 20:45:57 +03:00
Michael S2pac
ba07e15695 add timeout mechanism and better error handling 2025-12-03 20:33:43 +03:00
3 changed files with 35 additions and 6 deletions

View file

@ -2,11 +2,22 @@
FINISH_FILE="$GEODATA_DIR/cron-job-finished.txt"
while [ ! -f "$FINISH_FILE" ]; do
echo "Still waiting... (looking for $FINISH_FILE)"
sleep 10
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_WAIT seconds"
echo "Container startup aborted."
exit 1
fi
# Start fail2ban
[ "$XUI_ENABLE_FAIL2BAN" = "true" ] && fail2ban-client -x start

View file

@ -35,7 +35,7 @@ services:
build:
context: docker-cron-runner
args:
XRAY_VERSION: "v25.10.15"
XRAY_VERSION: "${XRAY_VERSION:-v25.10.15}"
XRAY_BUILD_DIR: "/app/xray"
container_name: geodata_cron
restart: unless-stopped

View file

@ -122,11 +122,29 @@ install_xray_core() {
cd "$XRAYDIR"
wget -q "https://github.com/XTLS/Xray-core/releases/download/${XRAY_VERSION}/Xray-linux-${ARCH}.zip"
unzip "Xray-linux-${ARCH}.zip" -d ./xray-unzip
# 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"
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" ] || [ ! -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
cmd="$1"