mirror of
https://github.com/netbirdio/netbird.git
synced 2025-08-21 03:40:01 +02:00
[client] make /var/lib/netbird paths configurable (#3084)
- NB_STATE_DIR - NB_UNCLEAN_SHUTDOWN_RESOLV_FILE - NB_DNS_STATE_FILE
This commit is contained in:
committed by
GitHub
parent
8154069e77
commit
522dd44bfa
@@ -1,23 +1,16 @@
|
||||
package statemanager
|
||||
|
||||
import (
|
||||
"github.com/netbirdio/netbird/client/configs"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
)
|
||||
|
||||
// GetDefaultStatePath returns the path to the state file based on the operating system
|
||||
// It returns an empty string if the path cannot be determined.
|
||||
func GetDefaultStatePath() string {
|
||||
switch runtime.GOOS {
|
||||
case "windows":
|
||||
return filepath.Join(os.Getenv("PROGRAMDATA"), "Netbird", "state.json")
|
||||
case "darwin", "linux":
|
||||
return "/var/lib/netbird/state.json"
|
||||
case "freebsd", "openbsd", "netbsd", "dragonfly":
|
||||
return "/var/db/netbird/state.json"
|
||||
if path := os.Getenv("NB_DNS_STATE_FILE"); path != "" {
|
||||
return path
|
||||
}
|
||||
|
||||
return ""
|
||||
|
||||
return filepath.Join(configs.StateDir, "state.json")
|
||||
}
|
||||
|
Reference in New Issue
Block a user