forked from allora-network/basic-coin-prediction-node
-
Notifications
You must be signed in to change notification settings - Fork 0
/
init.config
executable file
·43 lines (35 loc) · 1.64 KB
/
init.config
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
#!/bin/bash
set -e
if [ ! -f config.json ]; then
echo "Error: config.json file not found, please provide one"
exit 1
fi
nodeName=$(jq -r '.wallet.addressKeyName' config.json)
if [ -z "$nodeName" ]; then
echo "No wallet name provided for the node, please provide your preferred wallet name. config.json >> wallet.addressKeyName"
exit 1
fi
# Ensure the worker-data directory exists
mkdir -p ./worker-data
json_content=$(cat ./config.json)
stringified_json=$(echo "$json_content" | jq -c .)
mnemonic=$(jq -r '.wallet.addressRestoreMnemonic' config.json)
if [ -n "$mnemonic" ]; then
echo "ALLORA_OFFCHAIN_NODE_CONFIG_JSON='$stringified_json'" > ./worker-data/env_file
echo "NAME=$nodeName" >> ./worker-data/env_file
echo "ENV_LOADED=true" >> ./worker-data/env_file
echo "wallet mnemonic already provided by you, loading config.json . Please proceed to run docker compose"
exit 1
fi
if [ ! -f ./worker-data/env_file ]; then
echo "ENV_LOADED=false" > ./worker-data/env_file
fi
ENV_LOADED=$(grep '^ENV_LOADED=' ./worker-data/env_file | cut -d '=' -f 2)
if [ "$ENV_LOADED" = "false" ]; then
json_content=$(cat ./config.json)
stringified_json=$(echo "$json_content" | jq -c .)
docker run -it --entrypoint=bash -v $(pwd)/worker-data:/data -v $(pwd)/scripts:/scripts -e NAME="${nodeName}" -e ALLORA_OFFCHAIN_NODE_CONFIG_JSON="${stringified_json}" alloranetwork/allora-chain:latest -c "bash /scripts/init.sh"
echo "config.json saved to ./worker-data/env_file"
else
echo "config.json is already loaded, skipping the operation. You can set ENV_LOADED variable to false in ./worker-data/env_file to reload the config.json"
fi