-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathinitialize_chain.sh
executable file
·49 lines (47 loc) · 1014 Bytes
/
initialize_chain.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# !/bin/bash
# by Austin Hester
# Initializes geth chain with genesis.json
CURR=`dirname $0`
if [ -e $CURR/genesis.json ]; then
read -p "Are you sure you want to initialize the chain? (yes/no):" -r
echo
if [[ $REPLY == "yes" ]]
then
# bootstrap node
BOOT=$CURR/bootstrap
if ! [ -d $BOOT ]; then
mkdir -p $BOOT
fi
if ! [ -d $BOOT/geth ]; then
geth --datadir ./bootstrap init genesis.json
else
echo "bootstrap already initialized."
fi
# miner 1
MINER1=$CURR/miner1
if ! [ -d $MINER1 ]; then
mkdir -p $MINER1
fi
if ! [ -d $MINER1/geth ]; then
geth --datadir ./miner1 init genesis.json
else
echo "miner1 already initialized."
fi
# miner 2
MINER2=$CURR/miner2
if ! [ -d $MINER2 ]; then
mkdir -p $MINER2
fi
if ! [ -d $MINER2/geth ]; then
geth --datadir ./miner2 init genesis.json
else
echo "miner2 already initialized."
fi
echo "Done."
else
echo "quitting"
fi
else
echo "File "$CURR/genesis.json" not found."
echo "Generate genesis.json by running ./generate_genesis.sh"
fi