Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
dms3
go-dms3
Commits
70819671
Commit
70819671
authored
Mar 08, 2015
by
Henry
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cleaned up 'ipfs init'
parent
d88ba193
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
9 deletions
+16
-9
cmd/ipfs/init.go
cmd/ipfs/init.go
+16
-9
No files found.
cmd/ipfs/init.go
View file @
70819671
...
...
@@ -28,7 +28,6 @@ var initCmd = &cmds.Command{
Options
:
[]
cmds
.
Option
{
cmds
.
IntOption
(
"bits"
,
"b"
,
"Number of bits to use in the generated RSA private key (defaults to 4096)"
),
cmds
.
StringOption
(
"passphrase"
,
"p"
,
"Passphrase for encrypting the private key"
),
cmds
.
BoolOption
(
"force"
,
"f"
,
"Overwrite existing config (if it exists)"
),
// TODO need to decide whether to expose the override as a file or a
...
...
@@ -49,6 +48,7 @@ var initCmd = &cmds.Command{
res
.
SetError
(
err
,
cmds
.
ErrNormal
)
return
}
if
!
bitsOptFound
{
nBitsForKeypair
=
nBitsForKeypairDefault
}
...
...
@@ -75,28 +75,26 @@ func initWithDefaults(out io.Writer, repoRoot string) error {
return
debugerror
.
Wrap
(
err
)
}
func
writef
(
out
io
.
Writer
,
format
string
,
ifs
...
interface
{})
error
{
_
,
err
:=
out
.
Write
([]
byte
(
fmt
.
Sprintf
(
format
,
ifs
...
)))
return
err
}
func
doInit
(
out
io
.
Writer
,
repoRoot
string
,
force
bool
,
nBitsForKeypair
int
)
error
{
if
err
:=
write
f
(
out
,
"initializing ipfs node at %s
\n
"
,
repoRoot
);
err
!=
nil
{
if
_
,
err
:=
fmt
.
Fprint
f
(
out
,
"initializing ipfs node at %s
\n
"
,
repoRoot
);
err
!=
nil
{
return
err
}
if
fsrepo
.
IsInitialized
(
repoRoot
)
&&
!
force
{
return
errRepoExists
}
conf
,
err
:=
config
.
Init
(
out
,
nBitsForKeypair
)
if
err
!=
nil
{
return
err
}
if
fsrepo
.
IsInitialized
(
repoRoot
)
{
if
err
:=
fsrepo
.
Remove
(
repoRoot
);
err
!=
nil
{
return
err
}
}
if
err
:=
fsrepo
.
Init
(
repoRoot
,
conf
);
err
!=
nil
{
return
err
}
...
...
@@ -111,10 +109,12 @@ func doInit(out io.Writer, repoRoot string, force bool, nBitsForKeypair int) err
func
addDefaultAssets
(
out
io
.
Writer
,
repoRoot
string
)
error
{
ctx
,
cancel
:=
context
.
WithCancel
(
context
.
Background
())
defer
cancel
()
r
:=
fsrepo
.
At
(
repoRoot
)
if
err
:=
r
.
Open
();
err
!=
nil
{
// NB: repo is owned by the node
return
err
}
nd
,
err
:=
core
.
NewIPFSNode
(
ctx
,
core
.
Offline
(
r
))
if
err
!=
nil
{
return
err
...
...
@@ -130,6 +130,7 @@ func addDefaultAssets(out io.Writer, repoRoot string) error {
if
err
!=
nil
{
return
err
}
k
:=
u
.
B58KeyDecode
(
s
)
if
err
:=
dirb
.
AddChild
(
fname
,
k
);
err
!=
nil
{
return
err
...
...
@@ -141,15 +142,21 @@ func addDefaultAssets(out io.Writer, repoRoot string) error {
if
err
!=
nil
{
return
err
}
if
err
:=
nd
.
Pinning
.
Pin
(
dir
,
true
);
err
!=
nil
{
return
err
}
if
err
:=
nd
.
Pinning
.
Flush
();
err
!=
nil
{
return
err
}
writef
(
out
,
"to get started, enter:
\n
"
)
return
writef
(
out
,
"
\n\t
ipfs cat /ipfs/%s/readme
\n\n
"
,
dkey
)
if
_
,
err
=
fmt
.
Fprintf
(
out
,
"to get started, enter:
\n
"
);
err
!=
nil
{
return
err
}
_
,
err
=
fmt
.
Fprintf
(
out
,
"
\n\t
ipfs cat /ipfs/%s/readme
\n\n
"
,
dkey
)
return
err
}
func
initializeIpnsKeyspace
(
repoRoot
string
)
error
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment