mirror of
https://github.com/Control-D-Inc/ctrld.git
synced 2026-07-04 01:07:49 +02: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"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
"strings"
|
||||||
"sync/atomic"
|
"sync/atomic"
|
||||||
|
|
||||||
"github.com/kardianos/service"
|
"github.com/kardianos/service"
|
||||||
@@ -164,6 +165,16 @@ func HomeDir() (string, error) {
|
|||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
return filepath.Dir(exe), nil
|
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
|
return "", nil
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user