From d8e825443ee73cc5fda38f83f11e8443a111ea1b Mon Sep 17 00:00:00 2001 From: anastasia prasolova Date: Mon, 14 Nov 2022 15:15:00 +0300 Subject: [PATCH] [#238]: Remove interactive password input from setup scripts Signed-off-by: anastasia prasolova --- bin/config.sh | 17 +++++++++-------- bin/deposit.sh | 17 +++++++++-------- bin/resolve.sh | 2 +- bin/tick.sh | 21 ++++++++++----------- services/chain/config.yml | 4 ++++ services/chain/docker-compose.yml | 1 + 6 files changed, 34 insertions(+), 28 deletions(-) create mode 100644 services/chain/config.yml diff --git a/bin/config.sh b/bin/config.sh index 0f88192..f63a49c 100755 --- a/bin/config.sh +++ b/bin/config.sh @@ -1,19 +1,20 @@ #!/usr/bin/env bash +echo "Running bin/config.sh" + # Source env settings . .env . services/ir/.ir.env source bin/helper.sh # NeoGo binary path. -NEOGO="${NEOGO:-docker exec -it main_chain neo-go}" +NEOGO="${NEOGO:-docker exec 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" -NETMAP_ADDR=$(bin/resolve.sh netmap.neofs) +CONFIG_IMG="${CONFIG_IMG:-/wallets/config.yml}" + +NETMAP_ADDR=$(bin/resolve.sh netmap.neofs) || die "Failed to resolve 'netmap.neofs' domain name" # NeoFS configuration record: variable type [string|int|etc], # key is a string and value is a constant of given type @@ -36,9 +37,9 @@ fi echo "Changing ${KEY} configration value to ${VALUE}" # shellcheck disable=SC2086 -./bin/passwd.exp ${PASSWD} ${NEOGO} contract invokefunction \ - -w ${WALLET_IMG} \ - -a ${ADDR} \ +${NEOGO} contract invokefunction \ + --wallet-config ${CONFIG_IMG} \ + -a ${ADDR} --force \ -r http://morph-chain.${LOCAL_DOMAIN}:30333 \ ${NETMAP_ADDR} \ setConfig bytes:beefcafe \ diff --git a/bin/deposit.sh b/bin/deposit.sh index 95fbc3e..07610a5 100755 --- a/bin/deposit.sh +++ b/bin/deposit.sh @@ -1,16 +1,17 @@ #!/usr/bin/env bash +echo "Running bin/deposit.sh" + # Source env settings . .env . services/ir/.ir.env source bin/helper.sh # NeoGo binary path. -NEOGO="${NEOGO:-docker exec -it main_chain neo-go}" +NEOGO="${NEOGO:-docker exec main_chain neo-go}" # Wallet file to use for deposit GAS from -WALLET="${WALLET:-wallets/wallet.json}" -# Wallet password that would be entered automatically; '-' means no password -PASSWD="-" +WALLET="${WALLET:-services/chain/node-wallet.json}" +CONFIG="${CONFIG:-/wallets/config.yml}" # How much GAS to deposit. First cli argument or 50 by default DEPOSIT="${1:-50}" @@ -25,10 +26,10 @@ CONTRACT_ADDR=$(${NEOGO} util convert "${NEOFS_IR_CONTRACTS_NEOFS}" \ # Make deposit # shellcheck disable=SC2086 -./bin/passwd.exp ${PASSWD} ${NEOGO} wallet nep17 transfer \ - -w ${WALLET} \ +${NEOGO} wallet nep17 transfer \ + --wallet-config ${CONFIG} \ -r http://main-chain.${LOCAL_DOMAIN}:30333 \ - --from ${ADDR} \ + --from ${ADDR} --force \ --to ${CONTRACT_ADDR} \ --token GAS \ - --amount ${DEPOSIT} + --amount ${DEPOSIT} || die "Cannot transfer GAS to NeoFS contract" diff --git a/bin/resolve.sh b/bin/resolve.sh index 36a1ac2..9aba65b 100755 --- a/bin/resolve.sh +++ b/bin/resolve.sh @@ -5,7 +5,7 @@ source bin/helper.sh # NeoGo binary path. -NEOGO="${NEOGO:-docker exec -t morph_chain neo-go}" +NEOGO="${NEOGO:-docker exec morph_chain neo-go}" # NNS contract script hash output=$(curl -s --data '{ "id": 1, "jsonrpc": "2.0", "method": "getcontractstate", "params": [1] }' \ "http://morph-chain.${LOCAL_DOMAIN}:30333/") \ diff --git a/bin/tick.sh b/bin/tick.sh index ede13c2..8c89a90 100755 --- a/bin/tick.sh +++ b/bin/tick.sh @@ -1,20 +1,18 @@ #!/usr/bin/env bash +echo "Running bin/tick.sh" + # Source env settings . .env . services/ir/.ir.env source bin/helper.sh # NeoGo binary path. -NEOGO="${NEOGO:-docker exec -it main_chain neo-go}" -NEOGO_NONINTERACTIVE="${NEOGO_NONINTERACTIVE:-docker exec -t main_chain neo-go}" +NEOGO="${NEOGO:-docker exec 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" +CONFIG_IMG="${CONFIG_IMG:-/wallets/config.yml}" # Internal variables if [[ -z "${NEOFS_NOTARY_DISABLED}" ]]; then @@ -30,7 +28,7 @@ BLOCK_DURATION=$(grep SecondsPerBlock < "$SIDECHAIN_PROTO" | awk '{print $2}') \ NETMAP_ADDR=$(bin/resolve.sh netmap.neofs) || die "Cannot resolve netmap.neofs" # Fetch current epoch value -EPOCH=$(${NEOGO_NONINTERACTIVE} contract testinvokefunction \ +EPOCH=$(${NEOGO} contract testinvokefunction \ -r "http://morph-chain.${LOCAL_DOMAIN}:30333" "${NETMAP_ADDR}" epoch \ | grep 'value' | awk -F'"' '{ print $4 }') \ || die "Cannot fetch epoch from netmap contract" @@ -38,12 +36,13 @@ EPOCH=$(${NEOGO_NONINTERACTIVE} contract testinvokefunction \ echo "Updating NeoFS epoch to $((EPOCH+1))" # shellcheck disable=SC2086 -./bin/passwd.exp ${PASSWD} ${NEOGO} contract invokefunction \ - -w ${WALLET_IMG} \ - -a ${ADDR} \ +${NEOGO} contract invokefunction \ + --wallet-config ${CONFIG_IMG} \ + -a ${ADDR} --force \ -r http://morph-chain.${LOCAL_DOMAIN}:30333 \ ${NETMAP_ADDR} \ - newEpoch int:$((EPOCH+1)) -- ${ADDR}:Global + newEpoch int:$((EPOCH+1)) -- ${ADDR}:Global \ + || die "Cannot increment an epoch" # Wait one Morph block to ensure the transaction broadcasted # shellcheck disable=SC2086 diff --git a/services/chain/config.yml b/services/chain/config.yml new file mode 100644 index 0000000..7b4bb29 --- /dev/null +++ b/services/chain/config.yml @@ -0,0 +1,4 @@ +--- + +Path: "/wallets/node-wallet.json" +Password: "one" diff --git a/services/chain/docker-compose.yml b/services/chain/docker-compose.yml index b3e0822..3fe1698 100644 --- a/services/chain/docker-compose.yml +++ b/services/chain/docker-compose.yml @@ -20,6 +20,7 @@ services: - ./../../vendor/chain.gz:/chain.gz - ./protocol.privnet.yml:/config/protocol.privnet.yml - ./node-wallet.json:/wallets/node-wallet.json + - ./config.yml:/wallets/config.yml - ./../../vendor/hosts:/etc/hosts - ./../../wallets/wallet.json:/wallets/wallet.json