-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathsetup-aurad-status.py
executable file
·74 lines (49 loc) · 1.83 KB
/
setup-aurad-status.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
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
#!/usr/bin/env python3
import json
def boolToString(b):
if b == True:
return "Yes"
else:
return "No"
auto_restart = False
wait_before_restart = 0
rpc = ""
download_latest = False
print("\n--- aurad-status setup\n")
inp = input("Do you want to restart your node automatically when it goes offline? [Y/N]: ")
if inp == "Y" or inp == "y":
auto_restart = True
inp = input("Enter the time in seconds your node must be offline before restarting. Please use at least 60: ")
if not inp.isdigit():
print("Invalid input")
exit()
else:
wait_before_restart = int(inp)
if wait_before_restart < 60:
print("Timeout before restart must be at least 60 seconds. Exiting.")
exit()
rpc = input("Enter the RPC you want to use (for example \"https://mainnet.infura.io/v3/<API KEY>\"). Leave empty for default: ")
inp = input("Download the latest version when automatically restarting? [Y/N]: ")
if inp == "Y" or inp == "y":
download_latest = True
print("\nSaving the following settings:\n")
print("Automatic restart when node goes offline: " + boolToString(auto_restart))
if auto_restart:
print("Time to wait before restarting: " + str(wait_before_restart) + " seconds")
print("RPC to use: " + str(rpc))
print("Download latest version on restart: " + boolToString(download_latest))
inp = input("\nIs that correct? [Y/N]: ")
if inp == "Y" or inp == "y":
jobj = {}
jobj["auto_restart"] = auto_restart
jobj["wait_before_restart"] = wait_before_restart
jobj["rpc"] = rpc
jobj["download_latest"] = download_latest
try:
with open('aurad-status-settings.json', 'w') as f:
json.dump(jobj, f)
except:
print("Could not write settings to disk. Please make sure you have write permissions in this directory.")
print("\nSettings saved. You can now run ./aurad-status.py")
else:
print("\nAborted. No settings were changed.")