diff --git a/bin/installbfa.sh b/bin/installbfa.sh index 35fe02c693ea57cba83cb1e797ebb0602529fbe6..974212c9d5ad283226e082caed47033381a248f6 100755 --- a/bin/installbfa.sh +++ b/bin/installbfa.sh @@ -32,15 +32,15 @@ function nodejsinstall # Nodejs software repository PGP key if [ `apt-key export ${NODEJSPGP} 2>&1 | wc -l` -le 50 ] then - info Adding nodejs software repository PGP key + info "Adding nodejs software repository PGP key" apt-key adv --keyserver keyserver.ubuntu.com --recv ${NODEJSPGP} fi local file=/etc/apt/sources.list.d/nodesource.list if [ ! -r "$file" ] then - info Adding nodejs repository to apt sources. + info "Adding nodejs repository to apt sources." echo "deb https://deb.nodesource.com/node_10.x $(lsb_release -sc) main" > $file - info And now updating the software package list. + info "And now updating the software package list." apt update fi # nodejs also provides npm @@ -49,14 +49,15 @@ function nodejsinstall function web3install { - test -r ~bfa/package.json || - info Initialising nodejs. && + cd ~bfa + test -r package.json || + info "Initialising nodejs." && sudo --set-home -u bfa npm init -y # nodejs package(s) that we need. echo 'require("web3")' | sudo --set-home -u bfa nodejs 2>/dev/null && return - info Installing nodejs module: web3 "(will show many warnings)" + info "Installing nodejs module: web3 (will show many warnings)" sudo --set-home -u bfa npm install web3 - info Installing nodejs module: require + info "Installing nodejs module: require" sudo --set-home -u bfa npm install require } @@ -64,16 +65,16 @@ function golanginstall { if [ ! -d /usr/local/go ] then - info Downloading package of go binaries. + info "Downloading package of go binaries." mkdir -p ${NEW} cd ${NEW} - local arch= - case "$(uname -m)" in + local arch=$( uname -m ) + case "${arch}" in x86_64) arch=amd64 ;; *) - echo Do not know how to help you. >&2 + echo "We have no recipe for how to build on your \"${arch}\" platform." >&2 exit 1 ;; esac @@ -100,7 +101,7 @@ function golanginstall fi # Integrity checking the archive tar -xzf "$name" - info Unpacking $name into /usr/local + info "Unpacking $name into /usr/local" tar -C /usr/local -xzf go*.tar.gz fi PATH=${PATH}:/usr/local/go/bin @@ -108,21 +109,24 @@ function golanginstall function gethinstall { - mkdir -p ${NEW} + install --verbose --owner=bfa --group=bfa --directory ${NEW} cd ${NEW} - info Download geth source code. - test -d go-ethereum || - git clone https://github.com/ethereum/go-ethereum - cd ${NEW}/go-ethereum - info Running git pull to ensure that the local go-ethereum repo is up-to-date. - git pull + if [ -d go-ethereum ] + then + info "Running git pull to ensure that the local go-ethereum repo is up-to-date." + cd ${NEW}/go-ethereum + sudo -u bfa git pull + else + info "Download geth source code." + sudo -u bfa git clone https://github.com/ethereum/go-ethereum + cd ${NEW}/go-ethereum + fi # - cd ${NEW}/go-ethereum - info Compiling geth - make all - mkdir -p ~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 + info "Compiling geth" + sudo -u bfa make all + HISBINDIR=$( echo ~bfa/bfa ) + install --verbose --owner=bfa --group=bfa --directory ${HISBINDIR} + install --verbose --owner=bfa --group=bfa --target-directory=${HISBINDIR} ${NEW}/go-ethereum/build/bin/{geth,bootnode,abigen,ethkey,puppeth,rlpdump,wnode,swarm,swarm-smoke} } function aptinstall @@ -132,7 +136,7 @@ function aptinstall # consider apt install --install-suggests if you are masochist dpkg --verify $pkg 2>/dev/null || ( - info Installing $pkg + info "Installing $pkg" apt -y install $pkg ) done @@ -142,7 +146,7 @@ function usersetup { if ! id bfa >/dev/null 2>&1 then - info Adding required user \"bfa\" + info "Adding required user \"bfa\"" adduser --disabled-password --gecos 'Blockchain Federal Argentina' bfa fi cd ~bfa @@ -180,7 +184,7 @@ function cronit { if [ $( ( crontab -u bfa -l 2>/dev/null || true ) | grep -E "$BFAHOME/bin/cron.sh" | wc -l ) -eq 0 ] then - info Install crontab to start automatically upon reboot + info "Install crontab to start automatically upon reboot" (( crontab -u bfa -l 2>/dev/null || true ) ; echo "@reboot $BFAHOME/bin/cron.sh" ) | crontab -u bfa - fi }