forked from Consensys/qubernetes
-
Notifications
You must be signed in to change notification settings - Fork 0
/
quorum-create-nodes
executable file
·41 lines (34 loc) · 1.05 KB
/
quorum-create-nodes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/usr/bin/env ruby
require "yaml"
require "erb"
# setup up default config, or get passed in config to use.
@CONFIG_FILE = "qubernetes.yaml"
@OPTIONAL_CONFIG_FILE=ARGV[0]
ARGV.clear
if @OPTIONAL_CONFIG_FILE != nil
@CONFIG_FILE = @OPTIONAL_CONFIG_FILE
end
puts "using config file: " + @CONFIG_FILE
@config = YAML.load_file(@CONFIG_FILE)
# if nodes.yaml exists already, only append from last number, nodes will monotonically increase in number.
# Read in nodes.yaml if it exists.
@Node_File="out/config/nodes.yaml"
if File.file?(@Node_File)
puts "node file exists!!"
@node_config = YAML.load_file(@Node_File)
@nodes = @node_config["nodes"]
puts @nodes.length
@nodes.each do |node|
puts node.values.first["Node_UserIdent"]
end
# TODO: pass in len + 1 to nodes.yaml.erb
else
# else write the whole file in.
puts "doesn't exist will create"
File.open(@Node_File, "w") do |f|
f.puts (ERB.new(File.read("nodes.yaml.erb"), nil, "-").result)
end
end
# update sym link in home directory.
`rm nodes.yaml | true`
`ln -s out/config/nodes.yaml .`