[#238]: Remove interactive password input from setup scripts

Signed-off-by: anastasia prasolova <anastasia@nspcc.ru>
This commit is contained in:
anastasia prasolova 2022-11-14 15:15:00 +03:00 committed by Anastasia Prasolova
parent 79a11641ed
commit d8e825443e
6 changed files with 34 additions and 28 deletions

View file

@ -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 \

View file

@ -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"

View file

@ -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/") \

View file

@ -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

View file

@ -0,0 +1,4 @@
---
Path: "/wallets/node-wallet.json"
Password: "one"

View file

@ -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