add ability to exit after config generation as is described in the docs (#6023)

This commit is contained in:
Stefano Franz 2020-03-04 09:52:19 +00:00 committed by GitHub
parent b86ae0d6a6
commit 20c5040826
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 99 additions and 91 deletions

View File

@ -1,5 +1,9 @@
#!/usr/bin/env bash
GENERATE_TEST_NET=0
GENERATE_GENERIC=0
EXIT_ON_GENERATE=0
die() {
printf '%s\n' "$1" >&2
exit 1
@ -50,9 +54,13 @@ function generateGenericCZConfig(){
--base-directory /opt/corda \
--config-file ${CONFIG_FOLDER}/node.conf \
--network-root-truststore-password ${NETWORK_TRUST_PASSWORD} \
--network-root-truststore ${CERTIFICATES_FOLDER}/${TRUST_STORE_NAME} && \
echo "Successfully registered with ${DOORMAN_URL}, starting corda" && \
--network-root-truststore ${CERTIFICATES_FOLDER}/${TRUST_STORE_NAME} &&
echo "Successfully registered with ${DOORMAN_URL}, starting corda"
if [[ ${EXIT_ON_GENERATE} == 1 ]]; then
exit 0
else
run-corda
fi
}
function downloadTestnetCerts() {
@ -68,9 +76,6 @@ function downloadTestnetCerts() {
unzip ${CERTIFICATES_FOLDER}/certs.zip
}
GENERATE_TEST_NET=0
GENERATE_GENERIC=0
while :; do
case $1 in
-h | -\? | --help)
@ -78,19 +83,26 @@ while :; do
exit
;;
-t | --testnet)
if [[ ${GENERATE_GENERIC} = 0 ]]; then
if [[ ${GENERATE_GENERIC} == 0 ]]; then
GENERATE_TEST_NET=1
else
die 'ERROR: cannot generate config for multiple networks'
fi
;;
-g | --generic)
if [[ ${GENERATE_TEST_NET} = 0 ]]; then
if [[ ${GENERATE_TEST_NET} == 0 ]]; then
GENERATE_GENERIC=1
else
die 'ERROR: cannot generate config for multiple networks'
fi
;;
-e | --exit-on-generate)
if [[ ${EXIT_ON_GENERATE} == 0 ]]; then
EXIT_ON_GENERATE=1
else
die 'ERROR: cannot set exit on generate flag'
fi
;;
--) # End of all options.
shift
break
@ -99,7 +111,7 @@ while :; do
printf 'WARN: Unknown option (ignored): %s\n' "$1" >&2
;;
*) # Default case: No more options, so break out of the loop.
break
break ;;
esac
shift
done
@ -107,18 +119,14 @@ done
: ${TRUST_STORE_NAME="network-root-truststore.jks"}
: ${JVM_ARGS='-Xmx4g -Xms2g -XX:+UseG1GC'}
if [[ ${GENERATE_TEST_NET} == 1 ]]
then
if [[ ${GENERATE_TEST_NET} == 1 ]]; then
: ${MY_PUBLIC_ADDRESS:? 'MY_PUBLIC_ADDRESS must be set as environment variable'}
downloadTestnetCerts
generateTestnetConfig
elif [[ ${GENERATE_GENERIC} == 1 ]]
then
elif [[ ${GENERATE_GENERIC} == 1 ]]; then
: ${MY_PUBLIC_ADDRESS:? 'MY_PUBLIC_ADDRESS must be set as environment variable'}
generateGenericCZConfig
else
show_help
die "No Valid Configuration requested"
fi

View File

@ -132,7 +132,7 @@ It is possible to configure the name of the Trust Root file by setting the ``TRU
-e MY_EMAIL_ADDRESS="cordauser@r3.com" \
-v /home/user/docker/config:/etc/corda \
-v /home/user/docker/certificates:/opt/corda/certificates \
corda/corda-zulu-java1.8-|corda_version_lower|:latest config-generator --generic
corda/corda-zulu-java1.8-|corda_version_lower|:latest config-generator --generic --exit-on-generate
Several environment variables must also be passed to the container to allow it to register: