Skip to content
Snippets Groups Projects
Commit e529efe1 authored by Robert Martin-Legene's avatar Robert Martin-Legene
Browse files

Adding script for installing on a clean Debian system

parent 7d874180
No related branches found
No related tags found
No related merge requests found
...@@ -4,6 +4,8 @@ NODEJSPGP=0x68576280 ...@@ -4,6 +4,8 @@ NODEJSPGP=0x68576280
trap 'exit 1' ERR trap 'exit 1' ERR
set -o errtrace set -o errtrace
# Be verbose
set -e
if [ `id -u` -ne 0 ] if [ `id -u` -ne 0 ]
then then
...@@ -26,12 +28,6 @@ function yesno ...@@ -26,12 +28,6 @@ function yesno
test "${defval,,}" = "y" && test "${defval,,}" = "y" &&
yn="Yn" yn="Yn"
REPLY= 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" ] while [ "${REPLY}" != "y" -a "${REPLY}" != "n" ]
do do
read -s -n 1 -p "${*}? [${yn}]: " read -s -n 1 -p "${*}? [${yn}]: "
...@@ -50,14 +46,14 @@ function yesno ...@@ -50,14 +46,14 @@ function yesno
} }
# For getting a recent nodejs # For getting a recent nodejs
function nodejs_pre function nodejs_pre
{ {
info nodejs info nodejs
pkgs="$pkgs nodejs" pkgs="$pkgs nodejs"
# Nodejs software repository PGP key # Nodejs software repository PGP key
if [ `apt-key export ${NODEJSPGP} 2>&1 | wc -l` -le 50 ] if [ `apt-key export ${NODEJSPGP} 2>&1 | wc -l` -le 50 ]
then 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} apt-key adv --keyserver keyserver.ubuntu.com --recv ${NODEJSPGP}
fi fi
local file=/etc/apt/sources.list.d/nodejs.list local file=/etc/apt/sources.list.d/nodejs.list
...@@ -70,18 +66,18 @@ function nodejs_pre ...@@ -70,18 +66,18 @@ function nodejs_pre
fi fi
} }
function nodejs_post function nodejs_post
{ {
info Initialising nodejs. info Initialising nodejs.
test -r "package.json" || test -r "package.json" ||
npm init -y npm init -y
# nodejs package(s) that we need. # nodejs package(s) that we need.
nodejs -e 'require("web3")' 2>/dev/null && return nodejs -e 'require("web3")' 2>/dev/null && return
yesno y Installing nodejs module: web3 yesno n Installing nodejs module: web3
npm install web3 npm install web3
} }
function golang_pre function golang_pre
{ {
unset installedusrlocalgo unset installedusrlocalgo
if [ ! -d /usr/local/go ] if [ ! -d /usr/local/go ]
...@@ -129,7 +125,7 @@ function golang_pre ...@@ -129,7 +125,7 @@ function golang_pre
PATH=${PATH}:/usr/local/go/bin PATH=${PATH}:/usr/local/go/bin
} }
function geth_pre function geth_pre
{ {
mkdir -p ~/new mkdir -p ~/new
cd ~/new cd ~/new
...@@ -141,21 +137,21 @@ function geth_pre ...@@ -141,21 +137,21 @@ function geth_pre
git pull git pull
} }
function geth_compile function geth_compile
{ {
cd ~/new/go-ethereum cd ~/new/go-ethereum
info Compiling geth info Compiling geth
make all make geth
} }
function geth_post function geth_post
{ {
mkdir -p ~bfa/bin 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 chown -R bfa:bfa ~bfa
} }
function aptinstall function aptinstall
{ {
local inst= local inst=
for pkg in $pkgs for pkg in $pkgs
...@@ -167,9 +163,9 @@ function aptinstall ...@@ -167,9 +163,9 @@ function aptinstall
apt --install-suggests -y install $inst || true 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 then
info Adding BFA user \"bfa\". info Adding BFA user \"bfa\".
adduser --disabled-password --gecos 'Blockchain Federal Argentina' bfa adduser --disabled-password --gecos 'Blockchain Federal Argentina' bfa
...@@ -192,7 +188,7 @@ function usersetup ...@@ -192,7 +188,7 @@ function usersetup
fi fi
} }
function golang_post function golang_post
{ {
if [ -n "${installedusrlocalgo}" ] if [ -n "${installedusrlocalgo}" ]
then then
...@@ -201,16 +197,16 @@ function golang_post ...@@ -201,16 +197,16 @@ function golang_post
fi fi
} }
function cronit function cronit
{ {
if crontab -u bfa -l | expand | grep -qvE '^@reboot +bfa/bin/cron.sh$' if crontab -u bfa -l | expand | grep -qvE '^@reboot +bfa/bin/cron.sh$'
then 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 - ( crontab -u bfa -l ; echo '@reboot bfa/bin/cron.sh' ) | crontab -u bfa -
fi fi
} }
function welcome function welcome
{ {
echo echo
echo "(re)log in as user bfa" echo "(re)log in as user bfa"
...@@ -227,6 +223,6 @@ golang_pre ...@@ -227,6 +223,6 @@ golang_pre
geth_pre geth_pre
geth_compile geth_compile
geth_post geth_post
#golang_post golang_post
cronit cronit
welcome welcome
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment