Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adding a few more flags/options to the bootstrap script #498

Merged
merged 2 commits into from
Jun 16, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 27 additions & 5 deletions scripts/bootstrap
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
CLI=jcli
NODE=jormungandr
COLORS=1
CLEAN=0
DPATH="${PWD}"
REST_PREFIX="api"
REST_HOST="127.0.0.1"
REST_PORT="8443"
Expand All @@ -33,7 +35,7 @@ SECRET_PATH="."
CONFIG_PATH="."
ADD_STARTUP_SCRIPT=0

while getopts 'bc:d:ghk:p:s:xC' c
while getopts 'bc:d:ghk:p:s:xCod' c
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there's already a d:, the ending d shouldn't be there

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will fix

do
case $c in
b) CONSENSUS="bft" ;;
Expand All @@ -44,6 +46,8 @@ do
x) ADD_STARTUP_SCRIPT=1 ;;
s) SLOT_DURATION="${OPTARG}" ;;
C) COLORS=0 ;;
o) CLEAN=1 ;;
d) DPATH="${OPTARG}" ;;
h)
echo "usage: $0"
echo " [-p <REST_PORT>] [-b] [g]"
Expand All @@ -56,19 +60,35 @@ do
echo " -x Add startup script"
echo " -k <SECRET-PATH> The path to write secret files"
echo " -c <CONFIG-PATH> The path to write config files"
echo " -d <DATA-PATH> The path to write sqlite files"
echo " -s <SLOT-DURATION> Duration of a slot in seconds"
echo " -C Disable ansi shell colours in stdout"
echo " -o Overwrite existing sqlite files"
exit 0
;;
esac
done

STORAGE="${DPATH}/jormungandr-storage-test"

[ -n "${REST_PORT}" ] && [ "${REST_PORT}" -eq "${REST_PORT}" ] 2>/dev/null
if [ $? -ne 0 ]; then
echo "error: ${REST_PORT} is not valid number"
exit 1
fi

if [ ${CLEAN} -eq 0 ] && [ -f ${STORAGE}/blocks.sqlite ]; then
echo "error: directory ${STORAGE} contains blocks.sqlite already, use -o to overwrite"
exit 1
elif [ ${CLEAN} -eq 1 ] && [ -f ${STORAGE}/blocks.sqlite ]; then
find ${STORAGE} -type f -exec rm {} \;
fi

if [ ! -d ${DPATH} ] || [ ! -w ${DPATH} ]; then
echo "error: path to store (${DPATH}) sqlite files does not exist or your user does not have write permission"
exit 1
fi

REST_DEST="${REST_HOST}:${REST_PORT}"
REST_URL="http://${REST_DEST}/${REST_PREFIX}"

Expand Down Expand Up @@ -195,7 +215,7 @@ bft:
EOF

cat << EOF > ${CONFIG_PATH}/config.yaml
storage: "${PWD}/jormungandr-storage-test/"
storage: "${STORAGE}/"

rest:
listen: "${REST_DEST}"
Expand All @@ -215,15 +235,18 @@ if [ $? -ne 0 ]; then
exit 1
fi

BLOCK0_HASH=$($CLI genesis hash --input ${CONFIG_PATH}/block-0.bin)

### PRINT

echo "faucet account: ${GREEN}${FAUCET_ADDR}${WHITE}"
echo " * public: ${BLUE}${FAUCET_PK}${WHITE}"
echo " * secret: ${RED}${FAUCET_SK}${WHITE}"
echo " * amount: ${GREEN}${FAUCET_AMOUNT}${WHITE}"

echo
echo "pool id: ${GREEN}${STAKE_POOL_ID}${WHITE}"

echo "block-0 hash: ${BLUE}${BLOCK0_HASH}${BLUE}"
echo
echo "To start the node:"
if [ $ADD_STARTUP_SCRIPT -eq 1 ]; then
echo "$NODE --genesis-block ${CONFIG_PATH}/block-0.bin --config ${CONFIG_PATH}/config.yaml --secret ${SECRET_PATH}/pool-secret1.yaml" > startup_script.sh
Expand All @@ -241,7 +264,6 @@ SCRIPTPATH="$( cd "$(dirname "$0")" ; pwd -P )"
if [ ! -f "$SCRIPTPATH/faucet-send-money.shtempl" ] || [ ! -f "$SCRIPTPATH/faucet-send-certificate.shtempl" ]; then
echo "warning: cannot find faucet-send-money or faucet-send-certificate template: skipping !"
else
BLOCK0_HASH=$($CLI genesis hash --input ${CONFIG_PATH}/block-0.bin)

function process_file {
FROM=${1}
Expand Down