2021-04-16 10:57:21 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
2022-11-14 12:15:00 +00:00
|
|
|
echo "Running bin/config.sh"
|
|
|
|
|
2021-04-16 10:57:21 +00:00
|
|
|
# Source env settings
|
|
|
|
. .env
|
|
|
|
. services/ir/.ir.env
|
2022-06-10 08:32:20 +00:00
|
|
|
source bin/helper.sh
|
2021-04-16 10:57:21 +00:00
|
|
|
|
|
|
|
# NeoGo binary path.
|
2023-01-10 14:54:08 +00:00
|
|
|
NEOGO="${NEOGO:-docker exec morph_chain neo-go}"
|
2021-04-16 10:57:21 +00:00
|
|
|
|
2021-06-01 18:18:46 +00:00
|
|
|
# Wallet files to change config value
|
2023-01-10 14:54:08 +00:00
|
|
|
WALLET="${WALLET:-services/morph_chain/node-wallet.json}"
|
2022-11-14 12:15:00 +00:00
|
|
|
CONFIG_IMG="${CONFIG_IMG:-/wallets/config.yml}"
|
|
|
|
|
2023-01-10 13:05:29 +00:00
|
|
|
NETMAP_ADDR=$(bin/resolve.sh netmap.frostfs) || die "Failed to resolve 'netmap.frostfs' domain name"
|
2021-04-16 10:57:21 +00:00
|
|
|
|
2022-12-21 12:34:14 +00:00
|
|
|
# FrostFS configuration record: variable type [string|int|etc],
|
2021-10-15 11:42:15 +00:00
|
|
|
# key is a string and value is a constant of given type
|
|
|
|
TYPE=${1}
|
|
|
|
KEY=${2}
|
|
|
|
VALUE="${3}"
|
2021-04-16 10:57:21 +00:00
|
|
|
|
2021-10-15 11:42:15 +00:00
|
|
|
[ -z "$TYPE" ] && echo "Empty config value type" && exit 1
|
2021-04-16 10:57:21 +00:00
|
|
|
[ -z "$KEY" ] && echo "Empty config key" && exit 1
|
|
|
|
[ -z "$VALUE" ] && echo "Empty config value" && exit 1
|
|
|
|
|
|
|
|
# Internal variables
|
2022-12-21 12:34:14 +00:00
|
|
|
if [[ -z "${FROSTFS_NOTARY_DISABLED}" ]]; then
|
2022-06-10 08:32:20 +00:00
|
|
|
ADDR=$(jq -r .accounts[2].address < "${WALLET}" || die "Cannot get address from ${WALLET}")
|
2021-07-22 17:22:58 +00:00
|
|
|
else
|
2022-06-10 08:32:20 +00:00
|
|
|
ADDR=$(jq -r .accounts[0].address < "${WALLET}" || die "Cannot get address from ${WALLET}")
|
2021-07-22 17:22:58 +00:00
|
|
|
fi
|
2021-04-16 10:57:21 +00:00
|
|
|
|
|
|
|
# Change config value in side chain
|
|
|
|
echo "Changing ${KEY} configration value to ${VALUE}"
|
2022-06-10 08:32:20 +00:00
|
|
|
|
|
|
|
# shellcheck disable=SC2086
|
2022-11-14 12:15:00 +00:00
|
|
|
${NEOGO} contract invokefunction \
|
|
|
|
--wallet-config ${CONFIG_IMG} \
|
|
|
|
-a ${ADDR} --force \
|
2022-06-10 08:32:20 +00:00
|
|
|
-r http://morph-chain.${LOCAL_DOMAIN}:30333 \
|
|
|
|
${NETMAP_ADDR} \
|
|
|
|
setConfig bytes:beefcafe \
|
|
|
|
string:${KEY} \
|
|
|
|
${TYPE}:${VALUE} -- ${ADDR} || exit 1
|
2021-04-16 10:57:21 +00:00
|
|
|
|
2021-06-02 14:16:57 +00:00
|
|
|
# Update epoch to apply new configuration value
|
2021-06-29 19:01:40 +00:00
|
|
|
./bin/tick.sh
|