Skip to content

Commit 550f0de

Browse files
committed
Add test
1 parent 3de24ae commit 550f0de

1 file changed

Lines changed: 25 additions & 1 deletion

File tree

scripts/aws/entrypoint.sh

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,30 @@ TIME_SYNC_URL="http://127.0.0.1:27015/getCurrentTime"
2626
TIME_SYNC_PROXY="socks5h://127.0.0.1:3305"
2727
TIME_SYNC_INTERVAL_SECONDS="300"
2828

29+
TIME_SYNC_OFFSET_SECONDS="${TIME_SYNC_OFFSET_SECONDS:-30}"
30+
31+
sync_enclave_time_with_offset_once() {
32+
local current_time
33+
local parent_epoch
34+
if current_time=$(curl -s -f -x socks5h://127.0.0.1:3305 "${TIME_SYNC_URL}"); then
35+
parent_epoch=$(date -u -d "${current_time}" +%s 2>/dev/null || true)
36+
if [[ -n "${parent_epoch}" ]]; then
37+
parent_epoch=$((parent_epoch + TIME_SYNC_OFFSET_SECONDS))
38+
if ! date -u -s "@${parent_epoch}"; then
39+
echo "Time sync: failed to set enclave time from '${current_time}' with offset ${TIME_SYNC_OFFSET_SECONDS}s"
40+
return 1
41+
fi
42+
echo "Time sync: updated enclave time to ${current_time} + ${TIME_SYNC_OFFSET_SECONDS}s"
43+
fi
44+
else
45+
echo "Time sync: failed to fetch time from parent instance"
46+
return 1
47+
fi
48+
}
49+
50+
sync_enclave_time_with_offset_once || true
51+
52+
2953
enable_time_sync_timer() {
3054
if ! command -v systemctl >/dev/null 2>&1 || [[ ! -d /run/systemd/system ]]; then
3155
echo "Time sync: systemd not available; skipping timer setup" >&2
@@ -48,7 +72,7 @@ EOF
4872
Description=UID2 enclave time sync timer
4973
5074
[Timer]
51-
OnBootSec=30s
75+
OnBootSec=300s
5276
OnUnitActiveSec=${TIME_SYNC_INTERVAL_SECONDS}s
5377
Unit=uid2-time-sync.service
5478
Persistent=true

0 commit comments

Comments
 (0)