@@ -21,9 +21,12 @@ until ntp_synchronized=$(timedatectl show --property=NTPSynchronized --value) &&
21
21
if [ " ${retry} " -eq 0 ]; then
22
22
# If /dev/rtc is not available, the system time set during the Linux kernel build is used.
23
23
# The larger the difference between this system time and the NTP server time, the longer the NTP synchronization will take.
24
- # By setting the system time to the modification time of this script, which is likely to be closer to the actual time,
24
+ # By setting the system time to the modification time of the reference file, which is likely to be closer to the actual time,
25
+ reference_file=" ${LIMA_CIDATA_MNT:-/ mnt/ lima-cidata} /user-data"
26
+ [ -f " ${reference_file} " ] || reference_file=" ${0} "
27
+
25
28
# the NTP synchronization time can be shortened.
26
- echo_with_time_usec " Setting the system time to the modification time of ${0 } ."
29
+ echo_with_time_usec " Setting the system time to the modification time of ${reference_file } ."
27
30
28
31
# To set the time to a specified time, it is necessary to stop systemd-timesyncd.
29
32
systemctl stop systemd-timesyncd
@@ -35,8 +38,8 @@ until ntp_synchronized=$(timedatectl show --property=NTPSynchronized --value) &&
35
38
sleep 1
36
39
done
37
40
38
- # Set the system time to the modification time of this script .
39
- modification_time=$( stat -c %y " ${0 } " )
41
+ # Set the system time to the modification time of the reference file .
42
+ modification_time=$( stat -c %y " ${reference_file } " )
40
43
echo_with_time_usec " Setting the system time to ${modification_time} ."
41
44
timedatectl set-time " ${modification_time} "
42
45
0 commit comments