From 3e39f6cd62ff8512a1be18a9a21f77970b67d503 Mon Sep 17 00:00:00 2001 From: Robert Martin-Legene <robert@nic.ar> Date: Wed, 26 Sep 2018 17:23:59 -0300 Subject: [PATCH] Make sure we have an account --- bin/installbfa.sh | 20 ++++++++++++-------- bin/start.sh | 40 +++++++++++++++++++++++----------------- 2 files changed, 35 insertions(+), 25 deletions(-) diff --git a/bin/installbfa.sh b/bin/installbfa.sh index 8b6ddd4..906aa40 100755 --- a/bin/installbfa.sh +++ b/bin/installbfa.sh @@ -2,6 +2,10 @@ NODEJSPGP=0x68576280 +# /root often does not have enough space, so we create a directory in /home +# for building, which we hope has more space. +NEW=/home/root/new + trap 'exit 1' ERR set -o errtrace # Be verbose @@ -62,8 +66,8 @@ function golanginstall if [ ! -d /usr/local/go ] then info Downloading package of go binaries. - mkdir -p ~/new - cd ~/new + mkdir -p ${NEW} + cd ${NEW} local arch= case "$(uname -m)" in x86_64) @@ -105,21 +109,21 @@ function golanginstall function gethinstall { - mkdir -p ~/new - cd ~/new + mkdir -p ${NEW} + cd ${NEW} info Download geth source code. test -d go-ethereum || git clone https://github.com/ethereum/go-ethereum - cd ~/new/go-ethereum + cd ${NEW}/go-ethereum info Running git pull to ensure that the local go-ethereum repo is up-to-date. git pull # - cd ~/new/go-ethereum + cd ${NEW}/go-ethereum info Compiling geth make all && echo Ignore that last line, if it tells you to run geth now. mkdir -p ~bfa/bin - cp -vp ~/new/go-ethereum/build/bin/{geth,bootnode,abigen,ethkey,puppeth,rlpdump,wnode,swarm,swarm-smoke} ~bfa/bin/ + cp -vp ${NEW}/go-ethereum/build/bin/{geth,bootnode,abigen,ethkey,puppeth,rlpdump,wnode,swarm,swarm-smoke} ~bfa/bin/ chown -R bfa:bfa ~bfa } @@ -175,7 +179,7 @@ function welcome # development tools -aptinstall dirmngr apt-transport-https curl git curl build-essential +aptinstall dirmngr apt-transport-https curl git curl build-essential sudo usersetup nodejsinstall web3install diff --git a/bin/start.sh b/bin/start.sh index d1d9e09..de2bb17 100755 --- a/bin/start.sh +++ b/bin/start.sh @@ -3,25 +3,27 @@ if [ -z "${BFAHOME}" ]; then echo "\$BFAHOME not set. Did you source bfa/bin/env ?" >&2; exit 1; fi source ${BFAHOME}/bin/libbfa.sh || exit 1 -bootnodeid=6c81b38551fec2f1142b58ed65137cc1b7dfdc7b35bc556ef26604c41e30fcdeb12212b3c19913584f71dc7bf87d76cd67fa523e96996c0f148390fb76fdc5f7 -bootnodev6=2800:40:1:6::135 -bootnodev4=200.68.65.135 -bootnodeport=30301 -bootnodes="enode://${bootnodeid}@[$bootnodev6]:${bootnodeport},enode://${bootnodeid}@[$bootnodev4]:${bootnodeport}" +bootNICv4="enode://37614dc9f5e94efc45eb533ac02e9f1d693c47f0537d818b222f02e1e6d73cf9@[200.108.146.101]:30301" +bootnodes="${bootNICv4}" function accountlist { local accts= - for file in ${BFANODEDIR}/keystore/*--* + local filename + for filename in ${BFANODEDIR}/keystore/*--* do - if [ -r "$file" ] + if [ -r "$filename" -a ${#filename} -ge 40 ] then - acct=$( echo $file | sed 's/^.*--//' ) + acct=${filename:$(( ${#filename} - 40 ))} accts="${accts},${acct}" fi done - # strip first comma - echo "--password /dev/null --unlock ${accts:1}" + # strip leading comma + accts=${accts#,} + if [ ${#accts} -ge 40 ] + then + echo "--password /dev/null --unlock ${accts}" + fi } # touch the "miner" file if you are authorized to mine @@ -44,15 +46,19 @@ function getsyncmode echo "--syncmode ${syncmode}" } +test -n "${BFAACCOUNT}" || + fatal "No account defined." + +if [ -t 1 ] +then + echo Logging everything to ${BFANODEDIR}/log + echo Consider running: tail -n 1000 -F ${BFANODEDIR}/log +fi -# Start the miner. +# Start the node. ( + echo ${BASHPID} > ${BFANODEDIR}/start-loop.pid flock --nonblock --exclusive 9 || exit 1 - if [ -t 1 ] - then - echo Logging everything to ${BFANODEDIR}/log - echo Consider running: tail -n 1000 -F ${BFANODEDIR}/log - fi while : do echo @@ -79,4 +85,4 @@ function getsyncmode wait sleep 60 done 2>&1 | ${BFAHOME}/bin/log.sh ${BFANODEDIR}/log & -) 9>> ${BFANODEDIR}/geth.pid +) 9>> ${BFANODEDIR}/start-loop.pid -- GitLab