Initializes ipfs configuration files and generates a
new keypair.
`,
Run:func(rescmds.Response,reqcmds.Request){
ctx:=req.Context()
u.POut("initializing ipfs node at %s\n",ctx.ConfigRoot)
filename,err:=config.Filename(ctx.ConfigRoot)
iferr!=nil{
res.SetError(errors.New("Couldn't get home directory path"),cmds.ErrNormal)
return
}
arg,found:=req.Option("d")
dspath,ok:=arg.(string)
iffound&&!ok{
res.SetError(errors.New("failed to parse datastore flag"),cmds.ErrNormal)
return
}
fi,err:=os.Lstat(filename)
arg,found=req.Option("f")
force,ok:=arg.(bool)
iffound&&!ok{
res.SetError(errors.New("failed to parse force flag"),cmds.ErrNormal)
return
}
iffi!=nil||(err!=nil&&!os.IsNotExist(err)){
if!force{
res.SetError(errors.New("ipfs configuration file already exists!\nReinitializing would overwrite your keys.\n(use -f to force overwrite)"),cmds.ErrNormal)