mirror of
https://github.com/Control-D-Inc/ctrld.git
synced 2026-02-03 22:18:39 +00:00
internal/router: change default config directory on EdgeOS
So ctrld's own files will survive firmware upgrades.
This commit is contained in:
committed by
Cuong Manh Le
parent
c24589a5be
commit
b3eebb19b6
@@ -7,6 +7,7 @@ import (
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"sync/atomic"
|
||||
|
||||
"github.com/kardianos/service"
|
||||
@@ -164,6 +165,16 @@ func HomeDir() (string, error) {
|
||||
return "", err
|
||||
}
|
||||
return filepath.Dir(exe), nil
|
||||
case edgeos.Name:
|
||||
exe, err := os.Executable()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
// Using binary directory as home dir if it is located in /config.
|
||||
// Otherwise, fallback to old behavior for compatibility.
|
||||
if strings.HasPrefix(exe, "/config/") {
|
||||
return filepath.Dir(exe), nil
|
||||
}
|
||||
}
|
||||
return "", nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user