Skip to content

Commit

Permalink
Added autoup script to automaticallytake down the network as needed, …
Browse files Browse the repository at this point in the history
…and then install or upgrade as appropriate.
  • Loading branch information
mcoblenz committed Sep 2, 2019
1 parent 4357098 commit 73f161e
Show file tree
Hide file tree
Showing 60 changed files with 14,055 additions and 10 deletions.
13 changes: 13 additions & 0 deletions bin/obsidianautoup
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/usr/bin/env bash

bin_dir="$(cd "$(dirname $BASH_SOURCE)"; pwd)"
root_dir="$bin_dir/.."
export OBSIDIAN_COMPILER_DIR="$root_dir"

network_framework="${root_dir}/network-framework"

cd ${network_framework}

${root_dir}/network-framework/autoup.sh $@


4 changes: 2 additions & 2 deletions network-framework/.env
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
COMPOSE_PROJECT_NAME=net
IMAGE_TAG=latest
CHAINCODE_DIRECTORY=GenericsStateVariables

CHAINCODE_DIRECTORY=/Users/mcoblenz/code/Obsidian/evaluation/pilot6/auction-exercises/build/Auction
CHAINCODE_NAME=Auction
81 changes: 81 additions & 0 deletions network-framework/autoup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
#!/bin/bash
# This script invokes either up.sh or upgrade.sh, depending on whether the network is running.

function checkNetworkIsUp() {
CLI=$(docker ps -f name=cli -q)
if [ -n "$CLI" ]; then
NETWORKISUP=1
else
echo "no network"
NETWORKISUP=0
fi

}

function printHelp() {
echo "autoup.sh conditionally starts a new Fabric network or upgrades an existing one."
echo "Usage: "
echo " autoup.sh -s <chaincodedirectory>"
echo " -s <chaincodedirectory> - the path to the chaincode directory"
}

CD=default

while getopts "h?c:t:d:f:s:l:i:v:n:" opt; do
case "$opt" in
h | \?)
printHelp
exit 0
;;
c)
CHANNEL_NAME=$OPTARG
;;
t)
CLI_TIMEOUT=$OPTARG
;;
d)
CLI_DELAY=$OPTARG./
;;
f)
COMPOSE_FILE=$OPTARG
;;
s)
CD=${OPTARG}
;;
l)
LANGUAGE=$OPTARG
;;
i)
IMAGETAG=$(go env GOARCH)"-"$OPTARG
;;
v)
VERBOSE=true
;;
n)
if [ -n "$INIT" ]; then
INIT="${INIT},\"${OPTARG}\""
else
INIT="\"${OPTARG}\""
fi
;;
esac
done

checkNetworkIsUp
NETWORKDIR=$(dirname $BASH_SOURCE)

# Find out if this is the same chaincode path as before.
FOUND=$(grep -c -e "^${CD}$" .env)
if [ $? -eq 0 ]; then #same chaincode path as before
if [ $NETWORKISUP -ne 0 ]; then
echo "network is up; upgrading"
${NETWORKDIR}/upgrade.sh
else
echo "network down; starting"
${NETWORKDIR}/up.sh $@
fi
else
echo "different chaincode; restarting"
${NETWORKDIR}/down.sh
${NETWORKDIR}/up.sh $@
fi
4 changes: 2 additions & 2 deletions network-framework/docker-compose-cli.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,12 @@ services:
- CORE_PEER_TLS_KEY_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/server.key
- CORE_PEER_TLS_ROOTCERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt
- CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp
- CC_SRC_PATH=/opt/gopath/src/github.com/$CHAINCODE_DIRECTORY/
- CC_SRC_PATH=/opt/gopath/src/github.com/$CHAINCODE_NAME/
working_dir: /opt/gopath/src/github.com/hyperledger/fabric/peer
command: /bin/bash
volumes:
- /var/run/:/host/var/run/
- ./../$CHAINCODE_DIRECTORY/:/opt/gopath/src/github.com/$CHAINCODE_DIRECTORY
- $CHAINCODE_DIRECTORY/:/opt/gopath/src/github.com/$CHAINCODE_NAME
- ./crypto-config:/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/
- ./scripts:/opt/gopath/src/github.com/hyperledger/fabric/peer/scripts/
- ./channel-artifacts:/opt/gopath/src/github.com/hyperledger/fabric/peer/channel-artifacts
Expand Down
6 changes: 4 additions & 2 deletions network-framework/up.sh
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,10 @@ function checkPrereqs() {
# Generate the needed certificates, the genesis block and start the network.
function networkUp() {
checkPrereqs
# replace the chaincode directory in the .evn file
sed -i.backup "s/^.*CHAINCODE_DIRECTORY=.*$/CHAINCODE_DIRECTORY=${CD}/" .env
CHAINCODE_NAME=$(basename ${CD})
# replace the chaincode directory in the .env file
sed -i.backup "s,^.*CHAINCODE_DIRECTORY=.*$,CHAINCODE_DIRECTORY=${CD}," .env
sed -i.backup "s,^.*CHAINCODE_NAME=.*$,CHAINCODE_NAME=${CHAINCODE_NAME}," .env
rm .env.backup
# generate artifacts if they don't exist
if [ ! -d "crypto-config" ]; then
Expand Down
21 changes: 21 additions & 0 deletions obs-vscode-extension/node_modules/@types/node/LICENSE

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 16 additions & 0 deletions obs-vscode-extension/node_modules/@types/node/README.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

52 changes: 52 additions & 0 deletions obs-vscode-extension/node_modules/@types/node/assert.d.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

144 changes: 144 additions & 0 deletions obs-vscode-extension/node_modules/@types/node/async_hooks.d.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 73f161e

Please sign in to comment.