Skip to content

Commit 3dfd4c7

Browse files
committed
fix: wrap NTP check in set +e/set -e to prevent container crash loop
Made-with: Cursor
1 parent 9e89197 commit 3dfd4c7

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

development/qnet-integration/Dockerfile.production

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,14 +73,15 @@ echo "━━━━━━━━━━━━━━━━━━━━━━━━
7373
echo "⚠️ RUN ON HOST: sudo ufw allow 9876,9877,8001/tcp && sudo ufw allow 10876/udp"\n\
7474
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"\n\
7575
echo ""\n\
76+
set +e\n\
7677
echo "🕐 Checking host time synchronization..."\n\
7778
LOCAL_TIME=$(date +%s)\n\
7879
NTP_SYNCED=$(timedatectl show 2>/dev/null | grep "NTPSynchronized=yes")\n\
7980
if [ -n "$NTP_SYNCED" ]; then\n\
8081
echo " ✅ Host clock synchronized (systemd-timesyncd active)"\n\
8182
else\n\
82-
REMOTE_TIME=$(curl -s --max-time 5 http://time.google.com/gtimes 2>/dev/null | grep -o "[0-9]\{10\}" | head -1 || echo "0")\n\
83-
if [ "$REMOTE_TIME" != "0" ] && [ "$REMOTE_TIME" != "" ]; then\n\
83+
REMOTE_TIME=$(curl -s --max-time 5 http://time.google.com/gtimes 2>/dev/null | grep -o "[0-9]\{10\}" | head -1)\n\
84+
if [ -n "$REMOTE_TIME" ] && [ "$REMOTE_TIME" != "0" ]; then\n\
8485
DRIFT=$((LOCAL_TIME > REMOTE_TIME ? LOCAL_TIME - REMOTE_TIME : REMOTE_TIME - LOCAL_TIME))\n\
8586
if [ "$DRIFT" -gt 30 ]; then\n\
8687
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"\n\
@@ -96,6 +97,7 @@ else\n\
9697
fi\n\
9798
fi\n\
9899
echo ""\n\
100+
set -e\n\
99101
\n\
100102
if [ "$(id -u)" = "0" ]; then\n\
101103
echo "Checking data directory: $DATA_DIR"\n\

0 commit comments

Comments
 (0)