mirror of
https://github.com/Control-D-Inc/ctrld.git
synced 2026-02-03 22:18:39 +00:00
all: do not depend on vyatta-dhcpd service on EdgeOS
The only reason that forces ctrld to depend on vyatta-dhcpd service on EdgeOS is allowing ctrld to watch lease files properly, because those files may not be created at the time client info table initialized. However, on some EdgeOS version, vyatta-dhcpd could not start with an empty config file, causing restart loop itself, flooding systemd log, making the router run out of memory. To fix this, instead of depending on vyatta-dhcpd, we should just watch for lease files creation, then adding them to watch list. While at it, also making ctrld starts after nss-lookup, ensuring we have a working DNS before starting ctrld.
This commit is contained in:
committed by
Cuong Manh Le
parent
13391fd469
commit
126477ef88
@@ -169,6 +169,13 @@ func ContentFilteringEnabled() bool {
|
||||
return err == nil && !st.IsDir()
|
||||
}
|
||||
|
||||
func LeaseFileDir() string {
|
||||
if checkUSG() {
|
||||
return ""
|
||||
}
|
||||
return "/run"
|
||||
}
|
||||
|
||||
func checkUSG() bool {
|
||||
out, _ := exec.Command("mca-cli-op", "info").Output()
|
||||
return bytes.Contains(out, []byte("UniFi-Gateway-"))
|
||||
|
||||
@@ -173,20 +173,6 @@ func CanListenLocalhost() bool {
|
||||
}
|
||||
}
|
||||
|
||||
// ServiceDependencies returns list of dependencies that ctrld services needs on this router.
|
||||
// See https://pkg.go.dev/github.com/kardianos/service#Config for list format.
|
||||
func ServiceDependencies() []string {
|
||||
if Name() == edgeos.Name {
|
||||
// On EdeOS, ctrld needs to start after vyatta-dhcpd, so it can read leases file.
|
||||
return []string{
|
||||
"Wants=vyatta-dhcpd.service",
|
||||
"After=vyatta-dhcpd.service",
|
||||
"Wants=dnsmasq.service",
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// SelfInterfaces return list of *net.Interface that will be source of requests from router itself.
|
||||
func SelfInterfaces() []*net.Interface {
|
||||
switch Name() {
|
||||
@@ -197,6 +183,14 @@ func SelfInterfaces() []*net.Interface {
|
||||
}
|
||||
}
|
||||
|
||||
// LeaseFilesDir is the directory which contains lease files.
|
||||
func LeaseFilesDir() string {
|
||||
if Name() == edgeos.Name {
|
||||
edgeos.LeaseFileDir()
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func distroName() string {
|
||||
switch {
|
||||
case bytes.HasPrefix(unameO(), []byte("DD-WRT")):
|
||||
|
||||
Reference in New Issue
Block a user