@@ -21,9 +21,12 @@ until ntp_synchronized=$(timedatectl show --property=NTPSynchronized --value) &&
2121 if [ " ${retry} " -eq 0 ]; then
2222 # If /dev/rtc is not available, the system time set during the Linux kernel build is used.
2323 # 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+
2528 # 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 } ."
2730
2831 # To set the time to a specified time, it is necessary to stop systemd-timesyncd.
2932 systemctl stop systemd-timesyncd
@@ -35,8 +38,8 @@ until ntp_synchronized=$(timedatectl show --property=NTPSynchronized --value) &&
3538 sleep 1
3639 done
3740
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 } " )
4043 echo_with_time_usec " Setting the system time to ${modification_time} ."
4144 timedatectl set-time " ${modification_time} "
4245
0 commit comments