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