frostfs-dev-env/bin/config.sh
Leonard Lyubich 1b4452df67 [#84] bin/config.sh: Fix typo in comment
Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
2021-06-09 16:30:00 +03:00

50 lines
1.5 KiB
Bash
Executable file

#!/usr/bin/env bash
# Source env settings
. .env
. services/ir/.ir.env
# NeoGo binary path.
NEOGO="${NEOGO:-docker exec -it main_chain neo-go}"
# Wallet files to change config value
WALLET="${WALLET:-services/chain/node-wallet.json}"
WALLET_IMG="${WALLET_IMG:-wallets/node-wallet.json}"
# Wallet password that would be entered automatically; '-' means no password
PASSWD="one"
# NeoFS configuration record: key is a string and value is an int
KEY=${1}
VALUE="${2}"
[ -z "$KEY" ] && echo "Empty config key" && exit 1
[ -z "$VALUE" ] && echo "Empty config value" && exit 1
# Internal variables
ADDR=`cat ${WALLET} | jq -r .accounts[2].address`
# Change config value in side chain
echo "Changing ${KEY} configration value to ${VALUE}"
./bin/passwd.exp ${PASSWD} ${NEOGO} contract invokefunction \
-w ${WALLET_IMG} \
-a ${ADDR} \
-r http://morph_chain.${LOCAL_DOMAIN}:30333 \
${NEOFS_IR_CONTRACTS_NETMAP} \
setConfig bytes:beefcafe \
string:${KEY} \
int:${VALUE} -- ${ADDR} || exit 1
# Fetch current epoch value
EPOCH=`${NEOGO} contract testinvokefunction -r \
http://morph_chain.${LOCAL_DOMAIN}:30333 \
${NEOFS_IR_CONTRACTS_NETMAP} \
epoch | grep 'value' | awk -F'"' '{ print $4 }'`
# Update epoch to apply new configuration value
echo "Updating NeoFS epoch to $((EPOCH+1))"
./bin/passwd.exp ${PASSWD} ${NEOGO} contract invokefunction \
-w ${WALLET_IMG} \
-a ${ADDR} \
-r http://morph_chain.${LOCAL_DOMAIN}:30333 \
${NEOFS_IR_CONTRACTS_NETMAP} \
newEpoch int:$((EPOCH+1)) -- ${ADDR}:Global