Skip to content

Commit

Permalink
IBFT init script
Browse files Browse the repository at this point in the history
  • Loading branch information
arocha committed Dec 18, 2017
1 parent d9d6f73 commit 89f742d
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 10 deletions.
52 changes: 42 additions & 10 deletions scripts/init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ MESSAGE='Usage: init <mode> <node-type> <node-name>
node-type: validator | general
node-name: NODE_NAME (example: Alastria)'

if ( [ $# -ne 4 ] ); then
if ( [ $# -ne 3 ] ); then
echo "$MESSAGE"
exit
fi
Expand All @@ -23,7 +23,7 @@ if ( [ "auto" == "$1" -o "backup" == "$1" ]); then
fi

if ( [ "backup" == "$1" ]); then
echo "Backuping current node keys ..."
echo "Backing up current node keys ..."
#Backup directory tree
mkdir ~/alastria-keysBackup
mkdir ~/alastria-keysBackup/data
Expand All @@ -40,15 +40,42 @@ fi
PWD="$(pwd)"
CONSTELLATION_NODES=$(cat ../data/constellation-nodes.json)
STATIC_NODES=$(cat ../data/static-nodes.json)
PERMISSIONED_NODES_VALIDATOR=$(CAT ../data/permissioned-nodes_validator.json)
PERMISSIONED_NODES_GENERAL=$(CAT ../data/permissioned-nodes_general.json)
PERMISSIONED_NODES_VALIDATOR=$(cat ../data/permissioned-nodes_validator.json)
PERMISSIONED_NODES_GENERAL=$(cat ../data/permissioned-nodes_general.json)

update_constellation_nodes() {
NODE_IP="$1"
CONSTELLATION_PORT="$2"
URL=",
\"http://$NODE_IP:$CONSTELLATION_PORT/\"
]"
CONSTELLATION_NODES=${CONSTELLATION_NODES::-2}
CONSTELLATION_NODES="$CONSTELLATION_NODES$URL"
echo "$CONSTELLATION_NODES" > ~/alastria-node/data/constellation-nodes.json
}

update_nodes_list() {
echo "Selected $NODE_TYPE node..."
echo "Updating permissioned nodes..."

ENODE=",
\"$1\"
]"
PERMISSIONED_NODES_VALIDATOR=${PERMISSIONED_NODES_VALIDATOR::-2}
PERMISSIONED_NODES_VALIDATOR="$PERMISSIONED_NODES_VALIDATOR$ENODE"
echo "$PERMISSIONED_NODES_VALIDATOR" > ~/alastria-node/data/permissioned-nodes_validator.json

if ( [ "validator" == "$NODE_TYPE" ]); then
PERMISSIONED_NODES_GENERAL=${PERMISSIONED_NODES_GENERAL::-2}
PERMISSIONED_NODES_GENERAL="$PERMISSIONED_NODES_GENERAL$ENODE"
echo "$PERMISSIONED_NODES_GENERAL" > ~/alastria-node/data/permissioned-nodes_general.json
fi

echo "Updating static-nodes..."
cp ~/alastria-node/data/permissioned-nodes_general.json ~/alastria-node/data/static-nodes.json

}

echo "$NODE_TYPE" > ~/alastria/data/NODE_TYPE
if ( [ "validator" == "$NODE_TYPE" ]); then
echo "Selected node type validator..."
elif ( [ "general" == "$NODE_TYPE" ]); then
echo "Selected node type validator..."
fi

generate_conf() {
#define parameters which are passed in.
Expand Down Expand Up @@ -103,6 +130,9 @@ mkdir -p ~/alastria/data/{keystore,geth,constellation}
mkdir -p ~/alastria/data/constellation/{data,keystore}
mkdir -p ~/alastria/logs

echo "$NODE_NAME" > ~/alastria/data/IDENTITY
echo "$NODE_TYPE" > ~/alastria/data/NODE_TYPE

# Creamos el fichero de passwords con la contraseña de las cuentas
echo "Passw0rd" > ~/alastria/data/passwords.txt

Expand All @@ -112,6 +142,7 @@ cd ~/alastria/data/geth
bootnode -genkey nodekey
ENODE_KEY=$(bootnode -nodekey nodekey -writeaddress)
echo "ENODE -> 'enode://${ENODE_KEY}@${CURRENT_HOST_IP}:21000?raftport=41000'"
update_nodes_list "enode://${ENODE_KEY}@${CURRENT_HOST_IP}:21000?raftport=41000"
cd ~
if [[ "$CURRENT_HOST_IP" == "52.56.69.220" ]]; then
cp ~/alastria-node/data/static-nodes.json ~/alastria/data/static-nodes.json
Expand All @@ -122,6 +153,7 @@ echo " Por favor, introduzca como contraseña 'Passw0rd'."
geth --datadir ~/alastria/data account new

echo "[*] Initializing Constellation node."
update_constellation_nodes "${CURRENT_HOST_IP}" "9000"
generate_conf "${CURRENT_HOST_IP}" "9000" "$CONSTELLATION_NODES" "${PWD}" > ~/alastria/data/constellation/constellation.conf
cd ~/alastria/data/constellation/keystore
cat ~/alastria/data/passwords.txt | constellation-node --generatekeys=node
Expand Down
Empty file removed scripts/nohup.out
Empty file.

0 comments on commit 89f742d

Please sign in to comment.