-
Notifications
You must be signed in to change notification settings - Fork 0
/
avax
executable file
·130 lines (114 loc) · 1.71 KB
/
avax
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
#!/bin/bash
if test "$1" == "" ; then
echo "info: get node health"
echo "logs: watch node logs"
echo "node: get node id"
echo "sync: get status of chain synchronization"
echo "stop: stop node"
echo "drop: remove node"
echo "pots: restart stopped node"
echo "roll: stop, remove, and start new node"
echo "peer: peers"
echo "vals: list validators"
exit
fi
ADDR="127.0.0.1"
DATA=''
ENDP=''
PORT="9650"
case "$1" in
logs)
docker logs -f avalanche
;;
peer)
DATA='{
"jsonrpc": "2.0",
"method": "info.peers",
"id": 1
}'
ENDP='/ext/info'
;;
vals)
DATA='{
"jsonrpc": "2.0",
"method": "platform.getCurrentValidators",
"id": 1
}'
ENDP='/ext/P'
;;
info)
DATA='{
"jsonrpc": "2.0",
"id" : 1,
"method" : "health.getLiveness"
}'
ENDP='/ext/health'
;;
node)
DATA='{
"jsonrpc": "2.0",
"id" : 1,
"method" : "info.getNodeID"
}'
ENDP='/ext/info'
;;
c)
echo -n "C: "
DATA='{
"jsonrpc": "2.0",
"id" : 1,
"method" : "info.isBootstrapped",
"params" : {
"chain" : "C"
}
}'
ENDP='/ext/info'
;;
p)
echo -n "P: "
DATA='{
"jsonrpc": "2.0",
"id" : 1,
"method" : "info.isBootstrapped",
"params" : {
"chain" : "P"
}
}'
ENDP='/ext/info'
;;
x)
echo -n "X: "
DATA='{
"jsonrpc": "2.0",
"id" : 1,
"method" : "info.isBootstrapped",
"params" : {
"chain" : "X"
}
}'
ENDP='/ext/info'
;;
sync)
$0 c
$0 p
$0 x
;;
stop)
docker stop avalanche
;;
pots)
docker start avalanche
;;
drop)
docker rm avalanche
;;
roll)
$0 stop
$0 drop
docker run -d --restart unless-stopped --name avalanche -p 9650:9650 -p 9651:9651 -v avalanche:/root/.avalanchego avax0:avalanche
;;
*)
$0
;;
esac
if test "$DATA" != "" ; then curl -s -X POST --data "$DATA" -H 'content-type:application/json;' $ADDR:$PORT$ENDP | jq ; fi