all: cleaning up router before waiting ntp synchronization

On some Merlin routers reported by users, ctrld some how is not stopped
properly. So the router does not have a working DNS at boot time to do
ntp synchronization.

To fix it, just clean up the router before start waiting for ntp ready.
This commit is contained in:
Cuong Manh Le authored and Cuong Manh Le committed 2023-08-09 23:54:23 +07:00
1 parent f3a3227f21
commit 1aa991298a
2 files changed
+6 -3

No files matched your search

+5 -2
View File
@@ -127,10 +127,13 @@ func ConfigureService(sc *service.Config) error {
}
// PreRun blocks until the router is ready for running ctrld.
func PreRun() (err error) {
func PreRun(svc *service.Config) (err error) {
// On some routers, NTP may out of sync, so waiting for it to be ready.
switch Name() {
case Merlin, Tomato:
case DDWrt, Merlin, Tomato:
// Cleanup router to ensure valid DNS for NTP synchronization.
_ = Cleanup(svc)
// Wait until `ntp_ready=1` set.
b := backoff.NewBackoff("PreRun", func(format string, args ...any) {}, 10*time.Second)
for {