Created
January 2, 2019 05:40
-
-
Save 26rahulsingh/7f974aeb5ee5e2511f6b45c1d4a4b6a8 to your computer and use it in GitHub Desktop.
This script sets up a network map using docker and registers a notary and a regular node that are run using java.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# This example sets up a network map using docker and registers a notary and a regular node that are run using java | |
# Make sure your node's node.conf has the following: | |
# | |
# compatibilityZoneURL="http://localhost:8080" | |
# devMode=false | |
# keyStorePassword="cordacadevpass" | |
# trustStorePassword="trustpass" | |
############################################### | |
## ALTER THESE VARIABLES FOR YOUR USECASE ## | |
############################################### | |
# set this to a local directory that you want the NMS to store its data - at the moment, you need to do this in order to update the database with whitelisted notaries | |
NMSDB="${HOME}/tmp/nms" | |
# set this to the location of the corda node directory | |
CORDA_NODE="${HOME}/work/corda-app/kotlin-source/build/nodes" | |
# set this to the lcoation of the notary node directory | |
CORDA_NOTARY_NODE="${HOME}/work/corda-app/kotlin-source/build/nodes/Notary" | |
echo "storing database to ${NMSDB}" | |
echo "corda node directory: ${CORDA_NODE}" | |
echo "corda notary node directory: ${CORDA_NOTARY_NODE}" | |
# prepare a directory for the NMS' database | |
mkdir -p ${NMSDB} | |
echo | |
echo "###############################################" | |
echo "clearing any processes that may get in the way" | |
echo "###############################################" | |
echo "killing java processes" | |
killall java | |
echo "killing any network-map containers" | |
docker stop $(docker ps -q -f name=network-map) | |
docker rm $(docker ps -aq -f name=network-map) | |
echo | |
echo "########################" | |
echo "starting up network-map" | |
echo "########################" | |
docker run -p 8080:8080 -v ${NMSDB}:/opt/nms/db -e NMS_TLS=false -e NMS_DB=/opt/nms/db -e NMS_PARAM_UPDATE_DELAY=1S --name network-map -d cordite/network-map:v0.3.0 | |
echo "waiting for network map to initialise" | |
until $(curl --output /dev/null --silent --head --fail -X GET http://localhost:8080/admin/api/whitelist -H "accept: text/plain"); do | |
printf '.' | |
sleep 1 | |
done | |
echo | |
echo "network map ready" | |
echo | |
echo "#######################################" | |
echo "registering nodes via doorman protocol" | |
echo "#######################################" | |
echo "corda node doorman registration" | |
cd "$CORDA_NODE" | |
echo "clearing node's certificates" | |
rm -rf ./certificates/*.jks | |
rm -f nodeInfo-* | |
rm -f network-parameters | |
rm -f persistence.mv.db | |
echo "downloading networkmap's truststore" | |
curl http://localhost:8080/network-map/truststore -o ./certificates/network-root-truststore.jks | |
echo "registering node via doorman" | |
java -jar corda.jar --initial-registration --network-root-truststore-password trustpass --network-root-truststore certificates/network-root-truststore.jks | |
echo "corda node doorman registration" | |
cd "$CORDA_NOTARY_NODE" | |
echo "clearing notary's certificates, nodeInfo, database, network-parameters" | |
rm -rf ./certificates/*.jks | |
rm -f nodeInfo-* | |
rm -f network-parameters | |
rm -f persistence.mv.db | |
echo "downloading networkmap's truststore" | |
curl http://localhost:8080/network-map/truststore -o ./certificates/network-root-truststore.jks | |
echo "registering notary via doorman" | |
java -jar corda.jar --initial-registration --network-root-truststore-password trustpass --network-root-truststore certificates/network-root-truststore.jks | |
echo | |
echo "####################################################" | |
echo "registering notary as a whitelisted, global, notary" | |
echo "####################################################" | |
echo "generating notary nodeInfo" | |
java -jar corda.jar --just-generate-node-info | |
echo "copying notary nodeInfo to NMS to officially whitelist it as global notary" | |
cp nodeInfo-* "${NMSDB}/inputs/validating-notaries/" | |
echo "waiting for the network map to apply notary to the network-parameters" | |
sleep 5 # we do this based on the env variables passed to the network map (via docker) | |
echo | |
echo "#######################" | |
echo "starting up the notary" | |
echo "#######################" | |
cd "${CORDA_NOTARY_NODE}" | |
java -jar corda.jar --no-local-shell & | |
echo "starting up the node" | |
cd "${CORDA_NODE}" | |
java -jar corda.jar --no-local-shell & |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment