-
Notifications
You must be signed in to change notification settings - Fork 16
/
init.config
executable file
·37 lines (28 loc) · 1.31 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
#!/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
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'" > ./data/env_file
echo "NAME=$nodeName" >> ./data/env_file
echo "ENV_LOADED=true" >> ./data/env_file
echo "wallet mnemonic already provided by you, loading config.json . Please proceed to run docker compose"
exit 1
fi
ENV_LOADED=$(grep '^ENV_LOADED=' ./data/env_file | cut -d '=' -f 2)
if [ "$ENV_LOADED" = "false" ]; then
docker run -it --entrypoint=bash -v $(pwd)/data:/data -e NAME="${nodeName}" -e ALLORA_OFFCHAIN_NODE_CONFIG_JSON="${stringified_json}" alloranetwork/allora-chain:latest -c "bash /data/scripts/init.sh"
echo "config.json loaded to ./data/env_file"
else
echo "config.json is already loaded, skipping the operation. You can set ENV_LOADED variable to false in ./data/env_file to reload the config.json"
fi