mirror of
https://github.com/Control-D-Inc/ctrld.git
synced 2026-03-13 10:26:06 +00:00
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:
committed by
Cuong Manh Le
parent
f3a3227f21
commit
1aa991298a
@@ -168,7 +168,7 @@ func initCLI() {
|
||||
// Processing --cd flag require connecting to ControlD API, which needs valid
|
||||
// time for validating server certificate. Some routers need NTP synchronization
|
||||
// to set the current time, so this check must happen before processCDFlags.
|
||||
if err := router.PreRun(); err != nil {
|
||||
if err := router.PreRun(svcConfig); err != nil {
|
||||
mainLog.Fatal().Err(err).Msg("failed to perform router pre-run check")
|
||||
}
|
||||
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user