Skip to content

Commit e1c66a8

Browse files
authored
[client] Fix profile directory path handling based on NB_STATE_DIR (#4229)
[client] Fix profile directory path handling based on NB_STATE_DIR (#4229)
1 parent d89e615 commit e1c66a8

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

client/internal/profilemanager/service.go

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,18 @@ func init() {
3434
DefaultConfigPathDir = "/var/lib/netbird/"
3535
oldDefaultConfigPathDir = "/etc/netbird/"
3636

37-
switch runtime.GOOS {
38-
case "windows":
39-
oldDefaultConfigPathDir = filepath.Join(os.Getenv("PROGRAMDATA"), "Netbird")
40-
DefaultConfigPathDir = oldDefaultConfigPathDir
41-
42-
case "freebsd":
43-
oldDefaultConfigPathDir = "/var/db/netbird/"
44-
DefaultConfigPathDir = oldDefaultConfigPathDir
37+
if stateDir := os.Getenv("NB_STATE_DIR"); stateDir != "" {
38+
DefaultConfigPathDir = stateDir
39+
} else {
40+
switch runtime.GOOS {
41+
case "windows":
42+
oldDefaultConfigPathDir = filepath.Join(os.Getenv("PROGRAMDATA"), "Netbird")
43+
DefaultConfigPathDir = oldDefaultConfigPathDir
44+
45+
case "freebsd":
46+
oldDefaultConfigPathDir = "/var/db/netbird/"
47+
DefaultConfigPathDir = oldDefaultConfigPathDir
48+
}
4549
}
4650

4751
oldDefaultConfigPath = filepath.Join(oldDefaultConfigPathDir, "config.json")

0 commit comments

Comments
 (0)