node.sh for bls migration

pull/1099/head
Minh Doan 6 years ago committed by Minh Doan
parent 97a7d5e28b
commit 276bc2582b
  1. 51
      scripts/node.sh

@ -86,11 +86,12 @@ fi
print_usage() {
cat <<- ENDEND
usage: ${progname} [-1ch] account_address
usage: ${progname} [-1ch] [-k KEYFILE]
-c back up database/logs and start clean
(use only when directed by Harmony)
-1 do not loop; run once and exit
-h print this help and exit
-k KEYFILE use the given BLS key file (default: autodetect)
ENDEND
}
@ -103,10 +104,11 @@ usage() {
unset start_clean loop
start_clean=false
loop=true
${BLSKEYFILE=}
unset OPTIND OPTARG opt
OPTIND=1
while getopts :1ch opt
while getopts :1chk: opt
do
case "${opt}" in
'?') usage "unrecognized option -${OPTARG}";;
@ -114,25 +116,44 @@ do
c) start_clean=true;;
1) loop=false;;
h) print_usage; exit 0;;
k) BLSKEYFILE="${OPTARG}";;
*) err 70 "unhandled option -${OPTARG}";; # EX_SOFTWARE
esac
done
shift $((${OPTIND} - 1))
case $# in
0)
usage "Please provide account address." \
"For foundational nodes, please follow the instructions in Discord #foundational-nodes channel" \
"to generate and register your account address with <genesis at harmony dot one>."
[1-9]*)
usage "extra arguments at the end ($*)"
;;
esac
IDX="${1}"
shift 1
case $# in
[1-9]*)
usage "extra arguments at the end ($*)"
case "${BLSKEYFILE}" in
"")
unset -v f
for f in \
~/*--????-??-??T??-??-??.*Z--bls_???????????????????????????????????????????????????????????????????????????????????????????????? \
~/????????????????????????????????????????????????????????????????????????????????????????????????.key \
*--????-??-??T??-??-??.*Z--bls_???????????????????????????????????????????????????????????????????????????????????????????????? \
????????????????????????????????????????????????????????????????????????????????????????????????.key
do
[ -f "${f}" ] || continue
case "${BLSKEYFILE}" in
"")
BLSKEYFILE="${f}"
;;
*)
err 69 "multiple key files found (${f}, ${BLSKEYFILE}); please use -k to specify"
;;
esac
done
case "${BLSKEYFILE}" in
"") err 69 "could not autodetect BLS key file; please use -k to specify";;
esac
msg "autodetected BLS key file: ${BLSKEYFILE}"
;;
*)
msg "using manually specified BLS key file: ${BLSKEYFILE}"
;;
esac
@ -298,7 +319,7 @@ kill_node() {
check_update_pid=$!
unset -v passphrase
read -rsp "Enter passphrase for account ${IDX}: " passphrase
read -rsp "Enter passphrase for the BLS key file ${BLSKEYFILE}: " passphrase
echo
while :
@ -306,9 +327,9 @@ do
msg "############### Running Harmony Process ###############"
if [ "$OS" == "Linux" ]; then
# Run Harmony Node
echo -n "${passphrase}" | LD_LIBRARY_PATH=$(pwd) ./harmony -bootnodes $BN_MA -ip $PUB_IP -port $NODE_PORT -is_genesis -is_archival -accounts $IDX -pass stdin
echo -n "${passphrase}" | LD_LIBRARY_PATH=$(pwd) ./harmony -bootnodes $BN_MA -ip $PUB_IP -port $NODE_PORT -is_genesis -blskey_file "${BLSKEYFILE}" -blspass stdin
else
echo -n "${passphrase}" | DYLD_FALLBACK_LIBRARY_PATH=$(pwd) ./harmony -bootnodes $BN_MA -ip $PUB_IP -port $NODE_PORT -is_genesis -is_archival -accounts $IDX -pass stdin
echo -n "${passphrase}" | DYLD_FALLBACK_LIBRARY_PATH=$(pwd) ./harmony -bootnodes $BN_MA -ip $PUB_IP -port $NODE_PORT -is_genesis -blskey_file "${BLSKEYFILE}" -blspass stdin
fi || msg "node process finished with status $?"
${loop} || break
msg "restarting in 10s..."

Loading…
Cancel
Save