cmd/tailscale/cli: add "configure jetkvm" subcommand

To write the init script.

And fix the JetKVM detection to work during early boot while the filesystem
and modules are still being loaded; it wasn't being detected on early boot
and then tailscaled was failing to start because it didn't know it was on JetKVM
and didn't modprobe tun.

Updates #16524

Change-Id: I0524ca3abd7ace68a69af96aab4175d32c07e116
Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
This commit is contained in:
Brad Fitzpatrick
2025-07-11 08:51:02 -07:00
committed by Brad Fitzpatrick
parent 04e8d21b0b
commit 30da2e1c32
3 changed files with 94 additions and 1 deletions

View File

@@ -9,6 +9,7 @@ import (
"os"
"runtime"
"strconv"
"strings"
"tailscale.com/types/lazy"
"tailscale.com/util/lineiter"
@@ -103,12 +104,20 @@ func linuxDistro() Distro {
return Unraid
case have("/etc/alpine-release"):
return Alpine
case haveDir("/userdata/jetkvm") && haveDir("/sys/kernel/config/usb_gadget/jetkvm"):
case runtime.GOARCH == "arm" && isDeviceModel("JetKVM"):
return JetKVM
}
return ""
}
func isDeviceModel(want string) bool {
if runtime.GOOS != "linux" {
return false
}
v, _ := os.ReadFile("/sys/firmware/devicetree/base/model")
return want == strings.Trim(string(v), "\x00\r\n\t ")
}
func freebsdDistro() Distro {
switch {
case have("/etc/pfSense-rc"):