Commit 408e1292 authored by Alexander Kutelev's avatar Alexander Kutelev Committed by Alexander Kutelev

Check either ntpdate command exists or not before trying to execute it.

parent 61542f2b
......@@ -160,15 +160,15 @@ func (s *executor) updateGuestTime() error {
timeServer = "time.apple.com"
}
err := prl.TryExec(s.vmName, 20, "sudo", "ntpdate", "-u", timeServer)
// Check either ntpdate command exists or not before trying to execute it
// Starting from Mojave ntpdate was removed
_, err := prl.Exec(s.vmName, "which", "ntpdate")
if err != nil {
s.Debugln("Could not run ntpdate command. Trying the sntp command instead...")
err = prl.TryExec(s.vmName, 20, "sudo", "sntp", "-S", timeServer)
if err != nil {
return err
}
// Fallback to sntp
return prl.TryExec(s.vmName, 20, "sudo", "sntp", "-sS", timeServer)
}
return nil
return prl.TryExec(s.vmName, 20, "sudo", "ntpdate", "-u", timeServer)
}
func (s *executor) Prepare(options common.ExecutorPrepareOptions) error {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment