mirror of
https://github.com/AlexxIT/go2rtc.git
synced 2025-12-24 12:57:56 +08:00
Read from credential files
See https://systemd.io/CREDENTIALS/. This will also work for Docker Secrets by setting `CREDENTIALS_DIRECTORY=/run/secrets`.
This commit is contained in:
@@ -3,6 +3,7 @@ package shell
|
||||
import (
|
||||
"os"
|
||||
"os/signal"
|
||||
"path/filepath"
|
||||
"regexp"
|
||||
"strings"
|
||||
"syscall"
|
||||
@@ -51,6 +52,13 @@ func ReplaceEnvVars(text string) string {
|
||||
dok = true
|
||||
}
|
||||
|
||||
if dir, vok := os.LookupEnv("CREDENTIALS_DIRECTORY"); vok {
|
||||
value, err := os.ReadFile(filepath.Join(dir, key))
|
||||
if err == nil {
|
||||
return strings.TrimSpace(string(value))
|
||||
}
|
||||
}
|
||||
|
||||
if value, vok := os.LookupEnv(key); vok {
|
||||
return value
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user