This repository has been archived by the owner on Jan 19, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 33
/
quorum-init
executable file
·103 lines (88 loc) · 2.28 KB
/
quorum-init
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
#!/usr/bin/env ruby
require "yaml"
require "erb"
require 'optparse'
# set up flag options
options = {action: 'ask'}
OptionParser.new do |opts|
opts.banner = "Usage: ./quorum-init [options]"
opts.on("-a", "--action [ACTION]", String,
"create: override out directory and generate new resources.
update: keep out directory and only add additional resources.") do |a|
options[:action] = a
end
opts.on("-h", "--help", "prints this help.") do
puts opts
exit
end
end.parse!
# setup the config file to use to generate the quorum resources and kubernetes API resources.
@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)
# decide to create new resources
action = options[:action]
createNew=false
if (action == 'create')
createNew=true
end
if File.directory?("out") && (action == 'ask')
puts("\n The 'out' directory already exist.")
puts(" Please select the action you wish to take:")
puts("")
puts(" [1] Delete the 'out' directory and generate new resources.")
puts(" [2] Update / add nodes that don't already exist.")
puts(" [3] Cancel.")
res = gets
res = res.strip
case res
when "1"
puts("Creating all new resources.")
createNew=true
when "2"
puts("Generating additional resources only.")
action = 'update'
when "3"
puts("OK, bye :)")
exit(0)
else
puts("OK, not doing anything :)")
exit(0)
end
end
# delete out directory if creating new
if createNew
`rm -r -f out`
end
`
# create the output directory if
# it doesn't exist
mkdir -p out/config
# generate the nodes.yaml
# file for the set number of
# nodes.
# DEPRECATED
#./quorum-create-nodes #{@config_file}
`
puts ""
puts " Generating keys..."
`
# generate the keygen script
# to generate nodekey, account keys, and
# quorum transaction manager (tm.pub,tm.key) keys.
./quorum-keygen #{@config_file}
`
puts " Generating Quorum configs..."
`
# generate the appropriate config files:
# permissioned-nodes.json
# genesis.json
./quorum-config #{@config_file} --action=#{action}
`
puts ""
puts " Base quorum resources have been generated. "