all: detect JetKVM and specialize a handful of things for it

Updates #16524

Change-Id: I183428de8c65d7155d82979d2d33f031c22e3331
Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
This commit is contained in:
Brad Fitzpatrick
2025-07-10 11:14:08 -07:00
committed by Brad Fitzpatrick
parent bebc796e6c
commit fbc6a9ec5a
10 changed files with 89 additions and 12 deletions

View File

@@ -6,6 +6,7 @@
package paths
import (
"log"
"os"
"path/filepath"
"runtime"
@@ -70,6 +71,37 @@ func DefaultTailscaledStateFile() string {
return ""
}
// DefaultTailscaledStateDir returns the default state directory
// to use for tailscaled, for use when the user provided neither
// a state directory or state file path to use.
//
// It returns the empty string if there's no reasonable default.
func DefaultTailscaledStateDir() string {
if runtime.GOOS == "plan9" {
home, err := os.UserHomeDir()
if err != nil {
log.Fatalf("failed to get home directory: %v", err)
}
return filepath.Join(home, "tailscale-state")
}
return filepath.Dir(DefaultTailscaledStateFile())
}
// MakeAutomaticStateDir reports whether the platform
// automatically creates the state directory for tailscaled
// when it's absent.
func MakeAutomaticStateDir() bool {
switch runtime.GOOS {
case "plan9":
return true
case "linux":
if distro.Get() == distro.JetKVM {
return true
}
}
return false
}
// MkStateDir ensures that dirPath, the daemon's configuration directory
// containing machine keys etc, both exists and has the correct permissions.
// We want it to only be accessible to the user the daemon is running under.

View File

@@ -21,6 +21,9 @@ func init() {
}
func statePath() string {
if runtime.GOOS == "linux" && distro.Get() == distro.JetKVM {
return "/userdata/tailscale/var/tailscaled.state"
}
switch runtime.GOOS {
case "linux", "illumos", "solaris":
return "/var/lib/tailscale/tailscaled.state"