apiVersion: v1
# ===============LICENSE_START=======================================================
# Acumos Apache-2.0
# ===================================================================================
# Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
# ===================================================================================
# This Acumos software file is distributed by AT&T
# under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# This file is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ===============LICENSE_END=========================================================
kind: ConfigMap
metadata:
  namespace: <ACUMOS_NAMESPACE>
  name: nifi-configmap-$USER
data:
  start.sh: |-
    #!/bin/sh
    sed -i -e 's|<property name="Initial User Identity 1">.*</property>|<property name="Initial User Identity 1">$USER</property><property name="Initial User Identity 2">CN=$USER, OU=acumos, O=acumos, L=Unspecified, ST=Unspecified, C=US</property>|g' ${NIFI_HOME}/conf/authorizers.xml;
    sed -i -e 's|<property name="Initial Admin Identity">.*</property>|<property name="Initial Admin Identity">$USER</property>|g' ${NIFI_HOME}/conf/authorizers.xml;
    sed -i -e 's|<property name="Node Identity 1"></property>|<property name="Node Identity 1">CN=$USER, OU=acumos, O=acumos, L=Unspecified, ST=Unspecified, C=US</property>|g' ${NIFI_HOME}/conf/authorizers.xml;
    tail -F "/opt/nifi/nifi-current/logs/nifi-app.log" & "/opt/nifi/nifi-current/bin/nifi.sh" run & nifi_pid="$!";
    trap "echo Received trapped signal, beginning shutdown...;"
    KILL TERM HUP INT EXIT;echo NiFi running with PID ${nifi_pid}.;
    wait ${nifi_pid};
    echo init here;
    while [[ ! -e /opt/nifi/nifi-current/conf/authorizations.xml ]]; do
      echo '***** WAITING FOR /opt/nifi/nifi-current/conf/authorizations.xml *****'
      sleep 10;
    done;
    echo '***** DELETING /opt/nifi/nifi-current/conf/authorizations.xml *****'
    rm /opt/nifi/nifi-current/conf/authorizations.xml;
    echo '***** DELETED /opt/nifi/nifi-current/conf/authorizations.xml *****'
    /opt/nifi/nifi-current/bin/nifi.sh restart;
    while true;
    do echo hello; sleep 10;done
  nifi.properties: |-
    nifi.security.identity.mapping.pattern.dn=^CN=(.*?), OU=(.*?), O=(.*?), L=(.*?), ST=(.*?), C=(.*?)$
    nifi.security.identity.mapping.value.dn=$1
    nifi.flow.configuration.file=./conf/flow.xml.gz
    nifi.flow.configuration.archive.enabled=true
    nifi.flow.configuration.archive.dir=./conf/archive/
    nifi.flow.configuration.archive.max.time=30 days
    nifi.flow.configuration.archive.max.storage=500 MB
    nifi.flow.configuration.archive.max.count=
    nifi.flowcontroller.autoResumeState=true
    nifi.flowcontroller.graceful.shutdown.period=10 sec
    nifi.flowservice.writedelay.interval=500 ms
    nifi.administrative.yield.duration=30 sec
    nifi.bored.yield.duration=10 millis
    nifi.queue.backpressure.count=10000
    nifi.queue.backpressure.size=1 GB
    nifi.authorizer.configuration.file=./conf/authorizers.xml
    nifi.login.identity.provider.configuration.file=./conf/login-identity-providers.xml
    nifi.templates.directory=./conf/templates
    nifi.ui.banner.text=
    nifi.ui.autorefresh.interval=30 sec
    nifi.nar.library.directory=./lib
    nifi.nar.library.autoload.directory=./extensions
    nifi.nar.working.directory=./work/nar/
    nifi.documentation.working.directory=./work/docs/components
    nifi.state.management.configuration.file=./conf/state-management.xml
    nifi.state.management.provider.local=local-provider
    nifi.state.management.provider.cluster=zk-provider
    nifi.state.management.embedded.zookeeper.start=false
    nifi.state.management.embedded.zookeeper.properties=./conf/zookeeper.properties
    nifi.database.directory=./database_repository
    nifi.h2.url.append=;LOCK_TIMEOUT=25000;WRITE_DELAY=0;AUTO_SERVER=FALSE
    nifi.flowfile.repository.implementation=org.apache.nifi.controller.repository.WriteAheadFlowFileRepository
    nifi.flowfile.repository.wal.implementation=org.apache.nifi.wali.SequentialAccessWriteAheadLog
    nifi.flowfile.repository.directory=./flowfile_repository
    nifi.flowfile.repository.partitions=256
    nifi.flowfile.repository.checkpoint.interval=2 mins
    nifi.flowfile.repository.always.sync=false
    nifi.swap.manager.implementation=org.apache.nifi.controller.FileSystemSwapManager
    nifi.queue.swap.threshold=20000
    nifi.swap.in.period=5 sec
    nifi.swap.in.threads=1
    nifi.swap.out.period=5 sec
    nifi.swap.out.threads=4
    nifi.content.repository.implementation=org.apache.nifi.controller.repository.FileSystemRepository
    nifi.content.claim.max.appendable.size=1 MB
    nifi.content.claim.max.flow.files=100
    nifi.content.repository.directory.default=./content_repository
    nifi.content.repository.archive.max.retention.period=12 hours
    nifi.content.repository.archive.max.usage.percentage=50%
    nifi.content.repository.archive.enabled=true
    nifi.content.repository.always.sync=false
    nifi.content.viewer.url=../nifi-content-viewer/
    nifi.provenance.repository.implementation=org.apache.nifi.provenance.WriteAheadProvenanceRepository
    nifi.provenance.repository.debug.frequency=1_000_000
    nifi.provenance.repository.encryption.key.provider.implementation=
    nifi.provenance.repository.encryption.key.provider.location=
    nifi.provenance.repository.encryption.key.id=
    nifi.provenance.repository.encryption.key=
    nifi.provenance.repository.directory.default=./provenance_repository
    nifi.provenance.repository.max.storage.time=24 hours
    nifi.provenance.repository.max.storage.size=1 GB
    nifi.provenance.repository.rollover.time=30 secs
    nifi.provenance.repository.rollover.size=100 MB
    nifi.provenance.repository.query.threads=2
    nifi.provenance.repository.index.threads=2
    nifi.provenance.repository.compress.on.rollover=true
    nifi.provenance.repository.always.sync=false
    nifi.provenance.repository.indexed.fields=EventType, FlowFileUUID, Filename, ProcessorID, Relationship
    nifi.provenance.repository.indexed.attributes=
    nifi.provenance.repository.index.shard.size=500 MB
    nifi.provenance.repository.max.attribute.length=65536
    nifi.provenance.repository.concurrent.merge.threads=2
    nifi.provenance.repository.buffer.size=100000
    nifi.components.status.repository.implementation=org.apache.nifi.controller.status.history.VolatileComponentStatusRepository
    nifi.components.status.repository.buffer.size=1440
    nifi.components.status.snapshot.frequency=1 min
    nifi.remote.input.host=
    nifi.remote.input.secure=false
    nifi.remote.input.socket.port=
    nifi.remote.input.http.enabled=false
    nifi.remote.input.http.transaction.ttl=30 sec
    nifi.remote.contents.cache.expiration=30 secs
    nifi.web.war.directory=./lib
    nifi.web.http.host=
    nifi.web.http.port=
    nifi.web.http.network.interface.default=
    nifi.web.https.host=<ACUMOS_DOMAIN>
    nifi.web.https.port=443
    nifi.web.https.network.interface.default=
    nifi.web.jetty.working.directory=./work/jetty
    nifi.web.jetty.threads=200
    nifi.web.max.header.size=16 KB
    nifi.web.proxy.context.path=/$USER/nifi-user/
    nifi.web.proxy.host=
    nifi.sensitive.props.key=
    nifi.sensitive.props.key.protected=
    nifi.sensitive.props.algorithm=PBEWITHMD5AND256BITAES-CBC-OPENSSL
    nifi.sensitive.props.provider=BC
    nifi.sensitive.props.additional.keys=
    nifi.security.keystore=/opt/nifi/nifi-current/conf/sslkey/nifi-registry-keystore.p12
    nifi.security.keystoreType=PKCS12
    nifi.security.keystorePasswd=<KEYSTORE_PASSWORD>
    nifi.security.keyPasswd=<CERT_KEY_PASSWORD>
    nifi.security.truststore=/opt/nifi/nifi-current/conf/sslkey/nifi-truststore.jks
    nifi.security.truststoreType=JKS
    nifi.security.truststorePasswd=<TRUSTSTORE_PASSWORD>
    nifi.security.user.authorizer=managed-authorizer
    nifi.security.user.login.identity.provider=
    nifi.security.ocsp.responder.url=
    nifi.security.ocsp.responder.certificate=
    nifi.security.user.oidc.discovery.url=
    nifi.security.user.oidc.connect.timeout=5 secs
    nifi.security.user.oidc.read.timeout=5 secs
    nifi.security.user.oidc.client.id=
    nifi.security.user.oidc.client.secret=
    nifi.security.user.oidc.preferred.jwsalgorithm=
    nifi.security.user.knox.url=
    nifi.security.user.knox.publicKey=
    nifi.security.user.knox.cookieName=hadoop-jwt
    nifi.security.user.knox.audiences=
    nifi.cluster.protocol.heartbeat.interval=5 sec
    nifi.cluster.protocol.is.secure=false
    nifi.cluster.is.node=false
    nifi.cluster.node.address=
    nifi.cluster.node.protocol.port=
    nifi.cluster.node.protocol.threads=10
    nifi.cluster.node.protocol.max.threads=50
    nifi.cluster.node.event.history.size=25
    nifi.cluster.node.connection.timeout=5 sec
    nifi.cluster.node.read.timeout=5 sec
    nifi.cluster.node.max.concurrent.requests=100
    nifi.cluster.firewall.file=
    nifi.cluster.flow.election.max.wait.time=5 mins
    nifi.cluster.flow.election.max.candidates=
    nifi.cluster.load.balance.host=
    nifi.cluster.load.balance.port=6342
    nifi.cluster.load.balance.connections.per.node=4
    nifi.cluster.load.balance.max.thread.count=8
    nifi.cluster.load.balance.comms.timeout=30 sec
    nifi.zookeeper.connect.string=
    nifi.zookeeper.connect.timeout=3 secs
    nifi.zookeeper.session.timeout=3 secs
    nifi.zookeeper.root.node=/nifi
    nifi.zookeeper.auth.type=
    nifi.zookeeper.kerberos.removeHostFromPrincipal=
    nifi.zookeeper.kerberos.removeRealmFromPrincipal=
    nifi.kerberos.krb5.file=
    nifi.kerberos.service.principal=
    nifi.kerberos.service.keytab.location=
    nifi.kerberos.spnego.principal=
    nifi.kerberos.spnego.keytab.location=
    nifi.kerberos.spnego.authentication.expiration=12 hours
    nifi.variable.registry.properties=
