diff --git a/cmd/ipfs/daemon.go b/cmd/ipfs/daemon.go index 25b69b34065e..020a99a37576 100644 --- a/cmd/ipfs/daemon.go +++ b/cmd/ipfs/daemon.go @@ -233,20 +233,24 @@ func daemonFunc(req *cmds.Request, re cmds.ResponseEmitter, env cmds.Environment // first, whether user has provided the initialization flag. we may be // running in an uninitialized state. initialize, _ := req.Options[initOptionKwd].(bool) - if initialize && !fsrepo.IsInitialized(cctx.ConfigRoot) { - cfgLocation, _ := req.Options[initConfigOptionKwd].(string) - profiles, _ := req.Options[initProfileOptionKwd].(string) - var conf *config.Config + if initialize { + if fsrepo.IsInitialized(cctx.ConfigRoot) { + log.Warningf("repo is already initialized, nothing will be altered") + } else { + cfgLocation, _ := req.Options[initConfigOptionKwd].(string) + profiles, _ := req.Options[initProfileOptionKwd].(string) + var conf *config.Config + + if cfgLocation != "" { + if conf, err = cserial.Load(cfgLocation); err != nil { + return err + } + } - if cfgLocation != "" { - if conf, err = cserial.Load(cfgLocation); err != nil { + if err = doInit(os.Stdout, cctx.ConfigRoot, false, nBitsForKeypairDefault, profiles, conf); err != nil { return err } } - - if err = doInit(os.Stdout, cctx.ConfigRoot, false, nBitsForKeypairDefault, profiles, conf); err != nil { - return err - } } // acquire the repo lock _before_ constructing a node. we need to make