all: implement router setup for ubios

This commit is contained in:
Cuong Manh Le
2023-05-13 11:59:14 +07:00
committed by Cuong Manh Le
parent a5443d5ca4
commit f5ef9b917e
5 changed files with 402 additions and 10 deletions
+22
View File
@@ -1,7 +1,9 @@
package router
import (
"bytes"
"os"
"os/exec"
"github.com/kardianos/service"
)
@@ -26,6 +28,26 @@ func init() {
},
new: newMerlinService,
},
&linuxSystemService{
name: "ubios",
detect: func() bool {
if Name() != Ubios {
return false
}
out, err := exec.Command("ubnt-device-info", "firmware").CombinedOutput()
if err == nil {
// For v2/v3, UbiOS use a Debian base with systemd, so it is not
// necessary to use custom implementation for supporting init system.
return bytes.HasPrefix(out, []byte("1."))
}
return true
},
interactive: func() bool {
is, _ := isInteractive()
return is
},
new: newUbiosService,
},
}
systems = append(systems, service.AvailableSystems()...)
service.ChooseSystem(systems...)