Compare commits

...

6 commits

Author SHA1 Message Date
nagibator_archivator
b8dc7b2c71
Update docker-cron-runner/Dockerfile
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2025-12-15 17:36:24 +03:00
Michael S2pac
64d2f15be2 Refactored previous commit 2025-12-15 17:20:24 +03:00
Michael S2pac
dd1beaaaba is not requiered anymore, add extra check for 2025-12-15 17:09:46 +03:00
nagibator_archivator
e301c15cef
Apply suggestions from code review
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2025-12-15 15:53:00 +03:00
Michael S2pac
5bd52eff0c Refactored entrypoint for 3xui container 2025-12-15 15:30:20 +03:00
Michael S2pac
8cadbb9057 Refactored xray-tools.sh 2025-12-13 18:40:37 +03:00
3 changed files with 20 additions and 22 deletions

View file

@ -1,19 +1,22 @@
#!/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"
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))
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))
done
if [ ! -f "$FINISH_FILE" ]; then
echo "ERROR: Geodata initialization timed out after $MAX_WAIT seconds"
echo "ERROR: Geodata initialization timed out after $MAX_GEODATA_DIR_WAIT seconds"
echo "Container startup aborted."
exit 1
fi

View file

@ -17,7 +17,6 @@ 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" \

View file

@ -126,24 +126,20 @@ 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"
cd "$OLD_DIR"
return 1
exit 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
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
fi
}
if [ "${0##*/}" = "xray-tools.sh" ]; then
@ -166,7 +162,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 1
exit 0
;;
*)
echo "Unknown command: $cmd" >&2