-
Notifications
You must be signed in to change notification settings - Fork 1
/
config.py
45 lines (38 loc) · 1.32 KB
/
config.py
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
# !/bin/python3
import json
import sys
import re
harvester_key = ""
harvester_vrf = ""
node_name = ""
with open('./config.json', 'r') as f:
data = json.load(f)
harvester_key = data["harvesterKey"]
harvester_vrf = data["harvesterVrfKey"]
node_name = data["nodeName"]
params_to_replace = [
{"name": "harvesterSigningPrivateKey =", "param": harvester_key,
"file": "core-node/config/resources/config-harvesting.properties"},
{"name": "harvesterVrfPrivateKey =", "param": harvester_vrf,
"file": "core-node/config/resources/config-harvesting.properties"},
{"name": "friendlyName =", "param": node_name,
"file": "core-node/config/resources/config-node.properties"}]
for param in params_to_replace:
new_param = "{} {}".format(
param["name"], param["param"])
f = open(param["file"], 'r')
filedata = f.read()
f.close()
newdata = re.sub(
r'(?<={})[^\n\s]*'.format(param["name"]), param["param"], filedata)
print(newdata)
f = open(param["file"], 'w')
f.write(newdata)
f.close()
with open('rest/rest.json', 'r') as f:
data = json.load(f)
# other rest options here
data["db"]["url"] = "mongodb://172.28.1.2:27017/"
data["apiNode"]["host"] = "172.28.1.1"
with open('rest/rest.json', 'w') as jsonfile:
json.dump(data, jsonfile, indent=4)