94: init creates config, like tendermint init
This commit is contained in:
parent
c059e99f56
commit
da698bb7af
|
@ -6,10 +6,6 @@ import (
|
||||||
"path"
|
"path"
|
||||||
|
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
"github.com/spf13/viper"
|
|
||||||
|
|
||||||
"github.com/tendermint/tmlibs/cli"
|
|
||||||
cmn "github.com/tendermint/tmlibs/common"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
//commands
|
//commands
|
||||||
|
@ -35,14 +31,17 @@ func setupFile(path, data string, perm os.FileMode) (int, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func initCmd(cmd *cobra.Command, args []string) error {
|
func initCmd(cmd *cobra.Command, args []string) error {
|
||||||
rootDir := viper.GetString(cli.HomeFlag)
|
// this will ensure that config.toml is there if not yet created, and create dir
|
||||||
cmn.EnsureDir(rootDir, 0777)
|
cfg, err := getTendermintConfig()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
// initalize basecoin
|
// initalize basecoin
|
||||||
genesisFile := path.Join(rootDir, "genesis.json")
|
genesisFile := cfg.GenesisFile()
|
||||||
privValFile := path.Join(rootDir, "priv_validator.json")
|
privValFile := cfg.PrivValidatorFile()
|
||||||
key1File := path.Join(rootDir, "key.json")
|
key1File := path.Join(cfg.RootDir, "key.json")
|
||||||
key2File := path.Join(rootDir, "key2.json")
|
key2File := path.Join(cfg.RootDir, "key2.json")
|
||||||
|
|
||||||
mod1, err := setupFile(genesisFile, GenesisJSON, 0644)
|
mod1, err := setupFile(genesisFile, GenesisJSON, 0644)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
Loading…
Reference in New Issue