-
Notifications
You must be signed in to change notification settings - Fork 0
/
make.sh
135 lines (85 loc) · 4.23 KB
/
make.sh
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
#!/bin/bash
#/usr/bin/env bash
shopt -s extglob
shopt -s extquote
# shopt -s xpg_echo
set -f
if [[ "$1" == "help" || "$1" == "h" || "$1" == "?" || "$1" == "" ]]; then
echo
echo -e "bash $0 [ help/h/? | fmt | check | build | build release | submodules | submodules update | genconf/init | exec | exec_logging | exec_logging_cliout ]\n"
elif [[ "$1" == "fmt" ]]; then
echo "--check works since cargo-fmt 1.4.38"
cargo fmt -v --all --check ;
read -n 1 -s -p "Proceed with cargo fmt? [Enter/y|n] : " choice_fmt
echo -e "\n"
if [[ $choice_fmt == "y" || $choice_fmt == "" ]]; then
cargo fmt -v --all ;
else
echo
echo "Canceled"
fi
elif [[ "$1" == "check" ]]; then
cargo check ;
cargo clippy ;
elif [[ "$1" == "build" && "$2" == "" ]]; then
cargo build
elif [[ "$1" == "build" && "$2" == "release" ]]; then
cargo build --release
elif [[ "$1" == "submodules" && "$2" == "" ]]; then
git submodule status;
git submodule summary;
elif [[ "$1" == "submodules" && "$2" == "update" ]]; then
git submodule update --recursive --init
elif [[ "$1" == "genconf" || "$1" == "init" ]]; then
read -n 1 -s -p "Proceed with indexer initial configuration for particular network (enter as `init localnet/devnet/testnet/betanet/mainnet`)? [Enter/y|n] : " choice_init
echo -e "\n"
if [[ $choice_init == "y" || $choice_init == "" ]]; then
if [[ "${2}" == "localnet" || "${2}" == "devnet" || "${2}" == "testnet" || "${2}" == "betanet" || "${2}" == "mainnet" ]]; then
./target/debug/borealis-indexer --home-dir "./.borealis-indexer/${2}/" init --chain-id "${2}" "${@:3}"
# ./target/release/borealis-indexer --home-dir "./.borealis-indexer/${2}/" init --chain-id "${2}" "${@:3}"
sed -r -s -i"" "s/^(\s*?)\"tracked\_shards\"\:\s\[\]\,/\1\"tracked\_shards\"\:\ \[0\]\,/gI" "./.borealis-indexer/${2}/config.json"
else
./target/debug/borealis-indexer --home-dir ./.borealis-indexer/ init "${@:2}"
# ./target/release/borealis-indexer --home-dir ./.borealis-indexer/ init "${@:2}"
sed -r -s -i"" "s/^(\s*?)\"tracked\_shards\"\:\s\[\]\,/\1\"tracked\_shards\"\:\ \[0\]\,/gI" "./.borealis-indexer/${2}/config.json"
fi
else
echo
echo "Canceled"
fi
elif [[ "$1" == "exec" ]]; then
read -n 1 -s -p "Proceed with indexer command passing? [Enter/y|n] : " choice_exec
echo -e "\n"
if [[ $choice_exec == "y" || $choice_exec == "" ]]; then
./target/debug/borealis-indexer "${@:2}"
# ./target/release/borealis-indexer "${@:2}"
# | jq '{block_height: .block.header.height, block_hash: .block.header.hash, block_header_chunks: .block.chunks, shard_chunk_header: .shards[0].chunk.header, transactions: .shards[0].chunk.transactions, receipts: .shards[0].chunk.receipts, receipt_execution_outcomes: .shards[0].receipt_execution_outcomes, state_changes: .state_changes}'
else
echo
echo "Canceled"
fi
elif [[ "$1" == "exec_logging" ]]; then
read -n 1 -s -p "Proceed with indexer command passing? [Enter/y|n] : " choice_exec
echo -e "\n"
if [[ $choice_exec == "y" || $choice_exec == "" ]]; then
sudo mkdir -v -p /var/log/borealis-indexer/
sudo chown -v -R $USER:$USER /var/log/borealis-indexer/
./target/debug/borealis-indexer "${@:2}" >> /var/log/borealis-indexer/borealis-indexer.debug.log 2>&1 & disown
# ./target/release/borealis-indexer "${@:2}" >> /var/log/borealis-indexer/borealis-indexer.release.log 2>&1 & disown
else
echo
echo "Canceled"
fi
elif [[ "$1" == "exec_logging_cliout" ]]; then
read -n 1 -s -p "Proceed with indexer command passing? [Enter/y|n] : " choice_exec
echo -e "\n"
if [[ $choice_exec == "y" || $choice_exec == "" ]]; then
sudo mkdir -v -p /var/log/borealis-indexer/
sudo chown -v -R $USER:$USER /var/log/borealis-indexer/
./target/debug/borealis-indexer "${@:2}" 2>&1 | tee -a /var/log/borealis-indexer/borealis-indexer.debug.log & disown
# ./target/release/borealis-indexer "${@:2}" 2>&1 | tee -a /var/log/borealis-indexer/borealis-indexer.release.log & disown
else
echo
echo "Canceled"
fi
fi