3 # Licensed to the Apache Software Foundation (ASF) under one or more
4 # contributor license agreements. See the NOTICE file distributed with
5 # this work for additional information regarding copyright ownership.
6 # The ASF licenses this file to You under the Apache License, Version 2.0
7 # (the "License"); you may not use this file except in compliance with
8 # the License. You may obtain a copy of the License at
10 # http://www.apache.org/licenses/LICENSE-2.0
12 # Unless required by applicable law or agreed to in writing, software
13 # distributed under the License is distributed on an "AS IS" BASIS,
14 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 # See the License for the specific language governing permissions and
16 # limitations under the License.
19 # Modifications to the original nifi code for the ONAP project are made
20 # available under the Apache License, Version 2.0
23 scripts_dir='/opt/nifi/scripts'
25 [ -f "${scripts_dir}/common.sh" ] && . "${scripts_dir}/common.sh"
27 # Establish baseline properties
28 prop_replace 'nifi.web.http.port' "${NIFI_WEB_HTTP_PORT:-8080}"
29 prop_replace 'nifi.web.http.host' "${NIFI_WEB_HTTP_HOST:-$HOSTNAME}"
30 prop_replace 'nifi.remote.input.host' "${NIFI_REMOTE_INPUT_HOST:-$HOSTNAME}"
31 prop_replace 'nifi.remote.input.socket.port' "${NIFI_REMOTE_INPUT_SOCKET_PORT:-10000}"
32 prop_replace 'nifi.remote.input.secure' 'false'
34 # Set nifi-toolkit properties files and baseUrl
35 "${scripts_dir}/toolkit.sh"
36 prop_replace 'baseUrl' "http://${NIFI_WEB_HTTP_HOST:-$HOSTNAME}:${NIFI_WEB_HTTP_PORT:-8080}" ${nifi_toolkit_props_file}
38 prop_replace 'nifi.variable.registry.properties' "${NIFI_VARIABLE_REGISTRY_PROPERTIES:-}"
39 prop_replace 'nifi.cluster.is.node' "${NIFI_CLUSTER_IS_NODE:-false}"
40 prop_replace 'nifi.cluster.node.address' "${NIFI_CLUSTER_ADDRESS:-$HOSTNAME}"
41 prop_replace 'nifi.cluster.node.protocol.port' "${NIFI_CLUSTER_NODE_PROTOCOL_PORT:-}"
42 prop_replace 'nifi.cluster.node.protocol.threads' "${NIFI_CLUSTER_NODE_PROTOCOL_THREADS:-10}"
43 prop_replace 'nifi.cluster.node.protocol.max.threads' "${NIFI_CLUSTER_NODE_PROTOCOL_MAX_THREADS:-50}"
44 prop_replace 'nifi.zookeeper.connect.string' "${NIFI_ZK_CONNECT_STRING:-}"
45 prop_replace 'nifi.zookeeper.root.node' "${NIFI_ZK_ROOT_NODE:-/nifi}"
46 prop_replace 'nifi.cluster.flow.election.max.wait.time' "${NIFI_ELECTION_MAX_WAIT:-5 mins}"
47 prop_replace 'nifi.cluster.flow.election.max.candidates' "${NIFI_ELECTION_MAX_CANDIDATES:-}"
48 prop_replace 'nifi.web.proxy.context.path' "${NIFI_WEB_PROXY_CONTEXT_PATH:-}"
50 # REVIEW: Could not figure out how the nifi.properties file gets generated so
51 # replace value conditionally if the property name exists otherwise append
52 if grep -q 'nifi.dcae.jars.index.url' $nifi_props_file
54 prop_replace 'nifi.dcae.jars.index.url' "${NIFI_DCAE_JARS_INDEX_URL:-http://genprocessor-http/nifi-jars/}"
56 prop_append 'nifi.dcae.jars.index.url' "${NIFI_DCAE_JARS_INDEX_URL:-http://genprocessor-http/nifi-jars/}"
59 if grep -q 'nifi.ui.dcae.distibutor.api.url' $nifi_props_file
61 prop_replace 'nifi.ui.dcae.distibutor.api.url' "${NIFI_DCAE_DISTRIBUTOR_API_URL:-http://distributor-api}"
63 prop_append 'nifi.ui.dcae.distibutor.api.url' "${NIFI_DCAE_DISTRIBUTOR_API_URL:-http://distributor-api}"
66 . "${scripts_dir}/update_cluster_state_management.sh"
68 # Check if we are secured or unsecured
71 echo 'Enabling Two-Way SSL user authentication'
72 . "${scripts_dir}/secure.sh"
75 echo 'Enabling LDAP user authentication'
76 # Reference ldap-provider in properties
77 prop_replace 'nifi.security.user.login.identity.provider' 'ldap-provider'
79 . "${scripts_dir}/secure.sh"
80 . "${scripts_dir}/update_login_providers.sh"
83 if [ ! -z "${NIFI_WEB_PROXY_HOST}" ]; then
84 echo 'NIFI_WEB_PROXY_HOST was set but NiFi is not configured to run in a secure mode. Will not update nifi.web.proxy.host.'
89 # Continuously provide logs so that 'docker logs' can produce them
90 tail -F "${NIFI_HOME}/logs/nifi-app.log" &
91 "${NIFI_HOME}/bin/nifi.sh" run &
94 trap "echo Received trapped signal, beginning shutdown...;" KILL TERM HUP INT EXIT;
96 echo NiFi running with PID ${nifi_pid}.