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

bootnode option in admin.sh

parent a8c4342d
No related branches found
No related tags found
No related merge requests found
......@@ -4,7 +4,7 @@
if [ -z "${BFAHOME}" ]; then echo "\$BFAHOME not set. Did you source bfa/bin/env ?" >&2; exit 1; fi
source ${BFAHOME}/bin/libbfa.sh || exit 1
defaultmode="fast"
defaultsyncmode="fast"
function modefilter
{
......@@ -20,6 +20,8 @@ function modefilter
true
}
function admin_syncmode
{
echo "Available synchronization modes:"
echo " full : verify all blocks and all transactions since genesis (most secure)"
echo " fast : verify all blocks but not all transactions (faster than full, but less certain)"
......@@ -32,7 +34,7 @@ echo "between speed and paranoia. You can change the setting, according to"
echo "your needs."
mode=$( cat ${BFANODEDIR}/syncmode 2>/dev/null || true )
mode=${mode:-${defaultmode}}
mode=${mode:-${defaultsyncmode}}
orgmode=$mode
modefilter
echo "Your current mode is set to ${mode}"
......@@ -53,12 +55,7 @@ then
echo "fast mode, and revalidate everything in the entire blockchain."
echo "This probably takes quite a long time and also requires downloading"
echo "all blocks from the entire blockchain again."
REPLY=
while [ "$REPLY" != "y" -a "$REPLY" != "n" ]
do
read -p "Do you wish to delete all downloaded blocks and resynchronize? [yn]: "
REPLY=${REPLY,,}
done
yesno n "Do you wish to delete all downloaded blocks and resynchronize?"
if [ "$REPLY" = "y" ]
then
if [ -r "${BFANODEDIR}/geth.pid" ]
......@@ -79,3 +76,52 @@ then
echo "The startup.sh should restart your geth shortly."
fi
fi
}
function admin_bootnode
{
keyfile=${BFANETWORKDIR}/bootnode/key
echo "Only very few wants to actually run a boot node."
echo "If you have a keyfile for a bootnode, then you will"
echo "automatically start one, when restarting your system."
if [ -f $keyfile ]
then
echo "You are set up to run a boot node."
echo "Deleting your bootnode keyfile disables your bootnode."
yesno n "Do you want to delete your bootnode keyfile?"
if [ "$REPLY" = "y" ]
then
rm $keyfile
fi
pidfile=${BFANETWORKDIR}/bootnode/pid
if [ -r $pidfile ]
then
pid=`cat $pidfile`
kill -0 $pid &&
echo "Terminating your bootnode." &&
kill `cat $pidfile` ||
true
fi
else
echo "You are not set up to run a boot node."
yesno n "Do you want to create a keyfile for a bootnode?"
if [ "$REPLY" = "y" ]
then
bootnode -genkey $keyfile
fi
echo "You can now start your bootnode by running start.sh"
fi
}
case "$1" in
bootnode)
admin_bootnode
;;
syncmode)
admin_syncmode
;;
*)
echo Usage: `basename $0` "{bootnode|syncmode}"
trap '' ERR
exit 1
esac
......@@ -57,7 +57,7 @@ function web3install
)
# nodejs package(s) that we need.
echo 'require("web3")' | sudo --set-home -u bfa nodejs 2>/dev/null && return
info Installing nodejs module: web3
info Installing nodejs module: web3 "(will show many warnings)"
sudo --set-home -u bfa npm install web3
}
......
......@@ -21,6 +21,22 @@ test -n "$BASH_VERSION" ||
test "$( caller 2>/dev/null | awk '{print $1}' )" != "0" ||
fatal "This file must be source(d), not executed."
function yesno
{
local defreply=${1,,}
local yn=Yn
test "$defreply" = "n" &&
yn=yN
shift
REPLY=
read -p "$* [${yn}]: " -n 1 -e
REPLY=${REPLY,,}
if [ "$REPLY" != "y" -a "$REPLY" != "n" ]
then
REPLY=$defreply
fi
}
function cleanup
{
if [ $# -gt 0 ]
......
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