Skip to content

Commit

Permalink
Added red error prints and yellow warning prints to make issues stand…
Browse files Browse the repository at this point in the history
… out more in console output.

Also changed identityManagerAddress and networkmapAddress to be defined using protocol prefix, eg. http://
And fixed a cp -u command on macOS by changing it to cp -f in initial_registration.sh.yml.
  • Loading branch information
henrikr3 committed Jun 19, 2020
1 parent f1c754a commit d573615
Show file tree
Hide file tree
Showing 27 changed files with 283 additions and 148 deletions.
6 changes: 6 additions & 0 deletions corda-pki-generator/copy_certs_to_helm_files.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
#!/bin/bash

RED='\033[0;31m' # Error color
YELLOW='\033[0;33m' # Warning color
NC='\033[0m' # No Color

set -u
DIR="."
GetPathToCurrentlyExecutingScript () {
Expand Down Expand Up @@ -46,6 +50,7 @@ checkStatus () {
then
echo "."
else
echo -e "${RED}ERROR${NC}"
echo "The previous step failed"
exit 1
fi
Expand All @@ -63,6 +68,7 @@ ensureFileExistsAndCopy () {
fi
cp -f $FROM $TO
else
echo -e "${RED}ERROR${NC}"
echo "File did not exist, probably an issue with certificate creation: $FROM"
exit 1
fi
Expand Down
5 changes: 5 additions & 0 deletions corda-pki-generator/generate_firewall_pki.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
#!/bin/bash

RED='\033[0;31m' # Error color
YELLOW='\033[0;33m' # Warning color
NC='\033[0m' # No Color

set -u
DIR="."
GetPathToCurrentlyExecutingScript () {
Expand Down Expand Up @@ -46,6 +50,7 @@ checkStatus () {
then
echo "."
else
echo -e "${RED}ERROR${NC}"
echo "The previous step failed"
exit 1
fi
Expand Down
10 changes: 9 additions & 1 deletion corda-pki-generator/pki-firewall/generate_pki.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
#!/bin/bash

RED='\033[0;31m' # Error color
YELLOW='\033[0;33m' # Warning color
NC='\033[0m' # No Color

set -u
DIR="."
GetPathToCurrentlyExecutingScript () {
Expand Down Expand Up @@ -54,8 +58,9 @@ PKI_Prerequisites () {
KEYTOOL_EXE=/usr/bin/keytool
$KEYTOOL_EXE &>/dev/null
if [ "$?" -ne "0" ]; then
echo -e "${RED}ERROR${NC}"
echo "!!! Keytool not found, please check to make sure you have it installed and in the path or in path $DIR/bin/ !!!"
exit 1
exit 1
fi
fi
fi
Expand All @@ -66,6 +71,7 @@ PKI_Prerequisites () {
then
echo "Keytool is ready..."
else
echo -e "${RED}ERROR${NC}"
echo "!!! Keytool is not available, make sure your Keytool is configured correctly !!!"
exit 1
fi
Expand All @@ -90,6 +96,7 @@ GeneratePKI () {
set -eu

if [ "$CERTIFICATE_VALIDITY_DAYS" = "" -o "$TRUST_PASSWORD" = "" -o "$BRIDGE_PASSWORD" = "" -o "$FLOAT_PASSWORD" = "" -o "$CA_KEYSTORE_PASSWORD" = "" -o "$CA_KEY_PASSWORD" = "" ]; then
echo -e "${RED}ERROR${NC}"
echo "Some values were not set correctly from values.yaml file, please check the following values in the values.yaml file:"
echo "CERTIFICATE_VALIDITY_DAYS=$CERTIFICATE_VALIDITY_DAYS"
echo "TRUST_PASSWORD=$TRUST_PASSWORD"
Expand All @@ -99,6 +106,7 @@ GeneratePKI () {
echo "CA_KEY_PASSWORD=$CA_KEY_PASSWORD"
echo "---"
echo "The raw contents that was read from values.yaml: $FIREWALL_CONF_RAW"
exit 1
fi

$KEYTOOL_EXE -genkeypair -keyalg EC -keysize 256 -alias firewallroot -validity $CERTIFICATE_VALIDITY_DAYS -dname "CN=Firewall Root,O=Local Only,L=London,C=GB" -ext bc:ca:true,pathlen:1 -keystore $WORKDIR/firewallca.jks -storepass $CA_KEYSTORE_PASSWORD -keypass $CA_KEY_PASSWORD
Expand Down
5 changes: 5 additions & 0 deletions delete-deployment.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
#!/bin/bash

RED='\033[0;31m' # Error color
YELLOW='\033[0;33m' # Warning color
NC='\033[0m' # No Color

set -u
DIR="."
GetPathToCurrentlyExecutingScript () {
Expand Down Expand Up @@ -46,6 +50,7 @@ checkStatus () {
then
echo "."
else
echo -e "${RED}ERROR${NC}"
echo "The previous step failed"
exit 1
fi
Expand Down
5 changes: 5 additions & 0 deletions deploy.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
#!/bin/bash

RED='\033[0;31m' # Error color
YELLOW='\033[0;33m' # Warning color
NC='\033[0m' # No Color

set -u
DIR="."
GetPathToCurrentlyExecutingScript () {
Expand Down Expand Up @@ -46,6 +50,7 @@ checkStatus () {
then
echo "."
else
echo -e "${RED}ERROR${NC}"
echo "The previous step failed"
exit 1
fi
Expand Down
7 changes: 7 additions & 0 deletions docker-images/build_docker_images.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
#!/bin/bash

RED='\033[0;31m' # Error color
YELLOW='\033[0;33m' # Warning color
NC='\033[0m' # No Color

set -u
DIR="."
GetPathToCurrentlyExecutingScript () {
Expand Down Expand Up @@ -52,10 +56,13 @@ fi
BuildDockerImages () {
echo "====== Building Docker images next ... ====== "
if [ ! -f "$DIR/bin/$CORDA_VERSION.jar" -o ! -f "$DIR/bin/$CORDA_HEALTH_CHECK_VERSION.jar" -o ! -f "$DIR/bin/$CORDA_FIREWALL_VERSION.jar" ]; then
echo -e "${RED}ERROR${NC}"
echo "Missing binaries, check that you have the correct files with the correct names in the following folder $DIR/bin"
echo "$DIR/bin/$CORDA_VERSION.jar"
echo "$DIR/bin/$CORDA_FIREWALL_VERSION.jar"
echo "$DIR/bin/$CORDA_HEALTH_CHECK_VERSION.jar"
echo "$DIR/bin folder contents:"
ls -al $DIR/bin
exit 1
fi

Expand Down
11 changes: 8 additions & 3 deletions docker-images/corda_image_ent/startCorda.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
#!/usr/bin/env bash

RED='\033[0;31m' # Error color
YELLOW='\033[0;33m' # Warning color
NC='\033[0m' # No Color

echoMessage () {
message=$1

Expand All @@ -12,6 +16,7 @@ checkStatus () {
then
echoMessage "Success"
else
echo -e "${RED}ERROR${NC}"
echoMessage "The previous step failed"
exit 1
fi
Expand Down Expand Up @@ -107,7 +112,7 @@ waitTillIdentityManagerIsUpAndRunning () {
do
sleep 2
echoMessage "Trying to contact Identity Manager @ ($IDENTITY_MANAGER_ADDRESS)..."
curl -m5 -s http://$IDENTITY_MANAGER_ADDRESS/status > /dev/null
curl -m5 -s $IDENTITY_MANAGER_ADDRESS/status > /dev/null
let EXIT_CODE=$?
done

Expand All @@ -120,7 +125,7 @@ waitTillNetworkMapIsUpAndRunning () {
do
sleep 2
echoMessage "Trying to contact network map..."
curl -m5 -s http://$NETMAP_ADDRESS/network-map/my-hostname > /dev/null
curl -m5 -s $NETMAP_ADDRESS/network-map/my-hostname > /dev/null
let EXIT_CODE=$?
done

Expand All @@ -133,7 +138,7 @@ checkNetworkMap () {
do
sleep 2
echoMessage "Checking network map for notary NodeInfo..."
hash=$(curl -m5 -s http://$NETMAP_ADDRESS/network-map-user/network-map | jq -r '.[0]')
hash=$(curl -m5 -s $NETMAP_ADDRESS/network-map-user/network-map | jq -r '.[0]')
if [ "$hash" = "null" ]
then
echoMessage "The network map is currently empty, waiting for first registrations..."
Expand Down
5 changes: 5 additions & 0 deletions docker-images/corda_image_firewall/startFirewall.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
#!/usr/bin/env bash

RED='\033[0;31m' # Error color
YELLOW='\033[0;33m' # Warning color
NC='\033[0m' # No Color

echoMessage () {
message=$1

Expand All @@ -12,6 +16,7 @@ checkStatus () {
then
echoMessage "Success"
else
echo -e "${RED}ERROR${NC}"
echoMessage "The previous step failed"
exit 1
fi
Expand Down
7 changes: 7 additions & 0 deletions docker-images/docker_config.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
#!/bin/bash

RED='\033[0;31m' # Error color
YELLOW='\033[0;33m' # Warning color
NC='\033[0m' # No Color

set -u
DIR="."
GetPathToCurrentlyExecutingScript () {
Expand Down Expand Up @@ -59,17 +63,20 @@ EnsureDockerIsAvailableAndReachable () {
$DOCKER_CMD ps 2>&1 | grep -q "permission denied"
status=$?
if [ $status -eq 0 ]; then
echo -e "${YELLOW}Warning${NC}"
echo "Docker requires sudo to execute, trying to substitute using 'sudo docker'"
DOCKER_CMD='sudo docker'
$DOCKER_CMD ps 2>&1 | grep -q "permission denied"
status=$?
if [ $status -eq 0 ]; then
echo -e "${RED}ERROR${NC}"
echo "Still issues with permissions, try a manual workaround where you set 'alias docker='sudo docker'' then run 'docker ps' to check that there is no 'permission denied' errors."
exit 1
else
echo "Docker now accessible by way of sudo, continuing..."
fi
else
echo -e "${RED}ERROR${NC}"
echo "!!! Docker engine not available, make sure your Docker is running and responds to command 'docker ps' !!!"
exit 1
fi
Expand Down
14 changes: 13 additions & 1 deletion docker-images/download_binaries.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
#!/bin/bash

RED='\033[0;31m' # Error color
YELLOW='\033[0;33m' # Warning color
NC='\033[0m' # No Color

set -u
set +x

Expand Down Expand Up @@ -59,6 +63,7 @@ checkStatus () {
then
echoMessage "Success"
else
echo -e "${RED}ERROR${NC}"
echoMessage "The previous step failed"
exit 1
fi
Expand All @@ -74,6 +79,7 @@ wgetDownload () {
status=$?
set -e
if [ $status -ne 0 ]; then
echo -e "${RED}ERROR${NC}"
echo "wget missing, cannot continue (please install wget: https://stackoverflow.com/questions/33886917/how-to-install-wget-in-macos)!"
exit 1
else
Expand All @@ -82,7 +88,9 @@ wgetDownload () {
if [ $status -eq 0 ]; then
echo "URL check passed, target exists!"
else
echo -e "${RED}ERROR${NC}"
echo "URL check failed, file not found! Check your version definition in values.yaml file!"
echo "URL: $URL"
exit 1
fi

Expand Down Expand Up @@ -112,14 +120,15 @@ downloadBinaries () {
CORDA_FIREWALL_DOWNLOAD_URL="https://software.r3.com/artifactory/r3-corda-releases/com/r3/corda/corda-firewall/${VERSION}/corda-firewall-${VERSION}.jar"
CORDA_HEALTH_CHECK_DOWNLOAD_URL="https://software.r3.com/artifactory/r3-corda-releases/com/r3/corda/corda-tools-health-survey/${VERSION}/corda-tools-health-survey-${VERSION}.jar"
CORDA_FINANCE_WORKFLOWS_DOWNLOAD_URL="https://software.r3.com/artifactory/r3-corda-releases/com/r3/corda/corda-finance-workflows/${VERSION}/corda-finance-workflows-${VERSION}.jar"
CORDA_FINANCE_CONTRACT_DOWNLOAD_URL="https://ci-artifactory.corda.r3cev.com/artifactory/corda-releases/net/corda/corda-finance-contracts/${VERSION}/corda-finance-contracts-${VERSION}.jar"
CORDA_FINANCE_CONTRACT_DOWNLOAD_URL="https://software.r3.com/artifactory/corda-releases/net/corda/corda-finance-contracts/${VERSION}/corda-finance-contracts-${VERSION}.jar"

echo "Checking that wget exists..."
set +e
wget --help > /dev/null 2>&1
status=$?
set -e
if [ $status -ne 0 ]; then
echo -e "${YELLOW}Warning${NC}"
echo "wget is not installed. You need to install it in order to download the binaries using this script. You may also download them manually."
echo "Manual download instructions, please download the following links and save as the name suggests:"
echo "docker-images/bin/$CORDA_VERSION.jar = $CORDA_DOWNLOAD_URL"
Expand Down Expand Up @@ -197,16 +206,19 @@ downloadBinaries () {

askForArtifactoryLoginInformation () {
if [ "$ARTIFACTORY_USER" = "" ]; then
echo -e "${YELLOW}Warning${NC}"
echo "There is no value defined for artifactory_username in values.yaml, you can either interrupt this script with CTRL+C or enter your R3 Artifactory username next."
read -p "Enter your R3 Artifactory username to continue: " ARTIFACTORY_USER
fi

if [ "$ARTIFACTORY_PASSWORD" = "" ]; then
echo -e "${YELLOW}Warning${NC}"
echo "There is no value defined for artifactory_password in values.yaml, you can either interrupt this script with CTRL+C or enter your R3 Artifactory password next."
read -p "Enter your R3 Artifactory password to continue: " ARTIFACTORY_PASSWORD
fi

if [ "$ARTIFACTORY_USER" = "" -o "$ARTIFACTORY_PASSWORD" = "" ]; then
echo -e "${RED}ERROR${NC}"
echo "R3 Artifactory username or password missing!"
exit 1
fi
Expand Down
5 changes: 5 additions & 0 deletions docker-images/push_docker_images.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
#!/bin/bash

RED='\033[0;31m' # Error color
YELLOW='\033[0;33m' # Warning color
NC='\033[0m' # No Color

set -u
DIR="."
GetPathToCurrentlyExecutingScript () {
Expand Down Expand Up @@ -45,6 +49,7 @@ set -eu
PushDockerImages () {
echo "====== Pushing Docker images next ... ====== "
if [ "$DOCKER_REGISTRY" = "" ]; then
echo -e "${RED}ERROR${NC}"
echo "You must specify a valid container registry in the values.yaml file"
exit 1
fi
Expand Down
10 changes: 5 additions & 5 deletions helm/delete-all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ DeleteAllKubernetesResources () {
kubectl delete --all pv --wait=false

while :; do
n=$(kubectl get pods | wc -l)
if [[ n -eq 0 ]]; then
break
fi
sleep 5
n=$(kubectl get pods | wc -l)
if [[ n -eq 0 ]]; then
break
fi
sleep 5
done
echo "====== Deleting all Kubernetes resources completed. ====== "
}
Expand Down
4 changes: 2 additions & 2 deletions helm/files/conf/node-4.0.conf
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ p2pAddress: "{{ .Values.corda.node.conf.p2pAddress }}:{{ .Values.corda.node.conf
compatibilityZoneURL: "{{ .Values.corda.node.conf.compatibilityZoneURL }}"
{{- else }}
networkServices: {
doormanURL: "http://{{ .Values.corda.node.conf.identityManagerAddress }}",
networkMapURL: "http://{{ .Values.corda.node.conf.networkmapAddress }}"
doormanURL: "{{ .Values.corda.node.conf.identityManagerAddress }}",
networkMapURL: "{{ .Values.corda.node.conf.networkmapAddress }}"
}
{{- end }}
crlCheckSoftFail: {{ .Values.corda.node.conf.crlCheckSoftFail }}
Expand Down
4 changes: 2 additions & 2 deletions helm/files/conf/node-4.1.conf
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ p2pAddress: "{{ .Values.corda.node.conf.p2pAddress }}:{{ .Values.corda.node.conf
compatibilityZoneURL: "{{ .Values.corda.node.conf.compatibilityZoneURL }}"
{{- else }}
networkServices: {
doormanURL: "http://{{ .Values.corda.node.conf.identityManagerAddress }}",
networkMapURL: "http://{{ .Values.corda.node.conf.networkmapAddress }}"
doormanURL: "{{ .Values.corda.node.conf.identityManagerAddress }}",
networkMapURL: "{{ .Values.corda.node.conf.networkmapAddress }}"
}
{{- end }}
crlCheckSoftFail: {{ .Values.corda.node.conf.crlCheckSoftFail }}
Expand Down
4 changes: 2 additions & 2 deletions helm/files/conf/node-4.2.conf
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ p2pAddress: "{{ .Values.corda.node.conf.p2pAddress }}:{{ .Values.corda.node.conf
compatibilityZoneURL: "{{ .Values.corda.node.conf.compatibilityZoneURL }}"
{{- else }}
networkServices: {
doormanURL: "http://{{ .Values.corda.node.conf.identityManagerAddress }}",
networkMapURL: "http://{{ .Values.corda.node.conf.networkmapAddress }}"
doormanURL: "{{ .Values.corda.node.conf.identityManagerAddress }}",
networkMapURL: "{{ .Values.corda.node.conf.networkmapAddress }}"
}
{{- end }}
crlCheckSoftFail: {{ .Values.corda.node.conf.crlCheckSoftFail }}
Expand Down
4 changes: 2 additions & 2 deletions helm/files/conf/node-4.3.conf
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ p2pAddress: "{{ .Values.corda.node.conf.p2pAddress }}:{{ .Values.corda.node.conf
compatibilityZoneURL: "{{ .Values.corda.node.conf.compatibilityZoneURL }}"
{{- else }}
networkServices: {
doormanURL: "http://{{ .Values.corda.node.conf.identityManagerAddress }}",
networkMapURL: "http://{{ .Values.corda.node.conf.networkmapAddress }}"
doormanURL: "{{ .Values.corda.node.conf.identityManagerAddress }}",
networkMapURL: "{{ .Values.corda.node.conf.networkmapAddress }}"
}
{{- end }}
crlCheckSoftFail: {{ .Values.corda.node.conf.crlCheckSoftFail }}
Expand Down
Loading

0 comments on commit d573615

Please sign in to comment.