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