Skip to content

Instantly share code, notes, and snippets.

@randerzander
Last active August 5, 2016 11:54
Show Gist options
  • Save randerzander/6c8512b2b71f55ee65e2 to your computer and use it in GitHub Desktop.
Save randerzander/6c8512b2b71f55ee65e2 to your computer and use it in GitHub Desktop.
#!/bin/bash
#set -eu
source /root/.bashrc
MODE=$1
MASTER_FQDN=$2
NIFI_HOME=$3
HOSTNAME=$(hostname -f)
echo "export NIFI_HOME=$NIFI_HOME" >> /root/.bashrc
PROTO_PORT=1025
sed -i "s/protocol\.port=/protocol\.port=$PROTO_PORT/g" $NIFI_HOME/conf/nifi.properties
sed -i "s/node\.address=/node\.address=$HOSTNAME/g" $NIFI_HOME/conf/nifi.properties
sed -i "s/manager\.address=/manager\.address=$MASTER_FQDN/g" $NIFI_HOME/conf/nifi.properties
sed -i "s/http.host=/http\.host=$HOSTNAME/g" $NIFI_HOME/conf/nifi.properties
# Sets up site-to-site for INSECURE communication
sed -i "s/input.secure=/input\.secure=false/g" $NIFI_HOME/conf/nifi.properties
sed -i "s/input.socket.port=/input\.socket\.port=1026/g" $NIFI_HOME/conf/nifi.properties
sed -i "s/input.socket.host=/input\.socket\.host=$HOSTNAME/g" $NIFI_HOME/conf/nifi.properties
# Sets up ZooKeeper for state management
ZKPORT=2181
sed -i "s/connect.string=/connect\.string=$MASTER_FQDN:$ZKPORT/g" $NIFI_HOME/conf/nifi.properties
sed -i "s/server.1=/server\.1=$MASTER_FQDN:$ZKPORT/g" $NIFI_HOME/conf/zookeeper.properties
if [ $MODE = "master" ]; then
sed -i "s/is\.manager=false/is\.manager=true/g" $NIFI_HOME/conf/nifi.properties
sed -i "s/is\.node=true/is\.node=false/g" $NIFI_HOME/conf/nifi.properties
mkdir -p $NIFI_HOME/state/zookeeper
echo 1 >> $NIFI_HOME/state/zookeeper/myid
else
sed -i "s/is\.manager=true/is\.manager=false/g" $NIFI_HOME/conf/nifi.properties
sed -i "s/is\.node=false/is\.node=true/g" $NIFI_HOME/conf/nifi.properties
fi
$NIFI_HOME/bin/nifi.sh install
service nifi start
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment