-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup
executable file
·207 lines (160 loc) · 5.56 KB
/
setup
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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
#!/bin/bash
pause(){
read -p "Press [Enter] key to continue..." fackEnterKey
}
setup_witness(){
echo -en "\nEnter your BRAVO username: "
read username
if [ ${#username} -le 2 ];
then echo "Username must be > 2 characters";
exit
fi
active=""
while [ ${#active} -le 1 ]; do
active=`curl -s --data '{"jsonrpc":"2.0", "method":"lookup_account_names", "params":[["'$username'"]], "id":1}' http://node.bravocoin.com/ | json_pp | grep -v memo_key | grep -A4 active | grep BRV | cut -f2 -d\"`
done
echo -e "Active Key: $active\n"
echo -n "Enter your private active key (Profile->Keys in app): "
read wif
if [[ $wif = 5* ]];
then echo "Private key valid!"
else
echo "Not a valid private key!" ;
exit
fi
cat << EOF >> config.ini
# Endpoint for P2P node to listen on
p2p-endpoint = 0.0.0.0:2001
# Maxmimum number of incoming connections on P2P endpoint
p2p-max-connections = 50
# P2P nodes to connect to on startup (may specify multiple times)
seed-node = 54.148.2.246:2001
seed-node = 34.214.225.109:2001
seed-node = 35.163.146.134:2001
seed-node = 52.32.235.184:2001
seed-node = 18.217.66.193:2001
# Size of the shared memory file. Default: 54G
shared-file-size = 54G
# Endpoint for websocket RPC to listen on
rpc-endpoint = 0.0.0.0:8090
# Endpoint for TLS websocket RPC to listen on
rpc-tls-endpoint = 0.0.0.0:8091
# Plugin(s) to enable, may be specified multiple times
public-api = database_api login_api account_by_key_api network_broadcast_api tag_api follow_api raw_block_api
# Plugin(s) to enable, may be specified multiple times
enable-plugin = witness account_history account_by_key tags follow raw_block
# Maximum age of head block when broadcasting tx via API
max-block-age = 2000
# Flush shared memory file to disk this many blocks
flush = 100000
# Track account statistics by grouping orders into buckets of equal size measured in seconds specified as a JSON array of numbers
account-stats-bucket-size = [60,3600,21600,86400,604800,2592000]
# How far back in time to track history for each bucker size, measured in the number of buckets (default: 100)
account-stats-history-per-bucket = 100
# Which accounts to track the statistics of. Empty list tracks all accounts.
account-stats-tracked-accounts = []
# Track blockchain statistics by grouping orders into buckets of equal size measured in seconds specified as a JSON array of numbers
chain-stats-bucket-size = [60,3600,21600,86400,604800,2592000]
# How far back in time to track history for each bucket size, measured in the number of buckets (default: 100)
chain-stats-history-per-bucket = 100
# Set the maximum size of cached feed for an account
follow-max-feed-size = 500
# Block time (in epoch seconds) when to start calculating feeds
follow-start-feeds = 0
# Track market history by grouping orders into buckets of equal size measured in seconds specified as a JSON array of numbers
market-history-bucket-size = [15,60,300,3600,86400]
# How far back in time to track history for each bucket size, measured in the number of buckets (default: 5760)
market-history-buckets-per-size = 5760
# Enable block production, even if the chain is stale.
enable-stale-production = false
# Percent of witnesses (0-99) that must be participating in order to produce blocks
required-participation = false
# name of witness controlled by this node (e.g. initwitness )
witness = "$username"
# WIF PRIVATE KEY to be used by one or more witnesses or miners
private-key = $wif
# declare an appender named "stderr" that writes messages to the console
[log.console_appender.stderr]
stream=std_error
# declare an appender named "p2p" that writes messages to p2p.log
[log.file_appender.p2p]
filename=logs/p2p/p2p.log
# filename can be absolute or relative to this config file
# route any messages logged to the default logger to the "stderr" logger we
# declared above, if they are info level are higher
[logger.default]
level=warn
appenders=stderr
# route messages sent to the "p2p" logger to the p2p appender declared above
[logger.p2p]
level=warn
appenders=p2p
EOF
echo -en "\nGrabbing bravod-full from github..."
wget -q https://github.com/bravo-project/bravo/releases/download/v0.23.0/bravod-full
chmod u+x bravod-full
echo -n " Done"
echo -en "\nInitializing witness node..."
nohup ./bravod-full &
sleep 3
pid=`ps aux | grep bravod-full | head -1 | awk '{print $2}'`
kill -9 $pid
echo -n "PID killed, restarting..."
rm -rf ./witness_node_data_dir/config.ini ; cp config.ini ./witness_node_data_dir/
screen -Sdm bravo nohup ./bravod-full &
sleep 3
echo "Done"
timeout 10s tail -f nohup.out
pause
}
delete_witness(){
rm -rf ./witness_node_data_dir bravod-full nohup.out config.ini
pause
}
view_logs(){
watch -n 1 tail nohup.out
}
stop_node(){
pid=`ps aux | grep bravod-full | head -1 | awk '{print $2}'`
kill -9 $pid
echo "Node stopped"
pause
}
start_node(){
pid=`ps aux | grep bravod-full | head -1 | awk '{print $2}'`
kill -9 $pid
screen -Sdm bravo nohup ./bravod-full &
echo "Node started"
pause
}
# function to display menus
show_menus() {
clear
echo "~~~~~~~~~~~~~~~~~~~~"
echo " BRAVO WITNESS NODE "
echo "~~~~~~~~~~~~~~~~~~~~"
echo "1. Setup Witness Node"
echo "2. Delete Witness Node"
echo "3. View Logs (Crtl-C to exit)"
echo "4. Stop Node"
echo "5. Start Node"
echo "6. Exit"
}
read_options(){
local choice
read -p "Enter choice [ 1 - 6] " choice
case $choice in
1) setup_witness ;;
2) delete_witness ;;
3) view_logs ;;
4) stop_node ;;
5) start_node ;;
6) exit 0;;
esac
}
trap '' SIGINT SIGQUIT SIGTSTP
while true
do
show_menus
read_options
done