File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -25,33 +25,10 @@ echo "Starting vsock proxy..."
2525TIME_SYNC_URL=" http://127.0.0.1:27015/getCurrentTime"
2626TIME_SYNC_PROXY=" socks5h://127.0.0.1:3305"
2727
28- TIME_SYNC_OFFSET_SECONDS=" ${TIME_SYNC_OFFSET_SECONDS:- 30} "
29-
30- sync_enclave_time_with_offset_once () {
31- local current_time
32- local parent_epoch
33- if current_time=$( curl -s -f -x socks5h://127.0.0.1:3305 " ${TIME_SYNC_URL} " ) ; then
34- parent_epoch=$( date -u -d " ${current_time} " +%s 2> /dev/null || true)
35- if [[ -n " ${parent_epoch} " ]]; then
36- parent_epoch=$(( parent_epoch + TIME_SYNC_OFFSET_SECONDS))
37- if ! date -u -s " @${parent_epoch} " ; then
38- echo " Time sync: failed to set enclave time from '${current_time} ' with offset ${TIME_SYNC_OFFSET_SECONDS} s"
39- return 1
40- fi
41- echo " Time sync: updated enclave time to ${current_time} + ${TIME_SYNC_OFFSET_SECONDS} s"
42- fi
43- else
44- echo " Time sync: failed to fetch time from parent instance"
45- return 1
46- fi
47- }
48-
49- sync_enclave_time_with_offset_once || true
50-
5128install_time_sync_cron () {
5229 mkdir -p /etc/cron.d
5330 cat > /etc/cron.d/uid-time-sync << EOF
54- */5 * * * * root current_time=\$ (curl -sSf -x "${TIME_SYNC_PROXY} " "${TIME_SYNC_URL} ") && date -u -s "\$ {current_time}" && echo "Time sync: updated enclave time to \$ {current_time}"
31+ 0 0 * * * root current_time=\$ (curl -sSf -x "${TIME_SYNC_PROXY} " "${TIME_SYNC_URL} ") && date -u -s "\$ {current_time}" && echo "Time sync: updated enclave time to \$ {current_time}" >>/home/start.txt 2>&1
5532EOF
5633 chmod 0644 /etc/cron.d/uid-time-sync
5734 cron
You can’t perform that action at this time.
0 commit comments