forked from TrueCloudLab/frostfs-dev-env
#70 automating password input to neo-go commands
Signed-off-by: anastasia prasolova <anastasia@nspcc.ru>
This commit is contained in:
parent
4a6d304b8f
commit
d0094d8068
3 changed files with 25 additions and 4 deletions
|
@ -7,9 +7,11 @@
|
||||||
# NeoGo binary path.
|
# NeoGo binary path.
|
||||||
NEOGO="${NEOGO:-docker exec -it main_chain neo-go}"
|
NEOGO="${NEOGO:-docker exec -it main_chain neo-go}"
|
||||||
|
|
||||||
# Wallet files to change config value
|
# Wallet files to change config value
|
||||||
WALLET="${WALLET:-services/chain/node-wallet.json}"
|
WALLET="${WALLET:-services/chain/node-wallet.json}"
|
||||||
WALLET_IMG="${WALLET_IMG:-wallets/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
|
# NeoFS configuration record: key is a string and value is an int
|
||||||
KEY=${1}
|
KEY=${1}
|
||||||
|
@ -23,7 +25,7 @@ ADDR=`cat ${WALLET} | jq -r .accounts[2].address`
|
||||||
|
|
||||||
# Change config value in side chain
|
# Change config value in side chain
|
||||||
echo "Changing ${KEY} configration value to ${VALUE}"
|
echo "Changing ${KEY} configration value to ${VALUE}"
|
||||||
${NEOGO} contract invokefunction \
|
./bin/passwd.exp ${PASSWD} ${NEOGO} contract invokefunction \
|
||||||
-w ${WALLET_IMG} \
|
-w ${WALLET_IMG} \
|
||||||
-a ${ADDR} \
|
-a ${ADDR} \
|
||||||
-r http://morph_chain.${LOCAL_DOMAIN}:30333 \
|
-r http://morph_chain.${LOCAL_DOMAIN}:30333 \
|
||||||
|
@ -40,7 +42,7 @@ epoch | grep 'value' | awk -F'"' '{ print $4 }'`
|
||||||
|
|
||||||
# Update epoch to apply new configuartion value
|
# Update epoch to apply new configuartion value
|
||||||
echo "Updating NeoFS epoch to $((EPOCH+1))"
|
echo "Updating NeoFS epoch to $((EPOCH+1))"
|
||||||
${NEOGO} contract invokefunction \
|
./bin/passwd.exp ${PASSWD} ${NEOGO} contract invokefunction \
|
||||||
-w ${WALLET_IMG} \
|
-w ${WALLET_IMG} \
|
||||||
-a ${ADDR} \
|
-a ${ADDR} \
|
||||||
-r http://morph_chain.${LOCAL_DOMAIN}:30333 \
|
-r http://morph_chain.${LOCAL_DOMAIN}:30333 \
|
||||||
|
|
|
@ -8,6 +8,8 @@
|
||||||
NEOGO="${NEOGO:-docker exec -it main_chain neo-go}"
|
NEOGO="${NEOGO:-docker exec -it main_chain neo-go}"
|
||||||
# Wallet file to use for deposit GAS from
|
# Wallet file to use for deposit GAS from
|
||||||
WALLET="${WALLET:-wallets/wallet.json}"
|
WALLET="${WALLET:-wallets/wallet.json}"
|
||||||
|
# Wallet password that would be entered automatically; '-' means no password
|
||||||
|
PASSWD="-"
|
||||||
# How much GAS to deposit. First cli argument or 50 by default
|
# How much GAS to deposit. First cli argument or 50 by default
|
||||||
DEPOSIT="${1:-50}"
|
DEPOSIT="${1:-50}"
|
||||||
|
|
||||||
|
@ -16,7 +18,7 @@ ADDR=`cat ${WALLET} | jq -r .accounts[0].address`
|
||||||
CONTRACT_ADDR=`${NEOGO} util convert ${NEOFS_IR_CONTRACTS_NEOFS} | grep 'LE ScriptHash to Address' | awk '{print $5}' | grep -oP [A-z0-9]+`
|
CONTRACT_ADDR=`${NEOGO} util convert ${NEOFS_IR_CONTRACTS_NEOFS} | grep 'LE ScriptHash to Address' | awk '{print $5}' | grep -oP [A-z0-9]+`
|
||||||
|
|
||||||
# Make deposit
|
# Make deposit
|
||||||
${NEOGO} wallet nep17 transfer \
|
./bin/passwd.exp ${PASSWD} ${NEOGO} wallet nep17 transfer \
|
||||||
-w ${WALLET} \
|
-w ${WALLET} \
|
||||||
-r http://main_chain.${LOCAL_DOMAIN}:30333 \
|
-r http://main_chain.${LOCAL_DOMAIN}:30333 \
|
||||||
--from ${ADDR} \
|
--from ${ADDR} \
|
||||||
|
|
17
bin/passwd.exp
Executable file
17
bin/passwd.exp
Executable file
|
@ -0,0 +1,17 @@
|
||||||
|
#!/usr/bin/expect
|
||||||
|
|
||||||
|
set passwd [lindex $argv 0]
|
||||||
|
set args [lrange $argv 1 end]
|
||||||
|
|
||||||
|
spawn -noecho {*}$args
|
||||||
|
expect -re {^.*assword.*$}
|
||||||
|
|
||||||
|
if { $passwd == "-"} {
|
||||||
|
send -- "\r"
|
||||||
|
} else {
|
||||||
|
send -- "$passwd\r"
|
||||||
|
}
|
||||||
|
|
||||||
|
expect EOF
|
||||||
|
lassign [wait] pid spawnid os_error_flag value
|
||||||
|
exit $value
|
Loading…
Reference in a new issue