diff --git a/bin/installbfa.sh b/bin/installbfa.sh index 9d848d14771d43d80eca5cd7fddc9f2db8f42f3a..9ab1b85a8da14ddac30ee5d8c75650cc643d6e54 100755 --- a/bin/installbfa.sh +++ b/bin/installbfa.sh @@ -4,6 +4,8 @@ NODEJSPGP=0x68576280 trap 'exit 1' ERR set -o errtrace +# Be verbose +set -e if [ `id -u` -ne 0 ] then @@ -26,12 +28,6 @@ function yesno test "${defval,,}" = "y" && yn="Yn" REPLY= - # Don't really ask, if we are running from a script (with no tty as stdin) - # To avoid prompts, run this script with < /dev/null - if [ ! -t 0 ] - then - REPLY="${defval,,}" - fi while [ "${REPLY}" != "y" -a "${REPLY}" != "n" ] do read -s -n 1 -p "${*}? [${yn}]: " @@ -50,14 +46,14 @@ function yesno } # For getting a recent nodejs -function nodejs_pre +function nodejs_pre { info nodejs pkgs="$pkgs nodejs" # Nodejs software repository PGP key if [ `apt-key export ${NODEJSPGP} 2>&1 | wc -l` -le 50 ] then - yesno y Add nodejs software repository PGP key && + yesno n Add nodejs software repository PGP key && apt-key adv --keyserver keyserver.ubuntu.com --recv ${NODEJSPGP} fi local file=/etc/apt/sources.list.d/nodejs.list @@ -70,18 +66,18 @@ function nodejs_pre fi } -function nodejs_post +function nodejs_post { info Initialising nodejs. test -r "package.json" || npm init -y # nodejs package(s) that we need. nodejs -e 'require("web3")' 2>/dev/null && return - yesno y Installing nodejs module: web3 + yesno n Installing nodejs module: web3 npm install web3 } -function golang_pre +function golang_pre { unset installedusrlocalgo if [ ! -d /usr/local/go ] @@ -129,7 +125,7 @@ function golang_pre PATH=${PATH}:/usr/local/go/bin } -function geth_pre +function geth_pre { mkdir -p ~/new cd ~/new @@ -141,21 +137,21 @@ function geth_pre git pull } -function geth_compile +function geth_compile { cd ~/new/go-ethereum info Compiling geth - make all + make geth } -function geth_post +function geth_post { mkdir -p ~bfa/bin - cp -vp ~/new/go-ethereum/build/bin/{geth,bootnode,puppeth} ~bfa/bin/ + cp -vp ~/new/go-ethereum/build/bin/geth ~bfa/bin/ chown -R bfa:bfa ~bfa } -function aptinstall +function aptinstall { local inst= for pkg in $pkgs @@ -167,9 +163,9 @@ function aptinstall apt --install-suggests -y install $inst || true } -function usersetup +function usersetup { - if echo ~bfa | grep -qvE '^/' && yesno y Add required user \"bfa\" + if echo ~bfa | grep -qvE '^/' && yesno n Add required user \"bfa\" then info Adding BFA user \"bfa\". adduser --disabled-password --gecos 'Blockchain Federal Argentina' bfa @@ -192,7 +188,7 @@ function usersetup fi } -function golang_post +function golang_post { if [ -n "${installedusrlocalgo}" ] then @@ -201,16 +197,16 @@ function golang_post fi } -function cronit +function cronit { if crontab -u bfa -l | expand | grep -qvE '^@reboot +bfa/bin/cron.sh$' then - yesno y Install crontab to start automatically upon reboot || return + yesno n Install crontab to start automatically upon reboot || return ( crontab -u bfa -l ; echo '@reboot bfa/bin/cron.sh' ) | crontab -u bfa - fi } -function welcome +function welcome { echo echo "(re)log in as user bfa" @@ -227,6 +223,6 @@ golang_pre geth_pre geth_compile geth_post -#golang_post +golang_post cronit welcome