This is an automated email from the ASF dual-hosted git repository. chriss pushed a commit to branch NIFI-7060 in repository https://gitbox.apache.org/repos/asf/nifi.git
commit 4424b2ae4653480e468fd3e571122ef13a2b320c Author: Adrian Martin <adrianmartinpa...@gmail.com> AuthorDate: Wed Jan 22 18:53:38 2020 +0000 Update environment variable names Set the environment variable names to their counterpart in the nifi.properties file --- minifi/minifi-docker/dockerhub/sh/start.sh | 4 ++-- nifi-docker/dockerhub/sh/common.sh | 12 ++++++------ nifi-docker/dockerhub/sh/secure.sh | 3 ++- nifi-docker/dockerhub/sh/toolkit.sh | 2 +- .../dockerhub/sh/update_cluster_state_management.sh | 4 ++-- nifi-docker/dockerhub/sh/update_login_providers.sh | 4 ++-- .../nifi-registry-docker/dockerhub/sh/common.sh | 11 ++++++----- .../nifi-registry-docker/dockerhub/sh/secure.sh | 19 ++++++++++--------- .../nifi-registry-docker/dockerhub/sh/start.sh | 7 ++++--- .../dockerhub/sh/update_bundle_provider.sh | 8 ++++---- .../dockerhub/sh/update_flow_provider.sh | 10 +++++----- .../dockerhub/sh/update_login_providers.sh | 6 +++--- .../docker/sh/docker-entrypoint.sh | 12 ++++++------ 13 files changed, 53 insertions(+), 49 deletions(-) diff --git a/minifi/minifi-docker/dockerhub/sh/start.sh b/minifi/minifi-docker/dockerhub/sh/start.sh index f1f19f9467..d5cdd49fab 100755 --- a/minifi/minifi-docker/dockerhub/sh/start.sh +++ b/minifi/minifi-docker/dockerhub/sh/start.sh @@ -20,7 +20,7 @@ tail -F "${MINIFI_HOME}/logs/minifi-app.log" & "${MINIFI_HOME}/bin/minifi.sh" run & minifi_pid="$!" -trap "echo Received trapped signal, beginning shutdown...;" KILL TERM HUP INT EXIT; +trap "echo Received trapped signal, beginning shutdown...;" TERM HUP INT EXIT; echo MiNiFi running with PID ${minifi_pid}. -wait ${minifi_pid} \ No newline at end of file +wait ${minifi_pid} diff --git a/nifi-docker/dockerhub/sh/common.sh b/nifi-docker/dockerhub/sh/common.sh index f2121abec8..e3ab9d8369 100755 --- a/nifi-docker/dockerhub/sh/common.sh +++ b/nifi-docker/dockerhub/sh/common.sh @@ -18,13 +18,13 @@ # 2 - value to replace # 3 - file to perform replacement inline prop_replace () { - target_file=${3:-${nifi_props_file}} + target_file="${3:-${nifi_props_file}}" echo "File [${target_file}] replacing [${1}]" sed -i -e "s|^$1=.*$|$1=$2|" "${target_file}" } uncomment() { - target_file=${2} + target_file="${2}" echo "File [${target_file}] uncommenting [${1}]" sed -i -e "s|^\#$1|$1|" "${target_file}" } @@ -33,7 +33,7 @@ uncomment() { # 2 - property value to use # 3 - file to perform replacement inline prop_add_or_replace () { - target_file=${3:-${nifi_props_file}} + target_file="${3:-${nifi_props_file}}" property_found=$(awk -v property="${1}" 'index($0, property) == 1') if [ -z "${property_found}" ]; then echo "File [${target_file}] adding [${1}]" @@ -44,8 +44,8 @@ prop_add_or_replace () { } # NIFI_HOME is defined by an ENV command in the backing Dockerfile -export nifi_bootstrap_file=${NIFI_HOME}/conf/bootstrap.conf -export nifi_props_file=${NIFI_HOME}/conf/nifi.properties -export nifi_toolkit_props_file=${HOME}/.nifi-cli.nifi.properties +export nifi_bootstrap_file="${NIFI_HOME}/conf/bootstrap.conf" +export nifi_props_file="${NIFI_HOME}/conf/nifi.properties" +export nifi_toolkit_props_file="${HOME}/.nifi-cli.nifi.properties" hostname=$(hostname) export hostname diff --git a/nifi-docker/dockerhub/sh/secure.sh b/nifi-docker/dockerhub/sh/secure.sh index dd021ccd76..70622a6905 100755 --- a/nifi-docker/dockerhub/sh/secure.sh +++ b/nifi-docker/dockerhub/sh/secure.sh @@ -17,6 +17,7 @@ scripts_dir='/opt/nifi/scripts' +# shellcheck source=./common.sh [ -f "${scripts_dir}/common.sh" ] && . "${scripts_dir}/common.sh" # Perform idempotent changes of configuration to support secure environments @@ -54,7 +55,7 @@ prop_replace 'keyPasswd' "${KEY_PASSWORD:-$KEYSTORE_PASSWORD}" "${nifi_ prop_replace 'truststore' "${TRUSTSTORE_PATH}" "${nifi_toolkit_props_file}" prop_replace 'truststoreType' "${TRUSTSTORE_TYPE}" "${nifi_toolkit_props_file}" # shellcheck disable=SC2086 -prop_replace 'truststorePasswd' "${TRUSTSTORE_PASSWORD}" ${nifi_toolkit_props_file} +prop_replace 'truststorePasswd' "${TRUSTSTORE_PASSWORD}" "${nifi_toolkit_props_file}" # Disable HTTP and enable HTTPS prop_replace 'nifi.web.http.port' '' diff --git a/nifi-docker/dockerhub/sh/toolkit.sh b/nifi-docker/dockerhub/sh/toolkit.sh index 465b38400f..2697620be3 100755 --- a/nifi-docker/dockerhub/sh/toolkit.sh +++ b/nifi-docker/dockerhub/sh/toolkit.sh @@ -29,5 +29,5 @@ proxiedEntity= EOT cat <<EOT > "${HOME}/.nifi-cli.config" -nifi.props=${nifi_toolkit_props_file} +nifi.props="${nifi_toolkit_props_file}" EOT diff --git a/nifi-docker/dockerhub/sh/update_cluster_state_management.sh b/nifi-docker/dockerhub/sh/update_cluster_state_management.sh index da49bdb65c..07b9d61f82 100755 --- a/nifi-docker/dockerhub/sh/update_cluster_state_management.sh +++ b/nifi-docker/dockerhub/sh/update_cluster_state_management.sh @@ -19,8 +19,8 @@ state_providers_file="${NIFI_HOME}/conf/state-management.xml" property_xpath='/stateManagement/cluster-provider/property' edit_property() { - property_name=$1 - property_value=$2 + property_name="$1" + property_value="$2" if [ -n "${property_value}" ]; then xmlstarlet ed --inplace -u "${property_xpath}[@name='${property_name}']" -v "${property_value}" "${state_providers_file}" diff --git a/nifi-docker/dockerhub/sh/update_login_providers.sh b/nifi-docker/dockerhub/sh/update_login_providers.sh index b323ce7153..a2475d930f 100755 --- a/nifi-docker/dockerhub/sh/update_login_providers.sh +++ b/nifi-docker/dockerhub/sh/update_login_providers.sh @@ -20,8 +20,8 @@ property_xpath='//loginIdentityProviders/provider/property' # Update a given property in the login-identity-providers file if a value is specified edit_property() { - property_name=$1 - property_value=$2 + property_name="$1" + property_value="$2" if [ -n "${property_value}" ]; then xmlstarlet ed --inplace -u "${property_xpath}[@name='${property_name}']" -v "${property_value}" "${login_providers_file}" diff --git a/nifi-registry/nifi-registry-core/nifi-registry-docker/dockerhub/sh/common.sh b/nifi-registry/nifi-registry-core/nifi-registry-docker/dockerhub/sh/common.sh index 0f594d9aed..d5b3c27168 100755 --- a/nifi-registry/nifi-registry-core/nifi-registry-docker/dockerhub/sh/common.sh +++ b/nifi-registry/nifi-registry-core/nifi-registry-docker/dockerhub/sh/common.sh @@ -18,11 +18,12 @@ # 2 - value to replace # 3 - file to perform replacement inline prop_replace () { - target_file=${3:-${nifi_registry_props_file}} - echo 'replacing target file ' ${target_file} - sed -i -e "s|^$1=.*$|$1=$2|" ${target_file} + target_file="${3:-${nifi_registry_props_file}}" + echo 'replacing target file ' "${target_file}" + sed -i -e "s|^$1=.*$|$1=$2|" "${target_file}" } # NIFI_REGISTRY_HOME is defined by an ENV command in the backing Dockerfile -export nifi_registry_props_file=${NIFI_REGISTRY_HOME}/conf/nifi-registry.properties -export hostname=$(hostname) +export nifi_registry_props_file="${NIFI_REGISTRY_HOME}/conf/nifi-registry.properties" +hostname=$(hostname) +export hostname diff --git a/nifi-registry/nifi-registry-core/nifi-registry-docker/dockerhub/sh/secure.sh b/nifi-registry/nifi-registry-core/nifi-registry-docker/dockerhub/sh/secure.sh index 8a7a5bbed5..e17c7aefdd 100644 --- a/nifi-registry/nifi-registry-core/nifi-registry-docker/dockerhub/sh/secure.sh +++ b/nifi-registry/nifi-registry-core/nifi-registry-docker/dockerhub/sh/secure.sh @@ -17,26 +17,27 @@ scripts_dir='/opt/nifi-registry/scripts' +# shellcheck source=./common.sh [ -f "${scripts_dir}/common.sh" ] && . "${scripts_dir}/common.sh" # Perform idempotent changes of configuration to support secure environments echo 'Configuring environment with SSL settings' -: ${KEYSTORE_PATH:?"Must specify an absolute path to the keystore being used."} +: "${KEYSTORE_PATH:?"Must specify an absolute path to the keystore being used."}" if [ ! -f "${KEYSTORE_PATH}" ]; then echo "Keystore file specified (${KEYSTORE_PATH}) does not exist." exit 1 fi -: ${KEYSTORE_TYPE:?"Must specify the type of keystore (JKS, PKCS12, PEM) of the keystore being used."} -: ${KEYSTORE_PASSWORD:?"Must specify the password of the keystore being used."} +: "${KEYSTORE_TYPE:?"Must specify the type of keystore (JKS, PKCS12, PEM) of the keystore being used."}" +: "${KEYSTORE_PASSWORD:?"Must specify the password of the keystore being used."}" -: ${TRUSTSTORE_PATH:?"Must specify an absolute path to the truststore being used."} +: "${TRUSTSTORE_PATH:?"Must specify an absolute path to the truststore being used."}" if [ ! -f "${TRUSTSTORE_PATH}" ]; then echo "Keystore file specified (${TRUSTSTORE_PATH}) does not exist." exit 1 fi -: ${TRUSTSTORE_TYPE:?"Must specify the type of truststore (JKS, PKCS12, PEM) of the truststore being used."} -: ${TRUSTSTORE_PASSWORD:?"Must specify the password of the truststore being used."} +: "${TRUSTSTORE_TYPE:?"Must specify the type of truststore (JKS, PKCS12, PEM) of the truststore being used."}" +: "${TRUSTSTORE_PASSWORD:?"Must specify the password of the truststore being used."}" prop_replace 'nifi.registry.security.keystore' "${KEYSTORE_PATH}" prop_replace 'nifi.registry.security.keystoreType' "${KEYSTORE_TYPE}" @@ -50,8 +51,8 @@ prop_replace 'nifi.registry.security.truststorePasswd' "${TRUSTSTORE_PASSWORD} prop_replace 'nifi.registry.web.http.port' '' prop_replace 'nifi.registry.web.http.host' '' prop_replace 'nifi.registry.web.https.port' "${NIFI_REGISTRY_WEB_HTTPS_PORT:-18443}" -prop_replace 'nifi.registry.web.https.host' "${NIFI_REGISTRY_WEB_HTTPS_HOST:-$HOSTNAME}" +prop_replace 'nifi.registry.web.https.host' "${NIFI_REGISTRY_WEB_HTTPS_HOST:-$hostname}" # Establish initial user and an associated admin identity -sed -i -e 's|<property name="Initial User Identity 1">.*</property>|<property name="Initial User Identity 1">'"${INITIAL_ADMIN_IDENTITY}"'</property>|' ${NIFI_REGISTRY_HOME}/conf/authorizers.xml -sed -i -e 's|<property name="Initial Admin Identity">.*</property>|<property name="Initial Admin Identity">'"${INITIAL_ADMIN_IDENTITY}"'</property>|' ${NIFI_REGISTRY_HOME}/conf/authorizers.xml +sed -i -e 's|<property name="Initial User Identity 1">.*</property>|<property name="Initial User Identity 1">'"${INITIAL_ADMIN_IDENTITY}"'</property>|' "${NIFI_REGISTRY_HOME}/conf/authorizers.xml" +sed -i -e 's|<property name="Initial Admin Identity">.*</property>|<property name="Initial Admin Identity">'"${INITIAL_ADMIN_IDENTITY}"'</property>|' "${NIFI_REGISTRY_HOME}/conf/authorizers.xml" diff --git a/nifi-registry/nifi-registry-core/nifi-registry-docker/dockerhub/sh/start.sh b/nifi-registry/nifi-registry-core/nifi-registry-docker/dockerhub/sh/start.sh index eba4ef217e..9cdbb26c81 100755 --- a/nifi-registry/nifi-registry-core/nifi-registry-docker/dockerhub/sh/start.sh +++ b/nifi-registry/nifi-registry-core/nifi-registry-docker/dockerhub/sh/start.sh @@ -17,13 +17,14 @@ scripts_dir='/opt/nifi-registry/scripts' +# shellcheck source=./common.sh [ -f "${scripts_dir}/common.sh" ] && . "${scripts_dir}/common.sh" # Establish baseline properties prop_replace 'nifi.registry.web.http.port' "${NIFI_REGISTRY_WEB_HTTP_PORT:-18080}" -prop_replace 'nifi.registry.web.http.host' "${NIFI_REGISTRY_WEB_HTTP_HOST:-$HOSTNAME}" +prop_replace 'nifi.registry.web.http.host' "${NIFI_REGISTRY_WEB_HTTP_HOST:-$hostname}" -. ${scripts_dir}/update_database.sh +. "${scripts_dir}/update_database.sh" # Check if we are secured or unsecured case ${AUTH} in @@ -56,7 +57,7 @@ tail -F "${NIFI_REGISTRY_HOME}/logs/nifi-registry-app.log" & "${NIFI_REGISTRY_HOME}/bin/nifi-registry.sh" run & nifi_registry_pid="$!" -trap "echo Received trapped signal, beginning shutdown...;" KILL TERM HUP INT EXIT; +trap "echo Received trapped signal, beginning shutdown...;" TERM HUP INT EXIT; echo NiFi-Registry running with PID ${nifi_registry_pid}. wait ${nifi_registry_pid} diff --git a/nifi-registry/nifi-registry-core/nifi-registry-docker/dockerhub/sh/update_bundle_provider.sh b/nifi-registry/nifi-registry-core/nifi-registry-docker/dockerhub/sh/update_bundle_provider.sh index 27d5c940ac..9e8f0021fc 100644 --- a/nifi-registry/nifi-registry-core/nifi-registry-docker/dockerhub/sh/update_bundle_provider.sh +++ b/nifi-registry/nifi-registry-core/nifi-registry-docker/dockerhub/sh/update_bundle_provider.sh @@ -15,12 +15,12 @@ # See the License for the specific language governing permissions and # limitations under the License. -providers_file=${NIFI_REGISTRY_HOME}/conf/providers.xml +providers_file="${NIFI_REGISTRY_HOME}/conf/providers.xml" property_xpath='/providers/extensionBundlePersistenceProvider' add_property() { - property_name=$1 - property_value=$2 + property_name="$1" + property_value="$2" if [ -n "${property_value}" ]; then xmlstarlet ed --inplace --subnode "${property_xpath}" --type elem -n property -v "${property_value}" \ @@ -31,7 +31,7 @@ add_property() { xmlstarlet ed --inplace -u "${property_xpath}/property[@name='Extension Bundle Storage Directory']" -v "${NIFI_REGISTRY_BUNDLE_STORAGE_DIR:-./extension_bundles}" "${providers_file}" -case ${NIFI_REGISTRY_BUNDLE_PROVIDER} in +case "${NIFI_REGISTRY_BUNDLE_PROVIDER}" in file) xmlstarlet ed --inplace -u "${property_xpath}/class" -v "org.apache.nifi.registry.provider.extension.FileSystemBundlePersistenceProvider" "${providers_file}" ;; diff --git a/nifi-registry/nifi-registry-core/nifi-registry-docker/dockerhub/sh/update_flow_provider.sh b/nifi-registry/nifi-registry-core/nifi-registry-docker/dockerhub/sh/update_flow_provider.sh index 92a921422d..abcdbee06a 100644 --- a/nifi-registry/nifi-registry-core/nifi-registry-docker/dockerhub/sh/update_flow_provider.sh +++ b/nifi-registry/nifi-registry-core/nifi-registry-docker/dockerhub/sh/update_flow_provider.sh @@ -15,12 +15,12 @@ # See the License for the specific language governing permissions and # limitations under the License. -providers_file=${NIFI_REGISTRY_HOME}/conf/providers.xml +providers_file="${NIFI_REGISTRY_HOME}/conf/providers.xml" property_xpath='/providers/flowPersistenceProvider' add_property() { - property_name=$1 - property_value=$2 + property_name="$1" + property_value="$2" if [ -n "${property_value}" ]; then xmlstarlet ed --inplace --subnode "${property_xpath}" --type elem -n property -v "${property_value}" \ @@ -31,7 +31,7 @@ add_property() { xmlstarlet ed --inplace -u "${property_xpath}/property[@name='Flow Storage Directory']" -v "${NIFI_REGISTRY_FLOW_STORAGE_DIR:-./flow_storage}" "${providers_file}" -case ${NIFI_REGISTRY_FLOW_PROVIDER} in +case "${NIFI_REGISTRY_FLOW_PROVIDER}" in file) xmlstarlet ed --inplace -u "${property_xpath}/class" -v "org.apache.nifi.registry.provider.flow.FileSystemFlowPersistenceProvider" "${providers_file}" ;; @@ -41,7 +41,7 @@ case ${NIFI_REGISTRY_FLOW_PROVIDER} in add_property "Remote Access User" "${NIFI_REGISTRY_GIT_USER:-}" add_property "Remote Access Password" "${NIFI_REGISTRY_GIT_PASSWORD:-}" - if [ ! -z "$NIFI_REGISTRY_GIT_REPO" ]; then + if [ -n "$NIFI_REGISTRY_GIT_REPO" ]; then add_property "Remote Clone Repository" "${NIFI_REGISTRY_GIT_REPO:-}" fi ;; diff --git a/nifi-registry/nifi-registry-core/nifi-registry-docker/dockerhub/sh/update_login_providers.sh b/nifi-registry/nifi-registry-core/nifi-registry-docker/dockerhub/sh/update_login_providers.sh index e3280b56aa..0036c9922d 100755 --- a/nifi-registry/nifi-registry-core/nifi-registry-docker/dockerhub/sh/update_login_providers.sh +++ b/nifi-registry/nifi-registry-core/nifi-registry-docker/dockerhub/sh/update_login_providers.sh @@ -15,13 +15,13 @@ # See the License for the specific language governing permissions and # limitations under the License. -login_providers_file=${NIFI_REGISTRY_HOME}/conf/identity-providers.xml +login_providers_file="${NIFI_REGISTRY_HOME}/conf/identity-providers.xml" property_xpath='//identityProviders/provider/property' # Update a given property in the login-identity-providers file if a value is specified edit_property() { - property_name=$1 - property_value=$2 + property_name="$1" + property_value="$2" if [ -n "${property_value}" ]; then xmlstarlet ed --inplace -u "${property_xpath}[@name='${property_name}']" -v "${property_value}" "${login_providers_file}" diff --git a/nifi-toolkit/nifi-toolkit-assembly/docker/sh/docker-entrypoint.sh b/nifi-toolkit/nifi-toolkit-assembly/docker/sh/docker-entrypoint.sh index 3db34e43d6..c5af4e4853 100755 --- a/nifi-toolkit/nifi-toolkit-assembly/docker/sh/docker-entrypoint.sh +++ b/nifi-toolkit/nifi-toolkit-assembly/docker/sh/docker-entrypoint.sh @@ -20,21 +20,21 @@ toolkit_path="${NIFI_TOOLKIT_HOME}/bin" -program=$1 +program="$1" print_help () { - if [ -z ${program} ]; then + if [ -z "${program}" ]; then echo "No program option specified." else echo "Could not find program \"${program}\" to execute." fi - echo 'Options available include: ' $(for script in $(find "${toolkit_path}" -type f -name '*.sh'); do basename ${script} '.sh'; done) + echo 'Options available include: ' "$(for script in "${toolkit_path}"/*.sh; do basename "${script}" '.sh'; done)" } # Find out which component of the Toolkit we are using -if ! [ -f "${toolkit_path}/${program}.sh" ]; then - print_help ${program} +if [ ! -f "${toolkit_path}/${program}.sh" ]; then + print_help "${program}" else shift - exec ${toolkit_path}/${program}.sh "$@" + exec "${toolkit_path}/${program}.sh" "$@" fi