Add init scripts
This commit is contained in:
4
offchain-node-data/env_file
Normal file
4
offchain-node-data/env_file
Normal file
@ -0,0 +1,4 @@
|
||||
ALLORA_OFFCHAIN_NODE_CONFIG_JSON='{"wallet":{"addressKeyName":"basic-coin-prediction-offchain-node","addressRestoreMnemonic":"rich note fetch lava bless snake delay theme era anger ritual sea pluck neck hazard dish talk ranch trophy clap fancy human divide gun","addressAccountPassphrase":"secret","alloraHomeDir":"","gas":"1000000","gasAdjustment":1,"nodeRpc":"https://allora-rpc.devnet.behindthecurtain.xyz","maxRetries":1,"minDelay":1,"maxDelay":2,"submitTx":false},"worker":[{"topicId":1,"inferenceEntrypointName":"api-worker-reputer","loopSeconds":5,"parameters":{"InferenceEndpoint":"http://inference:8000/inference/{Token}","Token":"ETH"}}]}'
|
||||
ALLORA_OFFCHAIN_ACCOUNT_ADDRESS=allo14wkkdeg93mdc0sd770z9p4mpjz7w9mysz328um
|
||||
NAME=basic-coin-prediction-offchain-node
|
||||
ENV_LOADED=true
|
33
offchain-node-data/scripts/init.sh
Normal file
33
offchain-node-data/scripts/init.sh
Normal file
@ -0,0 +1,33 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
|
||||
if allorad keys --home=/data/.allorad --keyring-backend test show $NAME > /dev/null 2>&1 ; then
|
||||
echo "allora account: $NAME already imported"
|
||||
else
|
||||
echo "creating allora account: $NAME"
|
||||
output=$(allorad keys add $NAME --home=/data/.allorad --keyring-backend test 2>&1)
|
||||
address=$(echo "$output" | grep 'address:' | sed 's/.*address: //')
|
||||
mnemonic=$(echo "$output" | tail -n 1)
|
||||
|
||||
# Parse and update the JSON string
|
||||
updated_json=$(echo "$ALLORA_OFFCHAIN_NODE_CONFIG_JSON" | jq --arg name "$NAME" --arg mnemonic "$mnemonic" '
|
||||
.wallet.addressKeyName = $name |
|
||||
.wallet.addressRestoreMnemonic = $mnemonic
|
||||
')
|
||||
|
||||
stringified_json=$(echo "$updated_json" | jq -c .)
|
||||
|
||||
echo "ALLORA_OFFCHAIN_NODE_CONFIG_JSON='$stringified_json'" > /data/env_file
|
||||
echo ALLORA_OFFCHAIN_ACCOUNT_ADDRESS=$address >> /data/env_file
|
||||
echo "NAME=$NAME" >> /data/env_file
|
||||
|
||||
echo "Updated ALLORA_OFFCHAIN_NODE_CONFIG_JSON saved to /data/env_file"
|
||||
fi
|
||||
|
||||
|
||||
if grep -q "ENV_LOADED=false" /data/env_file; then
|
||||
sed -i 's/ENV_LOADED=false/ENV_LOADED=true/' /data/env_file
|
||||
else
|
||||
echo "ENV_LOADED=true" >> /data/env_file
|
||||
fi
|
Reference in New Issue
Block a user