diff --git a/cmd/ipfs/daemon.go b/cmd/ipfs/daemon.go index 88fa1f508..be74e8243 100644 --- a/cmd/ipfs/daemon.go +++ b/cmd/ipfs/daemon.go @@ -24,7 +24,7 @@ var Daemon = &cmds.Command{ } func daemonFunc(req cmds.Request, res cmds.Response) { - configPath, err := getConfigPath(req) + configPath, err := getConfigRoot(req) if err != nil { res.SetError(err, cmds.ErrNormal) return diff --git a/cmd/ipfs/ipfs.go b/cmd/ipfs/ipfs.go index dbff801ed..87d331986 100644 --- a/cmd/ipfs/ipfs.go +++ b/cmd/ipfs/ipfs.go @@ -67,6 +67,22 @@ func main() { } } + configPath, err := getConfigRoot(options) + if err != nil { + fmt.Println(err) + os.Exit(1) + } + + conf, err := getConfig(configPath) + if err != nil { + fmt.Println(err) + os.Exit(1) + } + + ctx := req.Context() + ctx.ConfigRoot = configPath + ctx.Config = conf + var res cmds.Response if root == Root { res = root.Call(req) @@ -74,12 +90,6 @@ func main() { } else { local := true - configPath, err := getConfigPath(options) - if err != nil { - fmt.Println(err) - os.Exit(1) - } - lockFilePath, err := config.Path(configPath, DaemonLockFile) if err != nil { fmt.Println(err) @@ -138,7 +148,7 @@ func getOptions(req cmds.Request, root *cmds.Command) (cmds.Request, error) { return tempReq, nil } -func getConfigPath(req cmds.Request) (string, error) { +func getConfigRoot(req cmds.Request) (string, error) { if opt, found := req.Option("config"); found { return opt.(string), nil }