-echo "Define replication type in module-shards.conf"
-sed -ie "s/{{{REPLICAS_1}}}/[\"member-1\",\n\t\t\t\"member-2\",\n\t\t\t\"member-3\"]/g" ${MODULESHARDSCONF}
-sed -ie "s/{{{REPLICAS_2}}}/[\"member-1\",\n\t\t\t\"member-2\",\n\t\t\t\"member-3\"]/g" ${MODULESHARDSCONF}
-sed -ie "s/{{{REPLICAS_3}}}/[\"member-1\",\n\t\t\t\"member-2\",\n\t\t\t\"member-3\"]/g" ${MODULESHARDSCONF}
-sed -ie "s/{{{REPLICAS_4}}}/[\"member-1\",\n\t\t\t\"member-2\",\n\t\t\t\"member-3\"]/g" ${MODULESHARDSCONF}
+echo "Changing to /tmp"
+cd /tmp
+
+echo "Downloading the distribution from ${ACTUALBUNDLEURL}"
+wget --progress=dot:mega '${ACTUALBUNDLEURL}'
+
+echo "Extracting the new controller..."
+unzip -q ${BUNDLE}
+
+echo "Configuring the startup features..."
+FEATURESCONF=/tmp/${BUNDLEFOLDER}/etc/org.apache.karaf.features.cfg
+CUSTOMPROP=/tmp/${BUNDLEFOLDER}/etc/custom.properties
+sed -ie "s/featuresBoot=.*/featuresBoot=config,standard,region,package,kar,ssh,management,${ACTUALFEATURES}/g" \${FEATURESCONF}
+sed -ie "s%mvn:org.opendaylight.integration/features-integration-index/${BUNDLEVERSION}/xml/features%mvn:org.opendaylight.integration/features-integration-index/${BUNDLEVERSION}/xml/features,mvn:org.opendaylight.integration/features-integration-test/${BUNDLEVERSION}/xml/features%g" \${FEATURESCONF}
+cat \${FEATURESCONF}
+
+echo "Configuring the log..."
+LOGCONF=/tmp/${BUNDLEFOLDER}/etc/org.ops4j.pax.logging.cfg
+sed -ie 's/log4j.appender.out.maxBackupIndex=10/log4j.appender.out.maxBackupIndex=1/g' \${LOGCONF}
+# FIXME: Make log size limit configurable from build parameter.
+sed -ie 's/log4j.appender.out.maxFileSize=1MB/log4j.appender.out.maxFileSize=100GB/g' \${LOGCONF}
+cat \${LOGCONF}
+
+if [ "${ODL_ENABLE_L3_FWD}" == "yes" ]; then
+ echo "Enable the l3.fwd in custom.properties.."
+ echo "ovsdb.l3.fwd.enabled=yes" >> \${CUSTOMPROP}
+ cat \${CUSTOMPROP}
+fi
+
+echo "Configure java home and max memory..."
+MEMCONF=/tmp/${BUNDLEFOLDER}/bin/setenv
+sed -ie 's%^# export JAVA_HOME%export JAVA_HOME="\${JAVA_HOME:-${JAVA_HOME}}"%g' \${MEMCONF}
+sed -ie 's/JAVA_MAX_MEM="2048m"/JAVA_MAX_MEM="${CONTROLLERMEM}"/g' \${MEMCONF}
+cat \${MEMCONF}
+
+echo "Set Java version"
+sudo /usr/sbin/alternatives --install /usr/bin/java java ${JAVA_HOME}/bin/java 1
+sudo /usr/sbin/alternatives --set java ${JAVA_HOME}/bin/java
+echo "JDK default version ..."
+java -version
+
+echo "Set JAVA_HOME"
+export JAVA_HOME="${JAVA_HOME}"
+# Did you know that in HERE documents, single quote is an ordinary character, but backticks are still executing?
+JAVA_RESOLVED=\`readlink -e "\${JAVA_HOME}/bin/java"\`
+echo "Java binary pointed at by JAVA_HOME: \${JAVA_RESOLVED}"
+
+# Copy shard file if exists
+if [ -f /tmp/custom_shard_config.txt ]; then
+ echo "Custom shard config exists!!!"
+ echo "Copying the shard config..."
+ cp /tmp/custom_shard_config.txt /tmp/${BUNDLEFOLDER}/bin/
+fi
+
+echo "Configuring cluster"
+/tmp/${BUNDLEFOLDER}/bin/configure_cluster.sh \$1 ${nodes_list}