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

Enable automatically running the installation.

parent 58fd7ce9
No related branches found
No related tags found
No related merge requests found
......@@ -4,8 +4,6 @@ NODEJSPGP=0x68576280
trap 'exit 1' ERR
set -o errtrace
# Be verbose
set -e
if [ `id -u` -ne 0 ]
then
......@@ -28,6 +26,12 @@ 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}]: "
......@@ -46,14 +50,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 n Add nodejs software repository PGP key &&
yesno y 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
......@@ -66,18 +70,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 n Installing nodejs module: web3
yesno y Installing nodejs module: web3
npm install web3
}
function golang_pre
function golang_pre
{
unset installedusrlocalgo
if [ ! -d /usr/local/go ]
......@@ -125,7 +129,7 @@ function golang_pre
PATH=${PATH}:/usr/local/go/bin
}
function geth_pre
function geth_pre
{
mkdir -p ~/new
cd ~/new
......@@ -137,21 +141,21 @@ function geth_pre
git pull
}
function geth_compile
function geth_compile
{
cd ~/new/go-ethereum
info Compiling geth
make geth
make all
}
function geth_post
function geth_post
{
mkdir -p ~bfa/bin
cp -vp ~/new/go-ethereum/build/bin/geth ~bfa/bin/
cp -vp ~/new/go-ethereum/build/bin/{geth,bootnode,puppeth} ~bfa/bin/
chown -R bfa:bfa ~bfa
}
function aptinstall
function aptinstall
{
local inst=
for pkg in $pkgs
......@@ -163,9 +167,9 @@ function aptinstall
apt --install-suggests -y install $inst || true
}
function usersetup
function usersetup
{
if echo ~bfa | grep -qvE '^/' && yesno n Add required user \"bfa\"
if echo ~bfa | grep -qvE '^/' && yesno y Add required user \"bfa\"
then
info Adding BFA user \"bfa\".
adduser --disabled-password --gecos 'Blockchain Federal Argentina' bfa
......@@ -188,7 +192,7 @@ function usersetup
fi
}
function golang_post
function golang_post
{
if [ -n "${installedusrlocalgo}" ]
then
......@@ -197,16 +201,16 @@ function golang_post
fi
}
function cronit
function cronit
{
if crontab -u bfa -l | expand | grep -qvE '^@reboot +bfa/bin/cron.sh$'
then
yesno n Install crontab to start automatically upon reboot || return
yesno y 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"
......@@ -223,6 +227,6 @@ golang_pre
geth_pre
geth_compile
geth_post
golang_post
#golang_post
cronit
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