diff --git a/ci/azure-pipelines.yml b/ci/azure-pipelines.yml index f3ce962f..c1ace394 100644 --- a/ci/azure-pipelines.yml +++ b/ci/azure-pipelines.yml @@ -98,6 +98,8 @@ jobs: inputs: versionSpec: $(NODE_VER) displayName: Install Node.js + - script: ./ci/scripts/shellcheck.sh + displayName: Lint Shell Scripts - script: ./ci/scripts/lint.sh displayName: Lint Code diff --git a/ci/scripts/shellcheck.sh b/ci/scripts/shellcheck.sh new file mode 100755 index 00000000..2330162a --- /dev/null +++ b/ci/scripts/shellcheck.sh @@ -0,0 +1,8 @@ +#!/bin/bash +set -euo pipefail + +scversion="v0.8.0" # or "stable", or "latest" +wget -qO- "https://github.com/koalaman/shellcheck/releases/download/${scversion?}/shellcheck-${scversion?}.linux.x86_64.tar.xz" | tar -xJv "shellcheck-${scversion}/shellcheck" +"./shellcheck-${scversion}/shellcheck" --version + +"./shellcheck-${scversion}/shellcheck" ./test-network-nano-bash/*.sh diff --git a/test-network-nano-bash/generate_artifacts.sh b/test-network-nano-bash/generate_artifacts.sh index bf832367..4a605961 100755 --- a/test-network-nano-bash/generate_artifacts.sh +++ b/test-network-nano-bash/generate_artifacts.sh @@ -1,5 +1,5 @@ -#!/usr/bin/env bash -set -euo pipefail +#!/usr/bin/env sh +set -eu # remove existing artifacts, or proceed on if the directories don't exist rm -r "${PWD}"/channel-artifacts || true diff --git a/test-network-nano-bash/orderer1.sh b/test-network-nano-bash/orderer1.sh index c06612e0..9ff8b258 100755 --- a/test-network-nano-bash/orderer1.sh +++ b/test-network-nano-bash/orderer1.sh @@ -1,5 +1,5 @@ -#!/usr/bin/env bash -set -euo pipefail +#!/usr/bin/env sh +set -eu # look for binaries in local dev environment /build/bin directory and then in local samples /bin directory export PATH="${PWD}"/../../fabric/build/bin:"${PWD}"/../bin:"$PATH" diff --git a/test-network-nano-bash/orderer2.sh b/test-network-nano-bash/orderer2.sh index 65a135e0..edb1a432 100755 --- a/test-network-nano-bash/orderer2.sh +++ b/test-network-nano-bash/orderer2.sh @@ -1,5 +1,5 @@ -#!/usr/bin/env bash -set -euo pipefail +#!/usr/bin/env sh +set -eu # look for binaries in local dev environment /build/bin directory and then in local samples /bin directory export PATH="${PWD}"/../../fabric/build/bin:"${PWD}"/../bin:"$PATH" diff --git a/test-network-nano-bash/orderer3.sh b/test-network-nano-bash/orderer3.sh index 6f2bb4c6..9c5c1481 100755 --- a/test-network-nano-bash/orderer3.sh +++ b/test-network-nano-bash/orderer3.sh @@ -1,5 +1,5 @@ -#!/usr/bin/env bash -set -euo pipefail +#!/usr/bin/env sh +set -eu # look for binaries in local dev environment /build/bin directory and then in local samples /bin directory export PATH="${PWD}"/../../fabric/build/bin:"${PWD}"/../bin:"$PATH" diff --git a/test-network-nano-bash/peer1.sh b/test-network-nano-bash/peer1.sh index 89d5d8da..bf5764d4 100755 --- a/test-network-nano-bash/peer1.sh +++ b/test-network-nano-bash/peer1.sh @@ -1,7 +1,7 @@ -#!/usr/bin/env bash -set -euo pipefail +#!/usr/bin/env sh +set -eu -if [ "$(uname)" == "Linux" ] ; then +if [ "$(uname)" = "Linux" ] ; then CCADDR="127.0.0.1" else CCADDR="host.docker.internal" diff --git a/test-network-nano-bash/peer1admin.sh b/test-network-nano-bash/peer1admin.sh index 17e4d619..448a37ad 100755 --- a/test-network-nano-bash/peer1admin.sh +++ b/test-network-nano-bash/peer1admin.sh @@ -1,4 +1,4 @@ -#!/usr/bin/env bash +#!/usr/bin/env sh # look for binaries in local dev environment /build/bin directory and then in local samples /bin directory export PATH="${PWD}"/../../fabric/build/bin:"${PWD}"/../bin:"$PATH" diff --git a/test-network-nano-bash/peer2.sh b/test-network-nano-bash/peer2.sh index 163df06e..8da1bac9 100755 --- a/test-network-nano-bash/peer2.sh +++ b/test-network-nano-bash/peer2.sh @@ -1,7 +1,7 @@ -#!/usr/bin/env bash -set -euo pipefail +#!/usr/bin/env sh +set -eu -if [ "$(uname)" == "Linux" ] ; then +if [ "$(uname)" = "Linux" ] ; then CCADDR="127.0.0.1" else CCADDR="host.docker.internal" diff --git a/test-network-nano-bash/peer2admin.sh b/test-network-nano-bash/peer2admin.sh index efd5a0c1..6b8e7b1a 100755 --- a/test-network-nano-bash/peer2admin.sh +++ b/test-network-nano-bash/peer2admin.sh @@ -1,4 +1,4 @@ -#!/usr/bin/env bash +#!/usr/bin/env sh # look for binaries in local dev environment /build/bin directory and then in local samples /bin directory export PATH="${PWD}"/../../fabric/build/bin:"${PWD}"/../bin:"$PATH" diff --git a/test-network-nano-bash/peer3.sh b/test-network-nano-bash/peer3.sh index 1054118f..5c976b7f 100755 --- a/test-network-nano-bash/peer3.sh +++ b/test-network-nano-bash/peer3.sh @@ -1,7 +1,7 @@ -#!/usr/bin/env bash -set -euo pipefail +#!/usr/bin/env sh +set -eu -if [ "$(uname)" == "Linux" ] ; then +if [ "$(uname)" = "Linux" ] ; then CCADDR="127.0.0.1" else CCADDR="host.docker.internal" diff --git a/test-network-nano-bash/peer3admin.sh b/test-network-nano-bash/peer3admin.sh index c9625163..3a187573 100755 --- a/test-network-nano-bash/peer3admin.sh +++ b/test-network-nano-bash/peer3admin.sh @@ -1,4 +1,4 @@ -#!/usr/bin/env bash +#!/usr/bin/env sh # look for binaries in local dev environment /build/bin directory and then in local samples /bin directory export PATH="${PWD}"/../../fabric/build/bin:"${PWD}"/../bin:"$PATH" diff --git a/test-network-nano-bash/peer4.sh b/test-network-nano-bash/peer4.sh index 22e95ace..b3b0aa14 100755 --- a/test-network-nano-bash/peer4.sh +++ b/test-network-nano-bash/peer4.sh @@ -1,7 +1,7 @@ -#!/usr/bin/env bash -set -euo pipefail +#!/usr/bin/env sh +set -eu -if [ "$(uname)" == "Linux" ] ; then +if [ "$(uname)" = "Linux" ] ; then CCADDR="127.0.0.1" else CCADDR="host.docker.internal" diff --git a/test-network-nano-bash/peer4admin.sh b/test-network-nano-bash/peer4admin.sh index 07a2373d..967d790e 100755 --- a/test-network-nano-bash/peer4admin.sh +++ b/test-network-nano-bash/peer4admin.sh @@ -1,4 +1,4 @@ -#!/usr/bin/env bash +#!/usr/bin/env sh # look for binaries in local dev environment /build/bin directory and then in local samples /bin directory export PATH="${PWD}"/../../fabric/build/bin:"${PWD}"/../bin:"$PATH"