diff --git a/bin/libbfa.sh b/bin/libbfa.sh index 7a635eb8864762bc6b1ac206fbf4ec08c815b214..1c216d57b2957442599426106a0c1b8f16ab535b 100644 --- a/bin/libbfa.sh +++ b/bin/libbfa.sh @@ -99,21 +99,34 @@ function geth_rpc echo "$json" | jq .result } +function create_account +{ + geth --cache 0 --datadir ${BFANODEDIR} --password /dev/null account new +} + function extradata { - # something uniqueish - ## find default interface - local def_if=$( - ( ip -4 route show ; ip -6 route show ) | - expand | - sed -ne '/^default /{s/ */ /g;s/^.* dev //;s/ .*//;p;q}' - ) - local mymac=$( - ip link show ${def_if} | - sed -ne '/link\|ether/{s/^.*link.ether //;s/ .*//;s/://g;p;q}' + local acct=$( + ls -1d "${BFANODEDIR}"/keystore/*--* 2>/dev/null | + head -1 | + sed 's/.*--//' ) - # - echo -n "${BFAACCOUNT:0:19}.${mymac:0:12}" + if [ -n "$acct" ] + then + # something uniqueish + ## find default interface + local def_if=$( + ( ip -4 route show ; ip -6 route show ) | + expand | + sed -ne '/^default /{s/ */ /g;s/^.* dev //;s/ .*//;p;q}' + ) + local mymac=$( + ip link show ${def_if} | + sed -ne '/link\|ether/{s/^.*link.ether //;s/ .*//;s/://g;p;q}' + ) + # + echo -n "${acct:0:19}.${mymac:0:12}" + fi } function prereq @@ -191,6 +204,10 @@ then netport=$( cat ${BFANODEDIR}/netport ) test $? = 0 fi +if [ "$netport" != "30303" ] +then + netportarg="--port ${netport}" +fi # # rpcport rpcport=8545 @@ -199,18 +216,7 @@ then rpcport=$( cat ${BFANODEDIR}/rpcport ) test $? = 0 fi -# -# BFAACCOUNT -if [ -z "$BFAACCOUNT" ] +if [ "$rpcport" != "8545" ] then - if ! ls -1d ${BFANODEDIR}/keystore/*--* >/dev/null 2>&1 - then - echo "No accounts found. Creating a new one (they are free)." - geth --cache 0 --datadir ${BFANODEDIR} --password /dev/null account new - fi - BFAACCOUNT=$( - ls -1d "${BFANODEDIR}"/keystore/*--* 2>/dev/null | - head -1 | - sed 's/.*--//' - ) + rpcportarg="--rpcport ${rpcport}" fi diff --git a/bin/start.sh b/bin/start.sh index 38d4f4b9f028e0c936ed93cf3f102e00b17cf4ea..4c33b360426b02f3d3f892ca9374015913d52058 100755 --- a/bin/start.sh +++ b/bin/start.sh @@ -26,10 +26,6 @@ function getsyncmode echo "--syncmode ${syncmode}" } -test -n "${BFAACCOUNT}" || - fatal "No account defined." - - function startbootnode { local ERRTEXT="bootnode section failed" @@ -101,18 +97,26 @@ function startgeth echo # (re)configure parameters (you never know if they changed) flexargs="$( getsyncmode ) --extradata $( extradata )" + if [ "$netport" != 30303 ] + then + flexargs="${flexargs} --net $netport" + fi + if [ "$rpcport" != 30303 ] + then + flexargs="${flexargs} --rpcport $rpcport" + fi + if [ -n "$BFAVERBOSITY" -a "$BFAVERBOSITY" != 3 ] + then + flexargs="${flexargs} --verbosity ${BFAVERBOSITY:-3}" + fi set -x geth \ --datadir ${BFANODEDIR} \ --networkid ${BFANETWORKID} \ --rpc \ - --rpcport $rpcport \ --rpcapi "eth,net,web3,admin,clique,miner,personal" \ - --port $netport \ - --nousb \ --gcmode archive \ --cache 512 \ - --verbosity ${BFAVERBOSITY:-3} \ ${flexargs} \ --bootnodes "${bootnodes}" & set +x