diff --git a/plugins/timesync.koplugin/main.lua b/plugins/timesync.koplugin/main.lua index ec972fdc7..f1d2006f9 100644 --- a/plugins/timesync.koplugin/main.lua +++ b/plugins/timesync.koplugin/main.lua @@ -12,8 +12,18 @@ end local ntp_cmd -- Check if we have access to ntpd or ntpdate if os.execute("command -v ntpd >/dev/null") == 0 then - ntp_cmd = "ntpd -q -n -p pool.ntp.org" -elseif os.execute("command -v ntpdate >/dev/null") == 0 then + -- Make sure it's actually busybox's implementation, as the syntax may otherwise differ... + -- (Of particular note, Kobo ships busybox ntpd, but not ntpdate; and Kindle ships ntpdate and !busybox ntpd). + local path = os.getenv("PATH") or "" + for p in path:gmatch("([^:]+)") do + local sym = lfs.symlinkattributes(p .. "/ntpd") + if sym and sym.mode == "link" and string.sub(sym.target, -7) == "busybox" then + ntp_cmd = "ntpd -q -n -p pool.ntp.org" + break + end + end +end +if not ntp_cmd and os.execute("command -v ntpdate >/dev/null") == 0 then ntp_cmd = "ntpdate pool.ntp.org" end if not ntp_cmd then