all: support older version of Openwrt

This commit is contained in:
Cuong Manh Le
2023-06-07 23:48:41 +07:00
committed by Cuong Manh Le
parent 929de49c7b
commit 53f8d006f0
2 changed files with 12 additions and 1 deletions

View File

@@ -23,6 +23,16 @@ func IsGLiNet() bool {
return bytes.Contains(buf, []byte(" (glinet"))
}
// IsOldOpenwrt reports whether the router is an "old" version of Openwrt,
// aka versions which don't have "service" command.
func IsOldOpenwrt() bool {
if Name() != OpenWrt {
return false
}
cmd, _ := exec.LookPath("service")
return cmd == ""
}
func setupOpenWrt() error {
// Delete dnsmasq port if set.
if _, err := uci("delete", "dhcp.@dnsmasq[0].port"); err != nil && !errors.Is(err, errUCIEntryNotFound) {