# Licensed 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
-#
+#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# It starts opendaylight, installs the appc features, then shuts down opendaylight.
#
ODL_HOME=${ODL_HOME:-/opt/opendaylight}
-ODL_ADMIN_PASSWORD=${ODL_ADMIN_PASSWORD:-Kp8bJ4SXszM0WXlhak3eHlcse2gAw84vaoGGmJvUy2U}
SDNC_HOME=${SDNC_HOME:-/opt/onap/ccsdk}
APPC_HOME=${APPC_HOME:-/opt/onap/appc}
-SLEEP_TIME=${SLEEP_TIME:-120}
-MYSQL_PASSWD=${MYSQL_PASSWD:-openECOMP1.0}
appcInstallStartTime=$(date +%s)
-
-echo "Waiting ${SLEEP_TIME} seconds for OpenDaylight to initialize"
-sleep ${SLEEP_TIME}
-
+TIME_OUT=1000
+INTERVAL=30
+TIME=0
echo "Checking that Karaf can be accessed"
-clientOutput=$(${ODL_HOME}/bin/client shell:echo KarafLoginCheckIsWorking)
-if echo "$clientOutput" | grep -q "KarafLoginCheckIsWorking"; then
-echo "Karaf login succeeded"
-else
-echo "Error during Karaf login"
-exit 1
+while [ "$TIME" -lt "$TIME_OUT" ]; do
+
+##clientOutput=$(${ODL_HOME}/bin/client shell:echo KarafLoginCheckIsWorking)
+ clientOutput=$(sshpass -pkaraf ssh -o StrictHostKeyChecking=no karaf@localhost -p 8101 "shell:echo KarafLoginCheckIsWorking")
+ if echo "$clientOutput" | grep -q "KarafLoginCheckIsWorking"; then
+ echo "Karaf login succeeded"
+ echo localhost ready in $TIME seconds
+ break;
+ else
+ echo Sleep: $INTERVAL seconds before localhost address is ready. Total wait time up now is: $TIME seconds. Timeout is: $TIME_OUT seconds
+ fi
+
+ sleep $INTERVAL
+ TIME=$(($TIME+$INTERVAL))
+done
+
+if [ "$TIME" -ge "$TIME_OUT" ]; then
+ echo "Error during Karaf login, abort manual run dockerInstall.sh to instaill APPC platform features"
+ exit 1
fi
-echo "Copying a working version of the logging configuration into the opendaylight etc folder"
-cp ${APPC_HOME}/data/org.ops4j.pax.logging.cfg ${ODL_HOME}/etc/org.ops4j.pax.logging.cfg
-#echo "Copying a new version of aaf cadi shiro into the opendaylight deploy folder"
-#cp ${APPC_HOME}/data/aaf-shiro-aafrealm-osgi-bundle.jar ${ODL_HOME}/deploy/aaf-shiro-aafrealm-osgi-bundle.jar
-
-echo "Installing APPC platform features"
+echo "Karaf login is ready, installing APPC platform features"
${APPC_HOME}/bin/installFeatures.sh
-echo "Adding a property system.properties for AAF cadi.properties location"
-echo "" >> ${ODL_HOME}/etc/system.properties
-echo "cadi_prop_files=${APPC_HOME}/data/properties/cadi.properties" >> ${ODL_HOME}/etc/system.properties
-echo "" >> ${ODL_HOME}/etc/system.properties
-
-echo "Adding a value to property appc.asdc.env in appc.properties for appc-asdc-listener feature"
-echo "" >> $APPC_HOME/data/properties/appc.properties
-echo "appc.asdc.env=$DMAAP_TOPIC_ENV" >> $APPC_HOME/data/properties/appc.properties
-echo "" >> $APPC_HOME/data/properties/appc.properties
-
-#echo "Stopping OpenDaylight and waiting for it to stop"
-#${ODL_HOME}/bin/stop
-#The karaf command will exit when odl shuts down. This is the most reliable way to wait for opendaylight to stop
-#before exiting the docker container.
-#${ODL_HOME}/bin/client
-#echo "Karaf process has stopped"
-#sleep 10s
-
appcInstallEndTime=$(date +%s)
echo "Total Appc install took $(expr $appcInstallEndTime - $appcInstallStartTime) seconds"