mirror of
https://github.com/idanoo/autobrr
synced 2025-07-23 08:49:13 +00:00
feat(config): detect container runtime (#324)
* feat(config): add container detection capabilities
This commit is contained in:
parent
aa94962dfd
commit
f74b348b26
1 changed files with 11 additions and 1 deletions
|
@ -7,6 +7,7 @@ import (
|
|||
"path"
|
||||
"path/filepath"
|
||||
"sync"
|
||||
"strings"
|
||||
|
||||
"github.com/autobrr/autobrr/internal/domain"
|
||||
"github.com/autobrr/autobrr/internal/logger"
|
||||
|
@ -36,6 +37,15 @@ func writeConfig(configPath string, configFile string) error {
|
|||
return err
|
||||
}
|
||||
|
||||
host := "127.0.0.1"
|
||||
if pd, _ := os.Open("/proc/1/cgroup"); pd != nil {
|
||||
defer pd.Close()
|
||||
b := make([]byte, 4096, 4096)
|
||||
pd.Read(b)
|
||||
if strings.Contains(string(b), "/docker") || strings.Contains(string(b), "/lxc") {
|
||||
host = "0.0.0.0"
|
||||
}
|
||||
}
|
||||
defer f.Close()
|
||||
|
||||
_, err = f.WriteString(`# config.toml
|
||||
|
@ -44,7 +54,7 @@ func writeConfig(configPath string, configFile string) error {
|
|||
#
|
||||
# Default: "localhost"
|
||||
#
|
||||
host = "127.0.0.1"
|
||||
host = "` + host + `"
|
||||
|
||||
# Port
|
||||
#
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue