-
Notifications
You must be signed in to change notification settings - Fork 22
/
Copy pathrun.sh
executable file
·51 lines (43 loc) · 1.3 KB
/
run.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
#!/bin/bash
set -e
# set -x
execFile="modular-indexer-light"
command="./$execFile"
configExampleFile="config.example.json"
configFile="config.json"
bitcoinRPC="https://bitcoin-mainnet-archive.allthatnode.com"
randName=$(date +%s%N | base64 | head -c 6; echo)
if [[ ! -f "$configExampleFile" ]]; then
echo "$configExampleFile not found"
exit 1
fi
cp $configExampleFile $configFile
if [[ ! -f "$execFile" ]]; then
echo "$execfile not found"
exit 1
fi
read -p "Please enter your Bitcoin RPC endpoint: " endpoint
if [[ ! "$endpoint" =~ ^(http|https)://([^/\s]+)/?([^/\s]*)\.?([^/\s]*)?$ ]]; then
echo "Invalid Bitcoin RPC endpoint, default endpoint $bitcoinRPC will be used."
else
sed -i'' -e "s|$bitcoinRPC|$endpoint|g" "$configFile"
fi
read -p "Please enter your Gas Coupon: " gasCoupon
gasCoupon=$(echo "$gasCoupon" | xargs)
if [[ 30 != ${#gasCoupon} ]]; then
echo "Invalid Gas Coupon"
exit 1
fi
if [[ $gasCoupon == "" ]]; then
echo "Gas Coupon required!"
exit 1
fi
sed -i'' -e "s/YourGasCoupon/$gasCoupon/g" "$configFile"
read -p "Please enter your desired indexer name: " name
if [[ $name == "" ]]; then
echo "Use randomly generated name"
name=$randName
fi
sed -i'' -e "s/YourOwnLightIndexerName/$name/g" "$configFile"
echo "Starting modular-indexer-light ......"
$command