mirror of
https://github.com/tailscale/tailscale.git
synced 2025-08-13 22:47:30 +00:00
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:

committed by
Brad Fitzpatrick

parent
bebc796e6c
commit
fbc6a9ec5a
@@ -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.
|
||||
|
@@ -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"
|
||||
|
Reference in New Issue
Block a user