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

grep -v does not return a reliable return code?

parent 3e39f6cd
No related branches found
No related tags found
No related merge requests found
...@@ -165,7 +165,7 @@ function usersetup ...@@ -165,7 +165,7 @@ function usersetup
function cronit function cronit
{ {
if crontab -u bfa -l 2>/dev/null | expand | grep -qvE '^@reboot +bfa/bin/cron.sh$' if [ $( crontab -u bfa -l 2>/dev/null | expand | grep -E 'bfa/bin/cron.sh$' | wc -l ) -eq 0 ]
then then
info Install crontab to start automatically upon reboot info Install crontab to start automatically upon reboot
( 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 -
......
...@@ -16,11 +16,6 @@ test -n "$BASH_VERSION" || ...@@ -16,11 +16,6 @@ test -n "$BASH_VERSION" ||
test "$( caller 2>/dev/null | awk '{print $1}' )" != "0" || test "$( caller 2>/dev/null | awk '{print $1}' )" != "0" ||
fatal "This file must be source(d), not executed." fatal "This file must be source(d), not executed."
function stderr
{
echo "$@" >&2
}
function cleanup function cleanup
{ {
if [ $# -gt 0 ] if [ $# -gt 0 ]
...@@ -148,58 +143,53 @@ function contractSendTx ...@@ -148,58 +143,53 @@ function contractSendTx
############### ###############
# bfainit # # bfainit #
test -n "${BFAHOME}" -a \ test -n "${BFAHOME}" -a \
-d "${BFAHOME}" || -d "${BFAHOME}" ||
fatal "\$BFAHOME in your environment must point to a directory." fatal "\$BFAHOME in your environment must point to a directory."
# #
# BFANETWORKID # BFANETWORKID
test -n "${BFANETWORKID}" || BFANETWORKID=47525974938 test -n "${BFANETWORKID}" || BFANETWORKID=47525974938
# #
# BFANETWORKDIR # BFANETWORKDIR
test -n "${BFANETWORKDIR}" || BFANETWORKDIR="${BFAHOME}/network" test -n "${BFANETWORKDIR}" || BFANETWORKDIR="${BFAHOME}/network"
mkdir -p "${BFANETWORKDIR}" mkdir -p "${BFANETWORKDIR}"
test -d "${BFANETWORKDIR}" || fatal "\$BFANETWORKDIR (\"${BFANETWORKDIR}\") not found." test -d "${BFANETWORKDIR}" || fatal "\$BFANETWORKDIR (\"${BFANETWORKDIR}\") not found."
# #
# BFANODEDIR # BFANODEDIR
test -n "$BFANODEDIR" || BFANODEDIR="${BFANETWORKDIR}/node" test -n "$BFANODEDIR" || BFANODEDIR="${BFANETWORKDIR}/node"
if [ ! -d "${BFANODEDIR}" ] if [ ! -d "${BFANODEDIR}" -o ! -d "${BFANODEDIR}/geth/chaindata" ]
then then
echo "Node directory not found. Initialising a new node." echo "Node is not initialised. Initialising with BFA genesis."
geth --datadir ${BFANODEDIR} init ${BFAHOME}/src/genesis.json geth --cache 0 --datadir "${BFANODEDIR}" init "${BFAHOME}/src/genesis.json"
fi fi
if [ ! -d "${BFANODEDIR}/geth/chaindata" ] #
then # netport
echo "Node is not initialised. Initialising with BFA genesis." netport=30303
geth --datadir "${BFANODEDIR}" init "${BFAHOME}/src/genesis.json" if [ -r "${BFANODEDIR}/netport" ]
fi then
# netport=$( cat ${BFANODEDIR}/netport )
# netport test $? = 0
netport=30303 fi
if [ -r "${BFANODEDIR}/netport" ] #
then # rpcport
netport=$( cat ${BFANODEDIR}/netport ) rpcport=8545
test $? = 0 if [ -r "${BFANODEDIR}/rpcport" ]
fi then
# rpcport=$( cat ${BFANODEDIR}/rpcport )
# rpcport test $? = 0
rpcport=8545 fi
if [ -r "${BFANODEDIR}/rpcport" ] #
# BFAACCOUNT
if [ -z "$BFAACCOUNT" ]
then
if [ ! -d "${BFANODEDIR}/keystore" ]
then then
rpcport=$( cat ${BFANODEDIR}/rpcport ) echo "No accounts found. Creating a new one (they are free)."
test $? = 0 geth --cache 0 --datadir ${BFANODEDIR} --password /dev/null account new
fi
#
# BFAACCOUNT
if [ -z "$BFAACCOUNT" ]
then
if [ ! -d "${BFANODEDIR}/keystore" ]
then
echo "No accounts found. Creating a new one (they are free)."
geth --cache 0 --datadir ${BFANODEDIR} --password /dev/null account new
fi
BFAACCOUNT=$(
ls -1dl "${BFANODEDIR}"/keystore/*--* 2>/dev/null |
head -1 |
sed 's/.*--//'
)
fi fi
BFAACCOUNT=$(
ls -1d "${BFANODEDIR}"/keystore/*--* 2>/dev/null |
head -1 |
sed 's/.*--//'
)
fi
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