[Add meta-cmf-filogic sdk cmf for rdkb development]
[Description]
Add meta-cmf-filogic sdk cmf for rdkb development
1. rdkb base on dunfell rdkb-next (> 2022q1)
2. cmf is mostly from meta-turris implementation
3. some 64bit support are port from rp4-64 cmf
4. arm64/arm 32bit bsp both can run on rdkb
[Release-log]
N/A
diff --git a/recipes-rdkb/sysint-broadband/files/DCMscript.sh b/recipes-rdkb/sysint-broadband/files/DCMscript.sh
new file mode 100755
index 0000000..6dfc564
--- /dev/null
+++ b/recipes-rdkb/sysint-broadband/files/DCMscript.sh
@@ -0,0 +1,577 @@
+#!/bin/sh
+##########################################################################
+# If not stated otherwise in this file or this component's Licenses.txt
+# file the following copyright and licenses apply:
+#
+# Copyright 2018 RDK Management
+#
+# 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.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+##########################################################################
+#
+
+. /etc/include.properties
+. /etc/device.properties
+source /etc/log_timestamp.sh
+source /lib/rdk/getpartnerid.sh
+source /lib/rdk/getaccountid.sh
+# Enable override only for non prod builds
+if [ "$BUILD_TYPE" != "prod" ] && [ -f $PERSISTENT_PATH/dcm.properties ]; then
+ . $PERSISTENT_PATH/dcm.properties
+else
+ . /etc/dcm.properties
+fi
+
+if [ -f /lib/rdk/utils.sh ]; then
+ . /lib/rdk/utils.sh
+fi
+
+if [ -f /etc/mount-utils/getConfigFile.sh ];then
+ . /etc/mount-utils/getConfigFile.sh
+fi
+SIGN_FILE="/tmp/.signedRequest_$$_`date +'%s'`"
+DIRECT_BLOCK_TIME=86400
+DIRECT_BLOCK_FILENAME="/tmp/.lastdirectfail_dcm"
+TFTP_SERVER_IP=/tmp/tftpip.txt
+export PATH=$PATH:/usr/bin:/bin:/usr/local/bin:/sbin:/usr/local/lighttpd/sbin:/usr/local/sbin
+export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib:/lib
+
+if [ -z $LOG_PATH ]; then
+ LOG_PATH="/rdklogs/logs"
+fi
+
+if [ -z $PERSISTENT_PATH ]; then
+ PERSISTENT_PATH="/nvram"
+fi
+
+TELEMETRY_PATH="$PERSISTENT_PATH/.telemetry"
+DCMFLAG="/tmp/.DCMSettingsFlag"
+DCM_LOG_FILE="$LOG_PATH/dcmscript.log"
+TELEMETRY_INOTIFY_FOLDER="/rdklogs/logs/"
+TELEMETRY_INOTIFY_EVENT="$TELEMETRY_INOTIFY_FOLDER/eventType.cmd"
+DCMRESPONSE="$PERSISTENT_PATH/DCMresponse.txt"
+TELEMETRY_TEMP_RESEND_FILE="/rdklogs/logs/.temp_resend.txt"
+
+PEER_COMM_ID="/tmp/elxrretyt.swr"
+
+TELEMETRY_PREVIOUS_LOG_COMPLETE="/tmp/.telemetry_previous_log_done"
+TELEMETRY_PREVIOUS_LOG="/tmp/.telemetry_previous_log"
+MAX_PREV_LOG_COMPLETE_WAIT=12
+
+IDLE_TIMEOUT=30
+
+# http header
+HTTP_HEADERS='Content-Type: application/json'
+## RETRY DELAY in secs
+RETRY_DELAY=60
+## RETRY COUNT
+RETRY_COUNT=3
+
+echo_t "Starting execution of DCMscript.sh"
+
+if [ $# -ne 5 ]; then
+ echo_t "Argument does not match"
+ echo 0 > $DCMFLAG
+ exit 1
+fi
+
+. $RDK_PATH/utils.sh
+
+echo "`/bin/timestamp` Starting execution of DCMscript.sh" >> $LOG_PATH/dcmscript.log
+#---------------------------------
+# Initialize Variables
+#---------------------------------
+# URL
+URL=$2
+tftp_server=$3
+reboot_flag=$4
+checkon_reboot=$5
+touch $TFTP_SERVER_IP
+echo_t "URL: "$URL
+echo_t "DCM_TFTP_SERVER: "$tftp_server >> $TFTP_SERVER_IP
+echo_t "BOOT_FLAG: "$reboot_flag
+echo_t "CHECK_ON_REBOOT: "$checkon_reboot
+rm -f $TELEMETRY_TEMP_RESEND_FILE
+
+conn_str="Direct"
+first_conn=useDirectRequest
+sec_conn=useCodebigRequest
+CodebigAvailable=0
+
+
+if [ -f "/tmp/DCMSettings.conf" ]
+then
+ Check_URL=`grep 'urn:settings:ConfigurationServiceURL' /tmp/DCMSettings.conf | cut -d '=' -f2 | head -n 1`
+ if [ -n "$Check_URL" ]
+ then
+ URL=`grep 'urn:settings:ConfigurationServiceURL' /tmp/DCMSettings.conf | cut -d '=' -f2 | head -n 1`
+ #last_char=`echo $URL | sed -e 's/\(^.*\)\(.$\)/\2/'`
+ last_char=`echo $URL | awk '$0=$NF' FS=`
+ if [ "$last_char" != "?" ]
+ then
+ URL="$URL?"
+ fi
+ fi
+fi
+# File to save curl response
+#FILENAME="$PERSISTENT_PATH/DCMresponse.txt"
+TELE_HTTP_CODE="$PERSISTENT_PATH/telemetry_http_code"
+# File to save http code
+HTTP_CODE="$PERSISTENT_PATH/http_code"
+rm -rf $HTTP_CODE
+# Cron job file name
+current_cron_file="$PERSISTENT_PATH/cron_file.txt"
+# Tftpboot Server Ip
+echo TFTP_SERVER: $tftp_server >> $LOG_PATH/dcmscript.log
+# Timeout value
+timeout=30
+default_IP=$DEFAULT_IP
+upload_protocol='TFTP'
+upload_httplink=$HTTP_UPLOAD_LINK
+
+#---------------------------------
+# Function declarations
+#---------------------------------
+
+## FW version from version.txt
+getFWVersion()
+{
+ #cat /version.txt | grep ^imagename:PaceX1 | grep -v image
+ verStr=`cat /version.txt | grep ^imagename: | cut -d ":" -f 2`
+ echo $verStr
+}
+
+## Identifies whether it is a VBN or PROD build
+getBuildType()
+{
+ echo $BUILD_TYPE
+}
+
+## Get ECM mac address
+getECMMacAddress()
+{
+ address=`getECMMac`
+ mac=`echo $address | tr -d ' ' | tr -d '"'`
+ echo $mac
+}
+
+## Get Receiver Id
+getReceiverId()
+{
+ if [ -f "$PERSISTENT_PATH/www/whitebox/wbdevice.dat" ]
+ then
+ ReceiverId=`cat $PERSISTENT_PATH/www/whitebox/wbdevice.dat`
+ echo "$ReceiverId"
+ else
+ echo " "
+ fi
+}
+
+## Get Controller Id
+getControllerId()
+{
+ echo "2504"
+}
+
+## Get ChannelMap Id
+getChannelMapId()
+{
+ echo "2345"
+}
+
+## Get VOD Id
+getVODId()
+{
+ echo "15660"
+}
+
+IsDirectBlocked()
+{
+ ret=0
+ if [ -f $DIRECT_BLOCK_FILENAME ]; then
+ modtime=$(($(date +%s) - $(date +%s -r $DIRECT_BLOCK_FILENAME)))
+ if [ "$modtime" -le "$DIRECT_BLOCK_TIME" ]; then
+ echo "DCM: Last direct failed blocking is still valid, preventing direct" >> $DCM_LOG_FILE
+ ret=1
+ else
+ echo "DCM: Last direct failed blocking has expired, removing $DIRECT_BLOCK_FILENAME, allowing direct" >> $DCM_LOG_FILE
+ rm -f $DIRECT_BLOCK_FILENAME
+ ret=0
+ fi
+ fi
+ return $ret
+}
+
+# Get the configuration of codebig settings
+get_Codebigconfig()
+{
+ # If GetServiceUrl not available, then only direct connection available and no fallback mechanism
+ if [ -f /usr/bin/GetServiceUrl ]; then
+ CodebigAvailable=1
+ fi
+
+ if [ "$CodebigAvailable" -eq "1" ]; then
+ CodeBigEnable=`dmcli eRT getv Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.CodeBigFirst.Enable | grep true 2>/dev/null`
+ fi
+ if [ "$CodebigAvailable" -eq "1" ] && [ "x$CodeBigEnable" != "x" ] ; then
+ conn_str="Codebig"
+ first_conn=useCodebigRequest
+ sec_conn=useDirectRequest
+ fi
+
+ if [ "$CodebigAvailable" -eq 1 ]; then
+ echo_t "Xconf dcm : Using $conn_str connection as the Primary" >> $DCM_LOG_FILE
+ else
+ echo_t "Xconf dcm : Only $conn_str connection is available" >> $DCM_LOG_FILE
+ fi
+}
+
+# Direct connection Download function
+useDirectRequest()
+{
+ # Direct connection will not be tried if .lastdirectfail exists
+ IsDirectBlocked
+ if [ "$?" -eq "1" ]; then
+ return 1
+ fi
+ count=0
+ while [ "$count" -lt "$RETRY_COUNT" ] ; do
+ echo_t " DCM connection type DIRECT"
+ CURL_CMD="curl -w '%{http_code}\n' --tlsv1.2 --interface $EROUTER_INTERFACE $addr_type --connect-timeout $timeout -m $timeout -o \"$FILENAME\" '$HTTPS_URL$JSONSTR'"
+ echo_t "CURL_CMD: $CURL_CMD" >> $DCM_LOG_FILE
+ HTTP_CODE=`result= eval $CURL_CMD`
+ ret=$?
+
+ sleep 2
+ http_code=$(echo "$HTTP_CODE" | awk -F\" '{print $1}' )
+ [ "x$http_code" != "x" ] || http_code=0
+ echo_t "ret = $ret http_code: $http_code" >> $DCM_LOG_FILE
+
+ # log security failure
+ case $ret in
+ 35|51|53|54|58|59|60|64|66|77|80|82|83|90|91)
+ echo_t "DCM Direct Connection Failure Attempt:$count - ret:$ret http_code:$http_code" >> $DCM_LOG_FILE
+ ;;
+ esac
+ if [ $http_code -eq 200 ]; then
+ echo_t "Direct connection success - ret:$ret http_code:$http_code" >> $DCM_LOG_FILE
+ return 0
+ elif [ $http_code -eq 404 ]; then
+ echo "`Timestamp` Direct connection Received HTTP $http_code Response from Xconf Server. Retry logic not needed" >> $DCM_LOG_FILE
+ bypass_conn=1
+ return 0 # Do not return 1, if retry for next conn type is not to be done
+ else
+ if [ "$ret" -eq 0 ]; then
+ echo_t "DCM Direct Connection Failure Attempt:$count - ret:$ret http_code:$http_code" >> $DCM_LOG_FILE
+ fi
+ rm -rf $DCMRESPONSE
+ fi
+ count=$((count + 1))
+ sleep $RETRY_DELAY
+ done
+ echo_t "DCM :Retries for Direct connection exceeded " >> $DCM_LOG_FILE
+ [ "$CodebigAvailable" -ne "1" ] || [ -f $DIRECT_BLOCK_FILENAME ] || touch $DIRECT_BLOCK_FILENAME
+ return 1
+}
+
+# Codebig connection Download function
+useCodebigRequest()
+{
+ # Do not try Codebig if CodebigAvailable != 1 (GetServiceUrl not there)
+ if [ "$CodebigAvailable" -eq "0" ] ; then
+ echo "DCM : Only direct connection Available" >> $DCM_LOG_FILE
+ return 1
+ fi
+ count=0
+ while [ "$count" -lt "$RETRY_COUNT" ] ; do
+ SIGN_CMD="GetServiceUrl 3 \"$JSONSTR\""
+ eval $SIGN_CMD > $SIGN_FILE
+ CB_SIGNED_REQUEST=`cat $SIGN_FILE`
+ rm -f $SIGN_FILE
+ CURL_CMD="curl -w '%{http_code}\n' --tlsv1.2 --interface $EROUTER_INTERFACE $addr_type --connect-timeout $timeout -m $timeout -o \"$FILENAME\" \"$CB_SIGNED_REQUEST\""
+ echo_t " DCM connection type CODEBIG at `echo "$CURL_CMD" | sed -ne 's#.*\(https:.*\)?.*#\1#p'`" >> $DCM_LOG_FILE
+ echo_t "CURL_CMD: `echo "$CURL_CMD" | sed -ne 's#oauth_consumer_key=.*#<hidden>#p'`" >> $DCM_LOG_FILE
+ HTTP_CODE=`result= eval $CURL_CMD`
+ curlret=$?
+ http_code=$(echo "$HTTP_CODE" | awk -F\" '{print $1}' )
+ [ "x$http_code" != "x" ] || http_code=0
+ echo_t "ret = $curlret http_code: $http_code" >> $DCM_LOG_FILE
+
+ # log security failure
+ case $curlret in
+ 35|51|53|54|58|59|60|64|66|77|80|82|83|90|91)
+ echo_t "DCM Codebig Connection Failure Attempt: $count - ret:$curlret http_code:$http_code" >> $DCM_LOG_FILE
+ ;;
+ esac
+ if [ "$http_code" -eq 200 ]; then
+ echo_t "Codebig connection success - ret:$curlret http_code:$http_code" >> $DCM_LOG_FILE
+ return 0
+ elif [ "$http_code" -eq 404 ]; then
+ echo_t "DCM Codebig connection Received HTTP $http_code Response from Xconf Server. Retry logic not needed" >> $DCM_LOG_FILE
+ bypass_conn=1
+ return 0 # Do not return 1, if retry for next conn type is not to be done
+ else
+ if [ "$curlret" -eq 0 ]; then
+ echo_t "DCM Codebig Connection Failure Attempt:$count - ret:$curlret http_code:$http_code" >> $DCM_LOG_FILE
+ fi
+ rm -rf $DCMRESPONSE
+ fi
+ count=$((count + 1))
+ sleep $RETRY_DELAY
+ done
+ echo_t "Retries for Codebig connection exceeded " >> $DCM_LOG_FILE
+ return 1
+}
+
+sendHttpRequestToServer()
+{
+ resp=0
+ FILENAME=$1
+ URL=$2
+ echo "filename--args in sendHttpRequestToServer-------"$FILENAME
+ echo "url---args in sendHttpRequestToServer------"$URL
+
+ estbMacAddress=`ifconfig erouter0 | grep HWaddr | cut -c39-55`
+ JSONSTR=$estbMacAddress
+ CURL_CMD="curl -w "%{http_code}" '$URL?estbMacAddress=$JSONSTR&model=$MODEL_NAME' -o $DCMRESPONSE >> /tmp/telehttpcode.txt "
+ echo "------CURL_CMD:"$CURL_CMD
+
+ # Execute curl command
+ result= eval $CURL_CMD > $TELE_HTTP_CODE
+ #echo "Processing $FILENAME"
+ sleep $timeout
+ echo "sleep for :------------------"$timeout
+ # Get the http_code
+ http_code=$(awk -F\" '{print $1}' /tmp/telehttpcode.txt)
+ #start of pokuru
+
+if [ "$http_code" != "200" ]; then
+ #Added for retry - START
+ rm -rf /tmp/telehttpcode.txt
+ rm -rf $DCMRESPONSE
+
+ xconfRetryCount=0
+ while [ $xconfRetryCount -lt 2 ]
+ do
+ echo "Trying to Retry connection with XCONF server..."
+
+ CURL_CMD="curl -w "%{http_code}" '$URL?estbMacAddress=$JSONSTR&model=$MODEL_NAME' -o $DCMRESPONSE >> /tmp/telehttpcode.txt "
+
+ result= eval $CURL_CMD
+
+ http_code_retry=$(awk -F\" '{print $1}' /tmp/telehttpcode.txt)
+
+ if [ "$http_code_retry" != "200" ]; then
+ echo "Error in establishing communication with xconf server."
+ if [ $xconfRetryCount -ne 0 ]; then sleep 30; fi
+ rm -f /tmp/telehttpcode.txt
+ rm -rf $DCMRESPONSE
+
+ else
+ echo "After retries...No error in curl command and curl http code is:"$http_code_retry
+ resp=0
+ break
+ fi
+
+ xconfRetryCount=`expr $xconfRetryCount + 1`
+ done
+ echo "xconf retry count is:"$xconfRetryCount
+ if [ $xconfRetryCount -eq 2 ]; then
+ echo "No xconf comm ,exiting script"
+ startdcmEnd=`ps -ef | grep -i "StartDCM.sh" | head -n 1`
+ kill -9 $startdcmEnd
+ exit 0
+ fi
+ #Added for retry - END
+ #echo "Error from cloud exiting,check in upcoming reboot-------------"
+ #exit 0
+else
+ echo "No error in curl command and curl http code is:"$http_code
+fi
+ #end of pokuru
+ echo "----------ret http_code:"$http_code
+ echo "----------ret http_code_retry:"$http_code_retry
+
+ if [ $http_code -ne 200 ] ; then
+ if [ $http_code_retry -ne 200 ]; then
+ echo "curl HTTP request failed http_code :"$http_code
+ echo "curl HTTP request failed http_code_retry :"$http_code_retry
+ #pokuru rm -rf /tmp/DCMSettings.conf
+ resp=1
+ fi
+ else
+ echo "curl HTTP request success. Processing response.."
+ resp=0
+ fi
+ echo "----------res:"$resp
+ return $resp
+}
+
+dropbearRecovery()
+{
+ dropbearPid=`ps | grep -i dropbear | grep "$ARM_INTERFACE_IP" | grep -v grep`
+ if [ -z "$dropbearPid" ]; then
+ echo "Dropbear instance is missing ... Recovering dropbear !!! " >> $DCM_LOG_FILE
+ DROPBEAR_PARAMS_1="/tmp/.dropbear/dropcfg1$$"
+ DROPBEAR_PARAMS_2="/tmp/.dropbear/dropcfg2$$"
+ if [ ! -d '/tmp/.dropbear' ]; then
+ echo "wan_ssh.sh: need to create dropbear dir !!! " >> $DCM_LOG_FILE
+ mkdir -p /tmp/.dropbear
+ fi
+ echo "wan_ssh.sh: need to create dropbear files !!! " >> $DCM_LOG_FILE
+ getConfigFile $DROPBEAR_PARAMS_1
+ getConfigFile $DROPBEAR_PARAMS_2
+ dropbear -r $DROPBEAR_PARAMS_1 -r $DROPBEAR_PARAMS_2 -E -s -p $ARM_INTERFACE_IP:22 &
+ sleep 2
+ fi
+ rm -rf /tmp/.dropbear/*
+}
+
+# Safe wait for IP acquisition
+loop=1
+counter=0
+while [ $loop -eq 1 ]
+do
+ estbIp=`ifconfig erouter0 | grep -i inet | cut -d ":" -f2 | cut -d " " -f1`
+ if [ "X$estbIp" == "X" ]; then
+ echo_t "waiting for IP"
+ sleep 2
+ let counter++
+ else
+ echo "got IP in erouter0-------------------"
+ loop=0
+ fi
+done
+
+ ret=1
+ if [ "$estbIp" == "$default_IP" ] ; then
+ ret=0
+ fi
+ if [ $checkon_reboot -eq 1 ]; then
+ echo "call sendHttpRequestToServer-------------------"
+ sendHttpRequestToServer $DCMRESPONSE $URL
+ ret=$?
+ echo_t "sendHttpRequestToServer returned "$ret
+ else
+ ret=0
+ echo_t "sendHttpRequestToServer has not executed since the value of 'checkon_reboot' is $checkon_reboot" >> $DCM_LOG_FILE
+ fi
+
+ echo "after sendHttpRequestToServer-----sleep for 5 sec-------------"
+ sleep 5
+
+
+ if [ $ret -ne 0 ]; then
+ echo_t "Processing response failed." >> $DCM_LOG_FILE
+ rm -rf $FILENAME
+ echo_t "count = $count. Sleeping $RETRY_DELAY seconds ..." >> $DCM_LOG_FILE
+ exit 1
+ fi
+
+ if [ "x$DCA_MULTI_CORE_SUPPORTED" == "xyes" ]; then
+ dropbearRecovery
+
+ isPeriodicFWCheckEnabled=`syscfg get PeriodicFWCheck_Enable`
+ if [ "$isPeriodicFirmwareEnabled" == "true" ]; then
+ echo "XCONF SCRIPT : Calling XCONF Client firmwareSched for the updated time"
+ sh /etc/firmwareSched.sh &
+ fi
+
+ isAxb6Device="no"
+ if [ "$MODEL_NUM" == "TG3482G" ]; then
+ isNvram2Mounted=`grep nvram2 /proc/mounts`
+ if [ "$isNvram2Mounted" == "" -a -d "/nvram/logs" ]; then
+ isAxb6Device="yes"
+ fi
+ fi
+
+ if [ "x$isAxb6Device" == "xno" ]; then
+ # wait for telemetry previous log to be copied to atom
+ loop=1
+ while [ $loop -eq 1 ]
+ do
+ if [ ! -f $TELEMETRY_PREVIOUS_LOG ]; then
+ echo_t "waiting for previous log file" >> $DCM_LOG_FILE
+ sleep 10
+ else
+ echo_t "scp previous logs from arm to atom done, so breaking loop" >> $DCM_LOG_FILE
+ loop=0
+ fi
+ done
+
+ ### Trigger an inotify event on ATOM
+ echo "Telemetry run for previous log trigger to atom" >> $DCM_LOG_FILE
+ GetConfigFile $PEER_COMM_ID
+ ssh -I $IDLE_TIMEOUT -i $PEER_COMM_ID root@$ATOM_INTERFACE_IP "/bin/echo 'xconf_update' > $TELEMETRY_INOTIFY_EVENT" > /dev/null 2>&1
+ rm -f $PEER_COMM_ID
+
+ fi
+
+ # wait for telemetry previous log to be completed upto 2 mins . Avoid indefenite loops
+ loop=1
+ count=0
+ while [ "$loop" = "1" ]
+ do
+ if [ ! -f $TELEMETRY_PREVIOUS_LOG_COMPLETE ]; then
+ echo_t "waiting for previous log done file" >> $DCM_LOG_FILE
+ sleep 10
+ if [ $count -ge $MAX_PREV_LOG_COMPLETE_WAIT ]; then
+ echo_t "Max wait for previous log done file reached. Proceeding with new config from xconf " >> $DCM_LOG_FILE
+ loop=0
+ fi
+ else
+ echo_t "Telemetry run for previous log done, so breaking loop" >> $DCM_LOG_FILE
+ loop=0
+ fi
+ count=`expr $count + 1`
+ done
+
+ GetConfigFile $PEER_COMM_ID
+ scp -i $PEER_COMM_ID $DCMRESPONSE root@$ATOM_INTERFACE_IP:$PERSISTENT_PATH > /dev/null 2>&1
+ if [ $? -ne 0 ]; then
+ scp -i $PEER_COMM_ID $DCMRESPONSE root@$ATOM_INTERFACE_IP:$PERSISTENT_PATH > /dev/null 2>&1
+ fi
+ echo "Signal atom to pick the XCONF config data $DCMRESPONSE and schedule telemetry !!! " >> $DCM_LOG_FILE
+ ## Trigger an inotify event on ATOM
+ ssh -I $IDLE_TIMEOUT -i $PEER_COMM_ID root@$ATOM_INTERFACE_IP "/bin/echo 'xconf_update' > $TELEMETRY_INOTIFY_EVENT" > /dev/null 2>&1
+ rm -f $PEER_COMM_ID
+ else
+ echo "opensource platforms----------------------------"
+
+ isPeriodicFWCheckEnabled=`syscfg get PeriodicFWCheck_Enable`
+ if [ "$isPeriodicFirmwareEnabled" == "true" ]; then
+ echo "XCONF SCRIPT : Calling XCONF Client firmwareSched for the updated time"
+ sh /etc/firmwareSched.sh &
+ fi
+
+ # wait for telemetry previous log to be completed
+ loop=1
+ count=0
+ while [ "$loop" = "1" ]
+ do
+ echo "TELEMETRY_PREVIOUS_LOG_COMPLETE--------------"$TELEMETRY_PREVIOUS_LOG_COMPLETE
+ if [ ! -f $TELEMETRY_PREVIOUS_LOG_COMPLETE ]; then
+ echo_t "waiting for previous log done file"
+ sleep 10
+ if [ $count -ge $MAX_PREV_LOG_COMPLETE_WAIT ]; then
+ echo_t "Max wait for previous log done file reached. Proceeding with new config from xconf "
+ loop=0
+ fi
+ else
+ echo_t "Telemetry run for previous log done, so breaking loop"
+ loop=0
+ fi
+ count=`expr $count + 1`
+ done
+ echo "before calling dca_utility start of TELEMETRY LOGIC-----------------"
+ sh /lib/rdk/dca_utility.sh 1 &
+ fi
diff --git a/recipes-rdkb/sysint-broadband/files/StartDCM.sh b/recipes-rdkb/sysint-broadband/files/StartDCM.sh
new file mode 100755
index 0000000..70655b6
--- /dev/null
+++ b/recipes-rdkb/sysint-broadband/files/StartDCM.sh
@@ -0,0 +1,77 @@
+#!/bin/sh
+##########################################################################
+# If not stated otherwise in this file or this component's Licenses.txt
+# file the following copyright and licenses apply:
+#
+# Copyright 2018 RDK Management
+#
+# 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.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+##########################################################################
+#
+##################################################################
+## Script to start Device Configuration Management script
+## Author: Ajaykumar/Shakeel/Suraj
+##################################################################
+. /etc/include.properties
+
+
+if [ -f "$RDK_PATH/DCMscript.sh" ]
+then
+ if [ -f "$TELEMETRY_JSON_RESPONSE" ]; then
+ echo "remove previous json resp"
+ rm -f $TELEMETRY_JSON_RESPONSE
+ rm -f $PERSISTENT_PATH/*TELE*
+ fi
+ sh /lib/rdk/DCMscript.sh $DCM_LOG_SERVER $DCM_LOG_SERVER_URL $LOG_SERVER 0 1 >> /rdklogs/logs/telemetry.log &
+ sleep 10
+ fileRetryCount=0
+ while [ $fileRetryCount -ne 120 ]
+ do
+ echo "Trying to check if rtl_json files exists ..."
+ if [ -f "/nvram/rtl_json.txt" ]; then
+ echo "files exists !!!!..."
+ #sh $RDK_PATH/DCMscript-log.sh $DCM_LOG_SERVER $DCM_LOG_SERVER_URL $LOG_SERVER 0 1 >> /rdklogs/logs/logupload.log &
+ sleep 5
+ proUpdel=`cat /tmp/DCMSettings.conf | grep -i uploadRepository:uploadProtocol | tr -dc '"' |wc -c`
+ echo "number of proUPdel:"$proUpdel
+ #proUpdel=$((proUpdel - 1))
+ uploadProto=`cat /tmp/DCMSettings.conf | grep -i urn:settings:TelemetryProfile | cut -d '"' -f$proUpdel`
+ echo "Upload protocol is:"$uploadProto
+ if [ "$uploadProto" != "TFTP" ]; then
+ HTTPLOGUPLOADURL=`cat /tmp/DCMSettings.conf | grep -i "urn:settings:LogUploadSettings:RepositoryURL" | cut -d "=" -f2`
+ if [ "$HTTPLOGUPLOADURL" == "" ]; then
+ echo "No HTTP URL configured in xconf,going with internal one !!"
+ HTTPLOGUPLOADURL=$DCM_LA_SERVER_URL
+ fi
+ echo "HTTPURL:"$HTTPLOGUPLOADURL
+ sh $RDK_PATH/uploadSTBLogs.sh $HTTPLOGUPLOADURL 1 1 1 0 0 &
+ break
+ else
+ delimnr=`cat /tmp/DCMSettings.conf | grep -i urn:settings:TelemetryProfile | tr -dc ':' |wc -c`
+ echo "number of deli:"$delimnr
+ delimnr=$((delimnr - 1))
+ TFTPIP=`cat /tmp/DCMSettings.conf | grep -i urn:settings:TelemetryProfile | cut -d ":" -f$delimnr | cut -d '"' -f 2`
+ echo "TFTPIP:"$TFTPIP
+ sleep 5
+ sh $RDK_PATH/uploadSTBLogs.sh $TFTPIP 1 1 1 0 0 &
+ break
+ fi
+ else
+ echo "still file is not there sleep for 5 sec"$fileRetryCount
+ sleep 5
+ fi
+ fileRetryCount=`expr $fileRetryCount + 1`
+ done
+else
+ echo "$RDK_PATH/DCMscript.sh file not found."
+fi
diff --git a/recipes-rdkb/sysint-broadband/files/TurrisFwUpgrade.sh b/recipes-rdkb/sysint-broadband/files/TurrisFwUpgrade.sh
new file mode 100755
index 0000000..e24e244
--- /dev/null
+++ b/recipes-rdkb/sysint-broadband/files/TurrisFwUpgrade.sh
@@ -0,0 +1,74 @@
+#!/bin/bash
+
+if [ $1 ] ; then
+ echo "Usage '/lib/rdk/FwUgrade.sh'"
+ echo "Note: New images should be downloaded in /tmp directory"
+ exit 1
+fi
+
+check ()
+{
+ if [ $? != 0 ]; then
+ echo $*
+ exit 1
+ fi
+}
+
+ls /tmp/zImage* >/dev/null
+check "No new image present in /tmp directory"
+
+BootPartition="/dev/mmcblk0p1"
+NewTurrisModel=1
+
+ActiveRootPartition=`mount | grep "/" -w | cut -d' ' -f1`
+if [ $ActiveRootPartition == "/dev/mmcblk0p2" ]; then
+ TargetRootPartition="/dev/mmcblk0p3"
+elif [ $ActiveRootPartition == "/dev/mmcblk0p3" ]; then
+ TargetRootPartition="/dev/mmcblk0p2"
+elif [ $ActiveRootPartition == "/dev/mmcblk0p5" ]; then
+ TargetRootPartition="/dev/mmcblk0p7"
+ BootPartition="/dev/mmcblk0p3"
+ NewTurrisModel=0
+else ##if $ActiveRootPartition is "/dev/mmcblk0p7"
+ TargetRootPartition="/dev/mmcblk0p5"
+ BootPartition="/dev/mmcblk0p3"
+ NewTurrisMode=0
+fi
+echo "ActiveRootPartition: $ActiveRootPartition"
+echo "TargetRootPartition: $TargetRootPartition"
+echo "BootPartition: $BootPartition"
+
+umount /mnt 2>/dev/null
+echo y | mkfs.ext2 $TargetRootPartition
+check "Error in formatting $TargetRootPartition"
+
+mount $TargetRootPartition /mnt
+check "Error in mounting $TargetRootPartition"
+
+tar -xzf /tmp/*.tar.gz -C /mnt
+check "Error in unpacking new rootfs"
+
+umount /mnt
+check "Error in unmounting"
+echo "New rootfs is loaded in $TargetRootPartition"
+
+mount $BootPartition /mnt/
+check "Error in mounting $BootPartition"
+
+mv /mnt/zImage /zImage_old
+cp /tmp/zImage* /mnt/zImage
+if [ $? != 0 ]; then
+echo "Error in copying zImage. Falling back."
+mv /zImage_old /mnt/zImage
+exit 1
+fi
+
+if [ $NewTurrisModel -eq 1 ]; then
+ if [ $TargetRootPartition == "/dev/mmcblk0p2" ]; then
+ cp /boot-main.scr /mnt/boot.scr
+ else
+ cp /boot-alt.scr /mnt/boot.scr
+ fi
+else
+ fw_setenv yocto_bootargs earlyprintk console=ttyS0,115200 root=$TargetRootPartition rootfstype=ext2 rw rootwait
+fi
diff --git a/recipes-rdkb/sysint-broadband/files/commonUtils.sh b/recipes-rdkb/sysint-broadband/files/commonUtils.sh
new file mode 100755
index 0000000..86c2138
--- /dev/null
+++ b/recipes-rdkb/sysint-broadband/files/commonUtils.sh
@@ -0,0 +1,107 @@
+#!/bin/sh
+##########################################################################
+# If not stated otherwise in this file or this component's Licenses.txt
+# file the following copyright and licenses apply:
+#
+# Copyright 2018 RDK Management
+#
+# 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.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+##########################################################################
+#
+. /etc/include.properties
+. /etc/device.properties
+
+REBOOTLOG="$LOG_PATH/ocapri_log.txt"
+export PATH=$PATH:/sbin:/usr/sbin
+CORE_LOG="$LOG_PATH/core_log.txt"
+
+#This is need to set core path for yocto builds
+if [ -f /etc/os-release ]; then
+ export CORE_PATH="/var/lib/systemd/coredump/"
+fi
+
+Timestamp()
+{
+ date +"%Y-%m-%d %T"
+}
+
+resetRebootFlag()
+{
+ message=$1
+ echo `Timestamp` 'Rebooting the box'>>$REBOOTLOG;
+ echo 0 > /opt/.rebootFlag
+ echo `/bin/timestamp` ------------ $message ----------------- >> $REBOOTLOG
+}
+
+# Return system uptime in seconds
+Uptime()
+{
+ cat /proc/uptime | awk '{ split($1,a,"."); print a[1]; }'
+}
+
+# get eSTB IP address
+getIPAddress()
+{
+ if [ -f /tmp/estb_ipv6 ]; then
+ ifconfig -a $DEFAULT_ESTB_INTERFACE | grep inet6 | tr -s " " | grep -v Link | cut -d " " -f4 | cut -d "/" -f1 | head -n1
+ else
+ ifconfig -a $ESTB_INTERFACE | grep inet | grep -v inet6 | tr -s " " | cut -d ":" -f2 | cut -d " " -f1 | head -n1
+ fi
+
+}
+
+## get eSTB mac address
+getMacAddress()
+{
+ ifconfig -a $ESTB_INTERFACE | grep $ESTB_INTERFACE | tr -s ' ' | cut -d ' ' -f5
+}
+
+getMacAddressOnly()
+{
+ ifconfig -a $ESTB_INTERFACE | grep $ESTB_INTERFACE | tr -s ' ' | cut -d ' ' -f5 | sed 's/://g'
+}
+
+# argument is maximum time to wait in seconds
+waitForDumpCompletion()
+{
+ waitTime=$1
+ while [[ `dumpInProcess` == 'true' ]];
+ do
+ echo "Waiting for core dump completion." >> $CORE_LOG
+ count=`expr $count + 1`
+ sleep 1
+ if [ $count -gt $waitTime ]; then
+ echo "Core dump creation is taking more time than expected. Returning." >> $CORE_LOG
+ return
+ fi
+ done
+}
+
+dumpInProcess()
+{
+ if [[ -n "`ls $CORE_PATH/*.gz.tmp 2>/dev/null`" ]]; then
+ echo 'true'
+ else
+ echo 'false'
+ fi
+}
+
+haveCoreToUpload()
+{
+ if [[ -n "`ls $CORE_PATH/*.gz.tmp 2>/dev/null`" ]] || [[ -n "`ls $CORE_PATH/*.gz 2>/dev/null`" ]]; then
+ echo 'true'
+ else
+ echo 'false'
+ fi
+}
+
diff --git a/recipes-rdkb/sysint-broadband/files/dcaSplunkUpload.sh b/recipes-rdkb/sysint-broadband/files/dcaSplunkUpload.sh
new file mode 100755
index 0000000..246a861
--- /dev/null
+++ b/recipes-rdkb/sysint-broadband/files/dcaSplunkUpload.sh
@@ -0,0 +1,546 @@
+#!/bin/sh
+##########################################################################
+# If not stated otherwise in this file or this component's Licenses.txt
+# file the following copyright and licenses apply:
+#
+# Copyright 2016 RDK Management
+#
+# 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.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+##########################################################################
+
+
+####
+## This script will be invoked upon receiving events from ATOM when processed telemetry dat is available for upload
+## This cript is expected to pull the
+####
+
+. /etc/include.properties
+. /etc/device.properties
+
+if [ -f /lib/rdk/utils.sh ]; then
+ . /lib/rdk/utils.sh
+fi
+source /etc/log_timestamp.sh
+TELEMETRY_PATH="$PERSISTENT_PATH/.telemetry"
+TELEMETRY_RESEND_FILE="$PERSISTENT_PATH/.resend.txt"
+TELEMETRY_TEMP_RESEND_FILE="$PERSISTENT_PATH/.temp_resend.txt"
+
+TELEMETRY_PROFILE_DEFAULT_PATH="/tmp/DCMSettings.conf"
+TELEMETRY_PROFILE_RESEND_PATH="$PERSISTENT_PATH/.DCMSettings.conf"
+TELEMETRY_TFTP_UPLOAD_JSON_FILE="$PERSISTENT_PATH/tftp_json.txt"
+
+RTL_LOG_FILE="$LOG_PATH/dcmscript.log"
+
+HTTP_FILENAME="$TELEMETRY_PATH/dca_httpresult.txt"
+
+DCMRESPONSE="$PERSISTENT_PATH/DCMresponse.txt"
+
+PEER_COMM_ID="/tmp/elxrretyt.swr"
+
+#pokuru if [ ! -f /usr/bin/GetConfigFile ];then
+ #pokuru echo "Error: GetConfigFile Not Found"
+ #pokuru exit 127
+#pokuru fi
+
+SIGN_FILE="/tmp/.signedRequest_$$_`date +'%s'`"
+DIRECT_BLOCK_TIME=86400
+DIRECT_BLOCK_FILENAME="/tmp/.lastdirectfail_dca"
+
+SLEEP_TIME_FILE="/tmp/.rtl_sleep_time.txt"
+#MAX_LIMIT_RESEND=2
+# Max backlog queue set to 5, after which the resend file will discard subsequent entries
+MAX_CONN_QUEUE=5
+DIRECT_RETRY_COUNT=2
+
+ignoreResendList="false"
+
+# exit if an instance is already running
+if [ ! -f /tmp/.dca-splunk.upload ];then
+ # store the PID
+ echo $$ > /tmp/.dca-splunk.upload
+else
+ pid=`cat /tmp/.dca-splunk.upload`
+ if [ -d /proc/$pid ];then
+ echo_t "dca : previous instance of dcaSplunkUpload.sh is running."
+ ignoreResendList="true"
+ # Cannot exit as triggers can be from immediate log upload
+ else
+ rm -f /tmp/.dca-splunk.upload
+ echo $$ > /tmp/.dca-splunk.upload
+ fi
+fi
+
+conn_type_used="" # Use this to check the connection success, else set to fail
+conn_type="Direct" # Use this to check the connection success, else set to fail
+first_conn=useDirectRequest
+sec_conn=useCodebigRequest
+CodebigAvailable=0
+
+CURL_TIMEOUT=30
+TLS="--tlsv1.2"
+
+mkdir -p $TELEMETRY_PATH
+
+# Processing Input Args
+inputArgs=$1
+
+# dca_utility.sh does not uses TELEMETRY_PROFILE_RESEND_PATH, to hardwired to TELEMETRY_PROFILE_DEFAULT_PATH
+[ "x$sendInformation" != "x" ] || sendInformation=1
+if [ "$sendInformation" -ne 1 ] ; then
+ TELEMETRY_PROFILE_PATH=$TELEMETRY_PROFILE_RESEND_PATH
+else
+ TELEMETRY_PROFILE_PATH=$TELEMETRY_PROFILE_DEFAULT_PATH
+fi
+
+echo "Telemetry Profile File Being Used : $TELEMETRY_PROFILE_PATH" >> $RTL_LOG_FILE
+
+#Adding support for opt override for dcm.properties file
+if [ "$BUILD_TYPE" != "prod" ] && [ -f $PERSISTENT_PATH/dcm.properties ]; then
+ . $PERSISTENT_PATH/dcm.properties
+else
+ . /etc/dcm.properties
+fi
+TelemetryNewEndpointAvailable=0
+getTelemetryEndpoint() {
+ DEFAULT_DCA_UPLOAD_URL="$DCA_UPLOAD_URL"
+ TelemetryEndpoint=`dmcli eRT getv Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.TelemetryEndpoint.Enable | grep value | awk '{print $5}'`
+ TelemetryEndpointURL=""
+ if [ "x$TelemetryEndpoint" = "xtrue" ]; then
+ TelemetryEndpointURL=`dmcli eRT getv Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.TelemetryEndpoint.URL | grep value | awk '{print $5}'`
+ if [ ! -z "$TelemetryEndpointURL" ]; then
+ DCA_UPLOAD_URL="https://$TelemetryEndpointURL"
+ echo_t "dca upload url from RFC is $TelemetryEndpointURL" >> $RTL_LOG_FILE
+ TelemetryNewEndpointAvailable=1
+ fi
+ else
+ if [ -f "$DCMRESPONSE" ]; then
+ TelemetryEndpointURL=`grep '"uploadRepository:URL":"' $DCMRESPONSE | awk -F 'uploadRepository:URL":' '{print $NF}' | awk -F '",' '{print $1}' | sed 's/"//g' | sed 's/}//g'`
+
+ if [ ! -z "$TelemetryEndpointURL" ]; then
+ DCA_UPLOAD_URL="$TelemetryEndpointURL"
+ echo_t "dca upload url from dcmresponse is $TelemetryEndpointURL" >> $RTL_LOG_FILE
+ fi
+ fi
+ fi
+
+ if [ -z "$TelemetryEndpointURL" ]; then
+ DCA_UPLOAD_URL="$DEFAULT_DCA_UPLOAD_URL"
+ fi
+}
+
+getTelemetryEndpoint
+
+if [ -z $DCA_UPLOAD_URL ]; then
+ echo_t "dca upload url read from dcm.properties is NULL"
+ exit 1
+fi
+
+pidCleanup()
+{
+ # PID file cleanup
+ if [ -f /tmp/.dca-splunk.upload ];then
+ rm -rf /tmp/.dca-splunk.upload
+ fi
+}
+
+IsDirectBlocked()
+{
+ ret=0
+ # Temporarily disabling blocking of direct connection due to increased load on Codebig servers.
+ return $ret
+}
+
+# Get the configuration of codebig settings
+get_Codebigconfig()
+{
+ # If GetServiceUrl not available, then only direct connection available and no fallback mechanism
+ if [ -f /usr/bin/GetServiceUrl ]; then
+ CodebigAvailable=1
+ fi
+ if [ "$CodebigAvailable" -eq "1" ]; then
+ CodeBigEnable=`dmcli eRT getv Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.CodeBigFirst.Enable | grep true 2>/dev/null`
+ fi
+ if [ "$CodebigAvailable" -eq "1" ] && [ "x$CodeBigEnable" != "x" ] ; then
+ conn_type="Codebig"
+ first_conn=useCodebigRequest
+ sec_conn=useDirectRequest
+ fi
+
+ if [ "$CodebigAvailable" -eq 1 ]; then
+ echo_t "dca : Using $conn_type connection as the Primary" >> $RTL_LOG_FILE
+ else
+ echo_t "dca : Only $conn_type connection is available" >> $RTL_LOG_FILE
+ fi
+}
+
+# Direct connection Download function
+useDirectRequest()
+{
+ # Direct connection will not be tried if .lastdirectfail exists
+ IsDirectBlocked
+ if [ "$?" -eq "1" ]; then
+ return 1
+ fi
+ echo_t "dca$2: Using Direct commnication"
+ proUpdel=`cat /tmp/DCMSettings.conf | grep -i uploadRepository:uploadProtocol | tr -dc '"' |wc -c`
+ echo "number of proUPdel1:"$proUpdel
+ #proUpdel=$((proUpdel - 1))
+ uploadProtocoltel=`cat /tmp/DCMSettings.conf | grep -i urn:settings:TelemetryProfile | cut -d '"' -f$proUpdel`
+ echo "Upload protocol telemetry is:"$uploadProtocoltel
+ if [ "$uploadProtocoltel" != "TFTP" ]; then
+ echo "before HTTP upload"
+ delimhttp=`cat /tmp/DCMSettings.conf | grep -i uploadRepository:uploadProtocol | tr -dc '"' |wc -c`
+ echo "number of httpdeli:"$delimhttp
+ delimhttp=$((delimhttp - 4))
+ HTTPURL=`cat /tmp/DCMSettings.conf | grep -i urn:settings:TelemetryProfile | cut -d '"' -f$delimhttp`
+ if [ "$HTTPURL" == "" ]; then
+ echo "No HTTP URL configured in xconf,going with internal one !!"
+ HTTPURL=$DCM_HTTP_SERVER_URL
+ fi
+ echo "HTTPTELEMETRYURL:"$HTTPURL
+ CURL_CMD="curl --tlsv1.2 -w '%{http_code}\n' -H \"Accept: application/json\" -H \"Content-type: application/json\" -X POST -d @/nvram/rtl_json.txt '$HTTPURL' --connect-timeout 30 -m 30"
+ echo "------CURL_CMD:"$CURL_CMD
+ HTTP_CODE=`result= eval $CURL_CMD`
+ http_code=$(echo "$HTTP_CODE" | awk -F\" '{print $1}' )
+ echo "http code in telemetry is :"$http_code
+ #curl --tlsv1.2 -w '%{http_code}\n' -H "Accept: application/json" -H "Content-type: application/json" -X POST -d @/nvram/hell.txt '$HTTPURL' -o "/nvram/dca_httpresult.txt" --connect-timeout 30 -m 30
+ if [ $http_code -eq 200 ]; then
+ echo "HTTP telemetry curl upload succeded!!!!!!!!!!!!!!!!!"
+ ret=0
+ else
+ uploadRetryCount=0
+ while [ $uploadRetryCount -lt 2 ]
+ do
+ echo "Trying to upload telemetry file..."
+ CURL_CMD="curl --tlsv1.2 -w '%{http_code}\n' -H \"Accept: application/json\" -H \"Content-type: application/json\" -X POST -d @/nvram/rtl_json.txt '$HTTPURL' --connect-timeout 30 -m 30"
+ HTTP_CODE=`result= eval $CURL_CMD`
+ http_code_retry=$(echo "$HTTP_CODE" | awk -F\" '{print $1}' )
+ echo "http code in telemetry is :"$http_code_retry
+ if [ "$http_code_retry" != "200" ]; then
+ echo "Error in uploading telemetry file"
+ else
+ echo "telemetry json upload succeded in retry"
+ ret=0
+ break
+ fi
+ uploadRetryCount=`expr $uploadRetryCount + 1`
+ done
+ if [ $uploadRetryCount -eq 2]; then
+ ret=1
+ echo "HTTP telemetry curl upload failed!!!!!!!!!!!!!!!!!"
+ fi
+ fi
+ if [ $ret -eq 0 ]; then
+ echo_t "dca$2: Direct connection success - ret:$ret " >> $RTL_LOG_FILE
+ # Use direct connection for rest of the connections
+ conn_type_used="Direct"
+ cd ..
+ return 0
+ else
+ echo_t "dca$2: Direct Connection Failure - ret:$ret " >> $RTL_LOG_FILE
+ direct_retry=$(( direct_retry += 1 ))
+ if [ "$direct_retry" -ge "$DIRECT_RETRY_COUNT" ]; then
+ # .lastdirectfail will not be created for only direct connection
+ [ "$CodebigAvailable" -ne "1" ] || [ -f $DIRECT_BLOCK_FILENAME ] || touch $DIRECT_BLOCK_FILENAME
+ fi
+ sleep 10
+ cd ..
+ return 1
+ fi
+ else
+ echo "before TFTP load-----------"
+ delimnr=`cat /tmp/DCMSettings.conf | grep -i urn:settings:TelemetryProfile | tr -dc ':' |wc -c`
+ echo "number of delim:"$delimnr
+ delimnr=$((delimnr - 1))
+ IP=`cat /tmp/DCMSettings.conf | grep -i urn:settings:TelemetryProfile | cut -d ":" -f$delimnr | cut -d '"' -f 2`
+ echo "tftp ip is :"$IP
+ cd /nvram/
+ if [ -f "rtl_json.txt" ]; then
+ echo "rtl_json.txt available,going for tftp upload"
+ iptables -t raw -I OUTPUT -j CT -p udp -m udp --dport 69 --helper tftp
+ TurrisMacAddress=`ifconfig erouter0 | grep HWaddr | cut -c39-55`
+ extractVal=`echo $TurrisMacAddress | sed -e 's/://g'`
+ dt=`date "+%m-%d-%y-%I-%M%p"`
+ cp /nvram/rtl_json.txt /nvram/$extractVal-TELE-$dt.json
+ tftp -p -r $extractVal-TELE-$dt.json $IP
+ else
+ echo "No rtl_json.txt available,returning 1"
+ return 1
+ fi
+ ret=$?
+ echo $ret
+ if [ "$ret" -eq 1 ]; then
+ tftpuploadRetryCount=0
+ while [ $tftpuploadRetryCount -lt 2 ]
+ do
+ echo "Trying to upload telemetry file using tftp again..."
+ tftp -p -r $extractVal-TELE-$dt.json $IP
+ ret=$?
+ if [ "$ret" -eq 1 ]; then
+ echo "error in uploading using tftp"
+ else
+ echo "tftp upload in retry succeded"
+ ret=0
+ break
+ fi
+ tftpuploadRetryCount=`expr $tftpuploadRetryCount + 1`
+ done
+ if [ "$tftpuploadRetryCount" -eq 2]; then
+ ret=1
+ echo "TFTP telemetry upload failed!!!!!!!!!!!!!!!!!"
+ fi
+ else
+ echo "TFTP Telemetry succeded !!!"
+ ret=0
+ fi
+ sleep 10
+
+ echo_t "dca $2 : Direct Connection HTTP RESPONSE CODE : $http_code" >> $RTL_LOG_FILE
+ if [ $ret -eq 0 ]; then
+ echo_t "dca$2: Direct connection success - ret:$ret " >> $RTL_LOG_FILE
+ # Use direct connection for rest of the connections
+ conn_type_used="Direct"
+ cd ..
+ return 0
+ else
+ echo_t "dca$2: Direct Connection Failure - ret:$ret " >> $RTL_LOG_FILE
+ direct_retry=$(( direct_retry += 1 ))
+ if [ "$direct_retry" -ge "$DIRECT_RETRY_COUNT" ]; then
+ # .lastdirectfail will not be created for only direct connection
+ [ "$CodebigAvailable" -ne "1" ] || [ -f $DIRECT_BLOCK_FILENAME ] || touch $DIRECT_BLOCK_FILENAME
+ fi
+ sleep 10
+ cd ..
+ return 1
+ fi
+ fi
+}
+
+# Codebig connection Download function
+useCodebigRequest()
+{
+ # Do not try Codebig if CodebigAvailable != 1 (GetServiceUrl not there)
+ if [ "$CodebigAvailable" -eq "0" ] ; then
+ echo "dca$2 : Only direct connection Available"
+ return 1
+ fi
+
+ if [ "x$CodeBigEnable" = "x" ] ; then
+ echo_t "dca$2 : Codebig connection attempts are disabled through RFC. Exiting !!!" >> $RTL_LOG_FILE
+ return 1
+ fi
+
+ if [ "$TelemetryNewEndpointAvailable" -eq "1" ]; then
+ SIGN_CMD="GetServiceUrl 10 "
+ else
+ SIGN_CMD="GetServiceUrl 9 "
+ fi
+ eval $SIGN_CMD > $SIGN_FILE
+ CB_SIGNED_REQUEST=`cat $SIGN_FILE`
+ rm -f $SIGN_FILE
+ CURL_CMD="curl $TLS -w '%{http_code}\n' --interface $EROUTER_INTERFACE $addr_type -H \"Accept: application/json\" -H \"Content-type: application/json\" -X POST -d '$1' -o \"$HTTP_FILENAME\" \"$CB_SIGNED_REQUEST\" --connect-timeout $CURL_TIMEOUT -m $CURL_TIMEOUT"
+ echo_t "dca$2: Using Codebig connection at `echo "$CURL_CMD" | sed -ne 's#.*\(https:.*\)?.*#\1#p'`" >> $RTL_LOG_FILE
+ echo_t "CURL_CMD: `echo "$CURL_CMD" | sed -ne 's#oauth_consumer_key=.*oauth_signature=.* --#<hidden> --#p'`" >> $RTL_LOG_FILE
+ HTTP_CODE=`curl $TLS -w '%{http_code}\n' --interface $EROUTER_INTERFACE $addr_type -H "Accept: application/json" -H "Content-type: application/json" -X POST -d "$1" -o "$HTTP_FILENAME" "$CB_SIGNED_REQUEST" --connect-timeout $CURL_TIMEOUT -m $CURL_TIMEOUT`
+ curlret=$?
+ http_code=$(echo "$HTTP_CODE" | awk -F\" '{print $1}' )
+ [ "x$http_code" != "x" ] || http_code=0
+ # log security failure
+ echo_t "dca $2 : Codebig Connection HTTP RESPONSE CODE : $http_code" >> $RTL_LOG_FILE
+ case $curlret in
+ 35|51|53|54|58|59|60|64|66|77|80|82|83|90|91)
+ echo_t "dca$2: Codebig Connection Failure - ret:$curlret http_code:$http_code" >> $RTL_LOG_FILE
+ ;;
+ esac
+ if [ "$http_code" -eq 200 ]; then
+ echo_t "dca$2: Codebig connection success - ret:$curlret http_code:$http_code" >> $RTL_LOG_FILE
+ conn_type_used="Codebig"
+ return 0
+ fi
+ if [ "$curlret" -eq 0 ]; then
+ echo_t "dca$2: Codebig Connection Failure - ret:$curlret http_code:$http_code" >> $RTL_LOG_FILE
+ fi
+ sleep 10
+ return 1
+}
+
+# Function to get erouter0 ipv4 address
+getErouterIpv4()
+{
+ erouter_ipv4=`dmcli eRT getv Device.DeviceInfo.X_COMCAST-COM_WAN_IP | grep value | awk '{print $5}'`
+ if [ "$erouter_ipv4" != "" ];then
+ echo $erouter_ipv4
+ else
+ echo "null"
+ fi
+}
+
+# Function to get erouter0 ipv6 address
+getErouterIpv6()
+{
+ erouter_ipv6=`dmcli eRT getv Device.DeviceInfo.X_COMCAST-COM_WAN_IPv6 | grep value | awk '{print $5}'`
+ if [ "$erouter_ipv6" != "" ];then
+ echo $erouter_ipv6
+ else
+ echo "null"
+ fi
+}
+
+timestamp=`date +%Y-%b-%d_%H-%M-%S`
+#main app
+estbMac=`getErouterMacAddress`
+cur_time=`date "+%Y-%m-%d %H:%M:%S"`
+erouteripv4=`getErouterIpv4`
+erouteripv6=`getErouterIpv6`
+DEFAULT_IPV4="<#=#>EROUTER_IPV4<#=#>"
+DEFAULT_IPV6="<#=#>EROUTER_IPV6<#=#>"
+
+# If interface doesnt have ipv6 address then we will force the curl to go with ipv4.
+# Otherwise we will not specify the ip address family in curl options
+addr_type=""
+[ "x`ifconfig $EROUTER_INTERFACE | grep inet6 | grep -i 'Global'`" != "x" ] || addr_type="-4"
+
+if [ "x$DCA_MULTI_CORE_SUPPORTED" = "xyes" ]; then
+ ## 1] Pull processed data from ATOM
+ rm -f $TELEMETRY_JSON_RESPONSE
+
+
+ GetConfigFile $PEER_COMM_ID
+ scp -i $PEER_COMM_ID root@$ATOM_INTERFACE_IP:$TELEMETRY_JSON_RESPONSE $TELEMETRY_JSON_RESPONSE > /dev/null 2>&1
+ if [ $? -ne 0 ]; then
+ scp -i $PEER_COMM_ID root@$ATOM_INTERFACE_IP:$TELEMETRY_JSON_RESPONSE $TELEMETRY_JSON_RESPONSE > /dev/null 2>&1
+ fi
+ echo_t "Copied $TELEMETRY_JSON_RESPONSE " >> $RTL_LOG_FILE
+ rm -f $PEER_COMM_ID
+ sleep 2
+fi
+
+# Add the erouter MAC address from ARM as this is not available in ATOM
+sed -i -e "s/ErouterMacAddress/$estbMac/g" $TELEMETRY_JSON_RESPONSE
+
+
+if [ ! -f $SLEEP_TIME_FILE ]; then
+ if [ -f $DCMRESPONSE ]; then
+ cron=`grep -i TelemetryProfile $DCMRESPONSE | awk -F '"schedule":' '{print $NF}' | awk -F "," '{print $1}' | sed 's/://g' | sed 's/"//g' | sed -e 's/^[ ]//' | sed -e 's/^[ ]//'`
+ fi
+
+ if [ -n "$cron" ]; then
+ sleep_time=`echo "$cron" | awk -F '/' '{print $2}' | cut -d ' ' -f1`
+ fi
+
+ if [ -n "$sleep_time" ];then
+ sleep_time=`expr $sleep_time - 1` #Subtract 1 miute from it
+ sleep_time=`expr $sleep_time \* 60` #Make it to seconds
+ # Adding generic RANDOM number implementation as sh in RDK_B doesn't support RANDOM
+ RANDOM=`awk -v min=5 -v max=10 'BEGIN{srand(); print int(min+rand()*(max-min+1)*(max-min+1)*1000)}'`
+ sleep_time=$(($RANDOM%$sleep_time)) #Generate a random value out of it
+ echo "$sleep_time" > $SLEEP_TIME_FILE
+ else
+ sleep_time=10
+ fi
+else
+ sleep_time=`cat $SLEEP_TIME_FILE`
+fi
+
+if [ -z "$sleep_time" ];then
+ sleep_time=10
+fi
+
+if [ "$inputArgs" = "logbackup_without_upload" ];then
+ echo_t "log backup during bootup, Will upload on later call..!"
+ if [ -f $TELEMETRY_JSON_RESPONSE ]; then
+ outputJson=`cat $TELEMETRY_JSON_RESPONSE`
+ fi
+ if [ ! -f $TELEMETRY_JSON_RESPONSE ] || [ "x$outputJson" = "x" ] ; then
+ echo_t "dca: Unable to find Json message or Json is empty." >> $RTL_LOG_FILE
+ if [ ! -f /etc/os-release ];then pidCleanup; fi
+ exit 0
+ fi
+ if [ -f $TELEMETRY_RESEND_FILE ]; then
+ #If resend queue has already reached MAX_CONN_QUEUE entries then remove recent two
+ if [ "`cat $TELEMETRY_RESEND_FILE | wc -l`" -ge "$MAX_CONN_QUEUE" ]; then
+ echo_t "resend queue size at its max. removing recent two entries" >> $RTL_LOG_FILE
+ sed -i '1,2d' $TELEMETRY_RESEND_FILE
+ fi
+ mv $TELEMETRY_RESEND_FILE $TELEMETRY_TEMP_RESEND_FILE
+ fi
+ # ensure that Json is put at the top of the queue
+ echo "$outputJson" > $TELEMETRY_RESEND_FILE
+ if [ -f $TELEMETRY_TEMP_RESEND_FILE ] ; then
+ cat $TELEMETRY_TEMP_RESEND_FILE >> $TELEMETRY_RESEND_FILE
+ rm -f $TELEMETRY_TEMP_RESEND_FILE
+ fi
+ if [ ! -f /etc/os-release ];then pidCleanup; fi
+ exit 0
+fi
+get_Codebigconfig
+direct_retry=0
+## 2] Check for unsuccessful posts from previous execution in resend que.
+## If present repost either with appending to existing or as independent post
+echo "=============Telemetry has file only one upload======================="
+if [ -f $TELEMETRY_RESEND_FILE ] && [ "x$ignoreResendList" != "xtrue" ]; then
+ echo "=============Loop1======================="
+ rm -f $TELEMETRY_TEMP_RESEND_FILE
+ while read resend
+ do
+ resend=`echo $resend | sed "s/$DEFAULT_IPV4/$erouteripv4/" | sed "s/$DEFAULT_IPV6/$erouteripv6/"`
+ echo_t "dca resend : $resend" >> $RTL_LOG_FILE
+ $first_conn "$resend" "resend" || $sec_conn "$resend" "resend" || conn_type_used="Fail"
+
+ if [ "x$conn_type_used" = "xFail" ] ; then
+ echo "$resend" >> $TELEMETRY_TEMP_RESEND_FILE
+ echo_t "dca Connecion failed for this Json : requeuing back" >> $RTL_LOG_FILE
+ fi
+ echo_t "dca Attempting next Json in the queue " >> $RTL_LOG_FILE
+ sleep 10
+ done < $TELEMETRY_RESEND_FILE
+ sleep 2
+ rm -f $TELEMETRY_RESEND_FILE
+fi
+
+## 3] Attempt to post current message. Check for status if failed add it to resend queue
+if [ -f $TELEMETRY_JSON_RESPONSE ]; then
+ outputJson=`cat $TELEMETRY_JSON_RESPONSE`
+fi
+if [ ! -f $TELEMETRY_JSON_RESPONSE ] || [ "x$outputJson" = "x" ] ; then
+ echo_t "dca: Unable to find Json message or Json is empty." >> $RTL_LOG_FILE
+ [ ! -f $TELEMETRY_TEMP_RESEND_FILE ] || mv $TELEMETRY_TEMP_RESEND_FILE $TELEMETRY_RESEND_FILE
+ if [ ! -f /etc/os-release ];then pidCleanup; fi
+ exit 0
+fi
+
+echo "$outputJson" > $TELEMETRY_RESEND_FILE
+# sleep for random time before upload to avoid bulk requests on splunk server
+echo_t "dca: Sleeping for $sleep_time before upload." >> $RTL_LOG_FILE
+sleep $sleep_time
+timestamp=`date +%Y-%b-%d_%H-%M-%S`
+$first_conn "$outputJson" || $sec_conn "$outputJson" || conn_type_used="Fail"
+if [ "x$conn_type_used" != "xFail" ]; then
+ echo_t "dca: Json message successfully submitted." >> $RTL_LOG_FILE
+ rm -f $TELEMETRY_RESEND_FILE
+ [ ! -f $TELEMETRY_TEMP_RESEND_FILE ] || mv $TELEMETRY_TEMP_RESEND_FILE $TELEMETRY_RESEND_FILE
+else
+ if [ -f $TELEMETRY_TEMP_RESEND_FILE ] ; then
+ if [ "`cat $TELEMETRY_TEMP_RESEND_FILE | wc -l `" -ge "$MAX_CONN_QUEUE" ]; then
+ echo_t "dca: resend queue size has already reached MAX_CONN_QUEUE. Not adding anymore entries" >> $RTL_LOG_FILE
+ mv $TELEMETRY_TEMP_RESEND_FILE $TELEMETRY_RESEND_FILE
+ else
+ cat $TELEMETRY_TEMP_RESEND_FILE >> $TELEMETRY_RESEND_FILE
+ echo_t "dca: Json message submit failed. Adding message to resend queue" >> $RTL_LOG_FILE
+ fi
+ rm -f $TELEMETRY_TEMP_RESEND_FILE
+ fi
+fi
+#rm -f $TELEMETRY_JSON_RESPONSE
+# PID file cleanup
+if [ ! -f /etc/os-release ];then pidCleanup; fi
diff --git a/recipes-rdkb/sysint-broadband/files/dca_utility.sh b/recipes-rdkb/sysint-broadband/files/dca_utility.sh
new file mode 100755
index 0000000..5cd86b6
--- /dev/null
+++ b/recipes-rdkb/sysint-broadband/files/dca_utility.sh
@@ -0,0 +1,779 @@
+#!/bin/sh
+##########################################################################
+# If not stated otherwise in this file or this component's Licenses.txt
+# file the following copyright and licenses apply:
+#
+# Copyright 2016 RDK Management
+#
+# 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.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+##########################################################################
+
+. /etc/include.properties
+. /etc/device.properties
+
+echo "inside dca_utility script with 1 as value for arguments"
+
+if [ -f /lib/rdk/utils.sh ]; then
+ . /lib/rdk/utils.sh
+fi
+if [ -f /etc/mount-utils/getConfigFile.sh ];then
+ . /etc/mount-utils/getConfigFile.sh
+fi
+source /etc/log_timestamp.sh
+source /lib/rdk/getpartnerid.sh
+source /lib/rdk/getaccountid.sh
+EROUTER_IF=erouter0
+DCMRESPONSE="$PERSISTENT_PATH/DCMresponse.txt"
+DCM_SETTINGS_CONF="/tmp/DCMSettings.conf"
+
+TELEMETRY_PATH="$PERSISTENT_PATH/.telemetry"
+TELEMETRY_PATH_TEMP="$TELEMETRY_PATH/tmp"
+TELEMETRY_PROFILE_PATH="$PERSISTENT_PATH/.DCMSettings.conf"
+LOG_SYNC_PATH="/rdklogs/logs/"
+
+RTL_LOG_FILE="$LOG_PATH/dcmProcessing.log"
+RTL_DELTA_LOG_FILE="$RAMDISK_PATH/.rtl_temp.log"
+MAP_PATTERN_CONF_FILE="$TELEMETRY_PATH/dcafile.conf"
+TEMP_PATTERN_CONF_FILE="$TELEMETRY_PATH/temp_dcafile.conf"
+EXEC_COUNTER_FILE="/tmp/.dcaCounter.txt"
+
+# Persist this files for telemetry operation
+# Regenerate this only when there is a change identified from XCONF update
+SORTED_PATTERN_CONF_FILE="$TELEMETRY_PATH/dca_sorted_file.conf"
+
+current_cron_file="$PERSISTENT_PATH/cron_file.txt"
+
+#Performance oriented binaries
+DCA_BINARY="/usr/bin/dca"
+
+TELEMETRY_INOTIFY_FOLDER=/rdklogs/logs/
+TELEMETRY_INOTIFY_EVENT="$TELEMETRY_INOTIFY_FOLDER/eventType.cmd"
+TELEMETRY_EXEC_COMPLETE="/tmp/.dca_done"
+SCP_COMPLETE="/tmp/.scp_done"
+
+PEER_COMM_ID="/tmp/elxrretyt.swr"
+IDLE_TIMEOUT=30
+
+DEFAULT_IPV4="<#=#>EROUTER_IPV4<#=#>"
+DEFAULT_IPV6="<#=#>EROUTER_IPV6<#=#>"
+TELEMETRY_PREVIOUS_LOG="/tmp/.telemetry_previous_log"
+TELEMETRY_PREVIOUS_LOG_COMPLETE="/tmp/.telemetry_previous_log_done"
+TEMP_NVRAM_LOG_PATH="/tmp/nvram2_logs/"
+NVRAM_LOG_PATH="/nvram/logs/"
+
+
+# Retain source for future enabling. Defaulting to disable for now
+snmpCheck=false
+
+dcaCleanup()
+{
+ if [ "x$DCA_MULTI_CORE_SUPPORTED" = "xyes" ]; then
+ $CONFIGPARAMGEN jx $PEER_COMM_DAT $PEER_COMM_ID
+ ssh -I $IDLE_TIMEOUT -i $PEER_COMM_ID root@$ARM_INTERFACE_IP "/bin/echo 'notifyTelemetryCleanup' > $TELEMETRY_INOTIFY_EVENT" > /dev/null 2>&1
+ echo_t "notify ARM for dca execution completion" >> $RTL_LOG_FILE
+ rm -f $PEER_COMM_ID
+ else
+ touch $TELEMETRY_EXEC_COMPLETE
+ fi
+
+ echo_t "forced DCA execution before log upload/reboot. Clearing all markers !!!" >> $RTL_LOG_FILE
+ # Forced execution before flusing of logs, so clear the markers
+ if [ -d $TELEMETRY_PATH_TEMP ]; then
+ rm -rf $TELEMETRY_PATH_TEMP
+ fi
+ rm -rf $TELEMETRY_PATH
+
+}
+
+# exit if an instance is already running
+if [ ! -f /tmp/.dca-utility.pid ];then
+ # store the PID
+ echo $$ > /tmp/.dca-utility.pid
+ echo "No dca-utility pid -------"
+else
+ echo "dca-utility pis existing----------"
+ pid=`cat /tmp/.dca-utility.pid`
+ if [ -d /proc/$pid ];then
+ if [ "$1" == "2" ]; then
+ loop=0
+ while [ $loop -le 6 ]
+ do
+ sleep 10
+ loop=$((loop+1))
+ if [ ! -f /tmp/.dca-utility.pid ] || [ ! -d /proc/`cat /tmp/.dca-utility.pid` ]; then
+ dcaCleanup
+ break
+ fi
+ done
+ fi
+ exit 0
+ else
+ echo $$ > /tmp/.dca-utility.pid
+ fi
+fi
+
+mkdir -p $LOG_PATH
+touch $RTL_LOG_FILE
+
+previousLogPath=""
+if [ -f $TELEMETRY_PREVIOUS_LOG ]; then
+
+ isAxb6Device="no"
+ if [ "$MODEL_NUM" == "TG3482G" ];then
+ isNvram2Mounted=`grep nvram2 /proc/mounts`
+ if [ "$isNvram2Mounted" == "" -a -d "/nvram/logs" ];then
+ isAxb6Device="yes"
+ fi
+ fi
+
+ if [ "x$DCA_MULTI_CORE_SUPPORTED" = "xyes" -a "x$isAxb6Device" == "xno" ]; then
+ previousLogPath="$TEMP_NVRAM_LOG_PATH"
+ elif [ "x$isAxb6Device" = "xyes" ]; then
+ previousLogPath="$NVRAM_LOG_PATH"
+ else
+ previousLogPath="$LOG_SYNC_PATH"
+ fi
+
+ echo_t "Telemetry run for previous log path : "$previousLogPath
+fi
+
+if [ ! -f /tmp/.dca_bootup -a ! -f $TELEMETRY_PREVIOUS_LOG ]; then
+ echo_t "First dca execution after bootup. Clearing all markers."
+ touch /tmp/.dca_bootup
+ rm -rf $TELEMETRY_PATH
+ rm -f $RTL_LOG_FILE
+fi
+
+
+PrevFileName=''
+
+#Adding support for opt override for dcm.properties file
+if [ "$BUILD_TYPE" != "prod" ] && [ -f $PERSISTENT_PATH/dcm.properties ]; then
+ . $PERSISTENT_PATH/dcm.properties
+else
+ . /etc/dcm.properties
+fi
+
+
+if [ ! -d "$TELEMETRY_PATH_TEMP" ]
+then
+ echo_t "Telemetry Folder does not exist . Creating now"
+ mkdir -p "$TELEMETRY_PATH_TEMP"
+else
+ cp $TELEMETRY_PATH/rtl_* $TELEMETRY_PATH_TEMP/
+fi
+
+mkdir -p $TELEMETRY_PATH
+
+pidCleanup()
+{
+ # PID file cleanup
+ if [ -f /tmp/.dca-utility.pid ];then
+ rm -rf /tmp/.dca-utility.pid
+ fi
+}
+
+if [ $# -ne 1 ]; then
+ echo "Usage : `basename $0` <0/1/2> 0 - Telemtry From Cron 1 - Reinitialize Map 2 - Forced Telemetry search " >> $RTL_LOG_FILE
+ pidCleanup
+ exit 0
+fi
+
+# 0 if as part of normal execution
+# 1 if initiated due to an XCONF update
+# 2 if forced execution before log upload
+# 3 if modify the cron schedule
+
+triggerType=$1
+echo_t "dca: Trigger type is :"$triggerType
+
+cd $LOG_PATH
+
+
+isNum()
+{
+ Number=$1
+ if [ $Number -ne 0 -o $Number -eq 0 2>/dev/null ];then
+ echo 0
+ else
+ echo 1
+ fi
+}
+
+# Function to get erouerMAC
+getEstbMac()
+{
+
+ estbMac=`dmcli eRT getv Device.DeviceInfo.X_COMCAST-COM_WAN_MAC | grep type: | awk '{print $5}'|tr '[:lower:]' '[:upper:]'`
+
+ if [ "$estbMac" ]; then
+ echo "$estbMac"
+ else
+ if [ "$BOX_TYPE" == "XB3" ]; then
+ estbMac=`/usr/bin/rpcclient $ARM_ARPING_IP "ifconfig erouter0" | grep 'Link encap:' | cut -d ' ' -f7`
+ echo "$estbMac"
+ else
+ estbMac=`ifconfig erouter0 | grep 'Link encap:' | cut -d ' ' -f7`
+ echo "$estbMac"
+ fi
+ fi
+
+}
+
+# Function to get erouter0 ipv4 address
+getErouterIpv4()
+{
+ erouter_ipv4=`dmcli eRT getv Device.DeviceInfo.X_COMCAST-COM_WAN_IP | grep value | awk '{print $5}'`
+ if [ "$erouter_ipv4" != "" ];then
+ echo $erouter_ipv4
+ else
+ echo "null"
+ fi
+}
+
+# Function to get erouter0 ipv6 address
+getErouterIpv6()
+{
+ erouter_ipv6=`dmcli eRT getv Device.DeviceInfo.X_COMCAST-COM_WAN_IPv6 | grep value | awk '{print $5}'`
+ if [ "$erouter_ipv6" != "" ];then
+ echo $erouter_ipv6
+ else
+ echo "null"
+ fi
+}
+
+getSNMPUpdates() {
+ snmpMIB=$1
+ TotalCount=0
+ export MIBS=ALL
+ export MIBDIRS=/mnt/nfs/bin/target-snmp/share/snmp/mibs:/usr/share/snmp/mibs
+ export PATH=$PATH:/mnt/nfs/bin/target-snmp/bin
+ export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/mnt/nfs/bin/target-snmp/lib:/mnt/nfs/usr/lib
+ snmpCommunityVal=`head -n 1 /tmp/snmpd.conf | awk '{print $4}'`
+ tuneString=`snmpwalk -OQv -v 2c -c $snmpCommunityVal 127.0.0.1 $snmpMIB`
+ for count in $tuneString
+ do
+ count=`echo $count | tr -d ' '`
+ if [ $(isNum $count) -eq 0 ]; then
+ TotalCount=`expr $TotalCount + $count`
+ else
+ TotalCount=$count
+ fi
+ done
+
+ echo $TotalCount
+}
+
+## Reatining for future support when net-snmp tools will be enabled in XB3s
+getControllerId(){
+ ChannelMapId=''
+ ControllerId=''
+ VctId=''
+ vodServerId=''
+ export MIBS=ALL
+ export MIBDIRS=/mnt/nfs/bin/target-snmp/share/snmp/mibs:/usr/share/snmp/mibs
+ export PATH=$PATH:/mnt/nfs/bin/target-snmp/bin
+ export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/mnt/nfs/bin/target-snmp/lib:/mnt/nfs/usr/lib
+
+ snmpCommunityVal=`head -n 1 /tmp/snmpd.conf | awk '{print $4}'`
+ ChannelMapId=`snmpwalk -OQ -v 2c -c $snmpCommunityVal 127.0.0.1 1.3.6.1.4.1.17270.9225.1.1.40 | awk -F '= ' '{print $2}'`
+ ControllerId=`snmpwalk -OQ -v 2c -c $snmpCommunityVal 127.0.0.1 1.3.6.1.4.1.17270.9225.1.1.41 | awk -F '= ' '{print $2}'`
+ VctId=`snmpwalk -OQ -v 2c -c $snmpCommunityVal 127.0.0.1 OC-STB-HOST-MIB::ocStbHostCardVctId.0 | awk -F '= ' '{print $2}'`
+ vodServerId=`snmpwalk -OQ -v 2c -c $snmpCommunityVal 127.0.0.1 1.3.6.1.4.1.17270.9225.1.1.43 | awk -F '= ' '{print $2}'`
+
+ echo "{\"ChannelMapId\":\"$ChannelMapId\"},{\"ControllerId\":\"$ControllerId\"},{\"VctId\":$VctId},{\"vodServerId\":\"$vodServerId\"}"
+}
+
+# Function to get RF status
+## Reatining for future support when net-snmp tools will be enabled in XB3s
+getRFStatus(){
+ Dwn_RX_pwr=''
+ Ux_TX_pwr=''
+ Dx_SNR=''
+ export MIBS=ALL
+ export MIBDIRS=/mnt/nfs/bin/target-snmp/share/snmp/mibs
+ export PATH=$PATH:/mnt/nfs/bin/target-snmp/bin
+ export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/mnt/nfs/bin/target-snmp/lib:/mnt/nfs/usr/lib
+
+ snmpCommunityVal=`head -n 1 /tmp/snmpd.conf | awk '{print $4}'`
+ Dwn_RX_pwr=`snmpwalk -OQ -v 2c -c $snmpCommunityVal 192.168.100.1 DOCS-IF-MIB::docsIfDownChannelPower.3 | awk -F '= ' '{print $2}'`
+ Ux_TX_pwr=`snmpwalk -OQ -v 2c -c $snmpCommunityVal 192.168.100.1 DOCS-IF-MIB::docsIfCmStatusTxPower.2 | awk -F '= ' '{print $2}'`
+ Dx_SNR=`snmpwalk -OQ -v 2c -c $snmpCommunityVal 192.168.100.1 DOCS-IF-MIB::docsIfSigQSignalNoise.3 | awk -F '= ' '{print $2}'`
+
+ echo "{\"Dwn_RX_pwr\":\"$Dwn_RX_pwr\"},{\"Ux_TX_pwr\":\"$Ux_TX_pwr\"},{\"Dx_SNR\":\"$Dx_SNR\"}"
+}
+
+processJsonResponse()
+{
+ FILENAME=$1
+ #Condider getting the filename as an argument instead of using global file name
+ if [ -f "$FILENAME" ]; then
+ # Start pre-processing the original file
+ sed -i 's/,"urn:/\n"urn:/g' $FILENAME # Updating the file by replacing all ',"urn:' with '\n"urn:'
+ sed -i 's/^{//g' $FILENAME # Delete first character from file '{'
+ sed -i 's/}$//g' $FILENAME # Delete first character from file '}'
+ echo "" >> $FILENAME # Adding a new line to the file
+ # Start pre-processing the original file
+
+ OUTFILE=$DCM_SETTINGS_CONF
+ OUTFILEOPT="$PERSISTENT_PATH/.DCMSettings.conf"
+ #rm -f $OUTFILE #delete old file
+ cat /dev/null > $OUTFILE #empty old file
+ cat /dev/null > $OUTFILEOPT
+ while read line
+ do
+ # Special processing for telemetry
+ profile_Check=`echo "$line" | grep -ci 'TelemetryProfile'`
+ if [ $profile_Check -ne 0 ];then
+ #echo "$line"
+ echo "$line" | sed 's/"header":"/"header" : "/g' | sed 's/"content":"/"content" : "/g' | sed 's/"type":"/"type" : "/g' >> $OUTFILE
+
+ echo "$line" | sed 's/"header":"/"header" : "/g' | sed 's/"content":"/"content" : "/g' | sed 's/"type":"/"type" : "/g' | sed -e 's/uploadRepository:URL.*","//g' >> $OUTFILEOPT
+ else
+ echo "$line" | sed 's/":/=/g' | sed 's/"//g' >> $OUTFILE
+ fi
+ done < $FILENAME
+ else
+ echo "$FILENAME not found." >> $RTL_LOG_FILE
+ return 1
+ fi
+}
+
+scheduleCron()
+{
+ echo "schedulecronjob!!"
+ cron=''
+ scheduler_Check=`grep '"schedule":' $DCM_SETTINGS_CONF`
+ if [ -n "$scheduler_Check" ]; then
+ cron=`grep -i TelemetryProfile $DCM_SETTINGS_CONF | awk -F '"schedule":' '{print $NF}' | awk -F "," '{print $1}' | sed 's/://g' | sed 's/"//g' | sed -e 's/^[ ]//' | sed -e 's/^[ ]//'`
+ fi
+
+ #During diagnostic mode need to apply the cron schedule value through this custom configuration
+ DiagnosticMode=`dmcli eRT getv Device.SelfHeal.X_RDKCENTRAL-COM_DiagnosticMode | grep value | cut -f3 -d : | cut -f2 -d" "`
+ if [ "$DiagnosticMode" == "true" ];then
+ LogUploadFrequency=`dmcli eRT getv Device.SelfHeal.X_RDKCENTRAL-COM_DiagMode_LogUploadFrequency | grep value | cut -f3 -d : | cut -f2 -d" "`
+ if [ "$LogUploadFrequency" != "" ]; then
+ cron=''
+ cron="*/$LogUploadFrequency * * * *"
+ echo "$timestamp dca: the default Cron schedule from XCONF is ignored and instead SNMP overriden value is used" >> $RTL_LOG_FILE
+ fi
+ fi
+
+ #Check whether cron having empty value if it is empty then need to assign
+ #15mins by default
+ if [ -z "$cron" ]; then
+ echo "$timestamp: dca: Empty cron value so set default as 15mins"
+ cron="*/15 * * * *"
+ fi
+
+ if [ -n "$cron" ]; then
+ # Dump existing cron jobs to a file
+ crontab -l -c $CRON_SPOOL > $current_cron_file
+ # Check whether any cron jobs are existing or not
+ existing_cron_check=`cat $current_cron_file | tail -n 1`
+ tempfile="$PERSISTENT_PATH/tempfile.txt"
+ rm -rf $tempfile # Delete temp file if existing
+ if [ -n "$existing_cron_check" ]; then
+ rtl_cron_check=`grep -c 'dca_utility.sh' $current_cron_file`
+ if [ $rtl_cron_check -eq 0 ]; then
+ echo "$cron nice -n 19 sh $RDK_PATH/dca_utility.sh 1" >> $tempfile
+ fi
+ while read line
+ do
+ retval=`echo "$line" | grep 'dca_utility.sh'`
+ if [ -n "$retval" ]; then
+ echo "$cron nice -n 19 sh $RDK_PATH/dca_utility.sh 1" >> $tempfile
+ else
+ echo "$line" >> $tempfile
+ fi
+ done < $current_cron_file
+ else
+ # If no cron job exists, create one, with the value from DCMSettings.conf file
+ echo "$cron nice -n 19 sh $RDK_PATH/dca_utility.sh 1" >> $tempfile
+ fi
+ # Set new cron job from the file
+ crontab $tempfile -c $CRON_SPOOL
+ rm -rf $current_cron_file # Delete temp file
+ rm -rf $tempfile # Delete temp file
+ else
+ echo " `date` Failed to read \"schedule\" cronjob value from DCMSettings.conf." >> $RTL_LOG_FILE
+ fi
+}
+
+dropbearRecovery()
+{
+ dropbearPid=`ps | grep -i dropbear | grep "$ATOM_INTERFACE_IP" | grep -v grep`
+ if [ -z "$dropbearPid" ]; then
+ DROPBEAR_PARAMS_1="/tmp/.dropbear/dropcfg1$$"
+ DROPBEAR_PARAMS_2="/tmp/.dropbear/dropcfg2$$"
+ if [ ! -d '/tmp/.dropbear' ]; then
+ echo "wan_ssh.sh: need to create dropbear dir !!! " >> $RTL_LOG_FILE
+ mkdir -p /tmp/.dropbear
+ fi
+ echo "wan_ssh.sh: need to create dropbear files !!! " >> $RTL_LOG_FILE
+ getConfigFile $DROPBEAR_PARAMS_1
+ getConfigFile $DROPBEAR_PARAMS_2
+ dropbear -r $DROPBEAR_PARAMS_1 -r $DROPBEAR_PARAMS_2 -E -s -p $ATOM_INTERFACE_IP:22 &
+ sleep 2
+ fi
+ rm -rf /tmp/.dropbear/*
+}
+
+clearTelemetryConfig()
+{
+ echo_t "dca: Clearing telemetry config and markers" >> $RTL_LOG_FILE
+ if [ -f $RTL_DELTA_LOG_FILE ]; then
+ echo_t "dca: Deleting : $RTL_DELTA_LOG_FILE" >> $RTL_LOG_FILE
+ rm -f $RTL_DELTA_LOG_FILE
+ fi
+
+ if [ -f $MAP_PATTERN_CONF_FILE ]; then
+ echo_t "dca: MAP_PATTERN_CONF_FILE : $MAP_PATTERN_CONF_FILE" >> $RTL_LOG_FILE
+ rm -f $MAP_PATTERN_CONF_FILE
+ fi
+
+ if [ -f $TEMP_PATTERN_CONF_FILE ]; then
+ echo_t "dca: TEMP_PATTERN_CONF_FILE : $TEMP_PATTERN_CONF_FILE" >> $RTL_LOG_FILE
+ rm -f $TEMP_PATTERN_CONF_FILE
+ fi
+
+ if [ -f $SORTED_PATTERN_CONF_FILE ]; then
+ echo_t "dca: SORTED_PATTERN_CONF_FILE : $SORTED_PATTERN_CONF_FILE" >> $RTL_LOG_FILE
+ rm -f $SORTED_PATTERN_CONF_FILE
+ fi
+
+ # Clear markers with XCONF update as logs will be flushed in case of maintenance window case as well.
+ # During boot-up no need of maintaining old markers.
+ if [ -d $TELEMETRY_PATH ]; then
+ rm -rf $TELEMETRY_PATH
+ mkdir -p $TELEMETRY_PATH
+ fi
+
+ if [ -d $TELEMETRY_PATH_TEMP ]; then
+ rm -rf $TELEMETRY_PATH_TEMP
+ mkdir -p $TELEMETRY_PATH_TEMP
+ fi
+
+}
+
+## Pass The I/P O/P Files As Arguments
+generateTelemetryConfig()
+{
+ echo_t "dca: Generating telemetry config file." >> $RTL_LOG_FILE
+ input_file=$1
+ output_file=$2
+ touch $TEMP_PATTERN_CONF_FILE
+ if [ -f $input_file ]; then
+ grep -i 'TelemetryProfile' $input_file | sed 's/=\[/\n/g' | sed 's/},/}\n/g' | sed 's/],.*?/\n/g'| sed -e 's/^[ ]//' > $TEMP_PATTERN_CONF_FILE
+ fi
+
+ # Create map file from json message file
+ while read line
+ do
+ header_Check=`echo "$line" | grep -c '{"header"'`
+ if [ $header_Check -ne 0 ];then
+ polling=`echo "$line" | grep -c 'pollingFrequency'`
+ if [ $polling -ne 0 ];then
+ header=`echo "$line" | awk -F '"header" :' '{print $NF}' | awk -F '",' '{print $1}' | sed -e 's/^[ ]//' | sed 's/^"//'`
+ content=`echo "$line" | awk -F '"content" :' '{print $NF}' | awk -F '",' '{print $1}' | sed -e 's/^[ ]//' | sed 's/^"//'`
+ logFileName=`echo "$line" | awk -F '"type" :' '{print $NF}' | awk -F '",' '{print $1}' | sed -e 's/^[ ]//' | sed 's/^"//'`
+ skipInterval=`echo "$line" | sed -e "s/.*pollingFrequency\":\"//g" | sed 's/"}//'`
+ else
+ header=`echo "$line" | awk -F '"header" :' '{print $NF}' | awk -F '",' '{print $1}' | sed -e 's/^[ ]//' | sed 's/^"//'`
+ content=`echo "$line" | awk -F '"content" :' '{print $NF}' | awk -F '",' '{print $1}' | sed -e 's/^[ ]//' | sed 's/^"//'`
+ logFileName=`echo "$line" | awk -F '"type" :' '{print $NF}' | sed -e 's/^[ ]//' | sed 's/^"//' | sed 's/"}//'`
+ #default value to 0
+ skipInterval=0
+ fi
+
+ if [ -n "$header" ] && [ -n "$content" ] && [ -n "$logFileName" ] && [ -n "$skipInterval" ]; then
+ echo "$header<#=#>$content<#=#>$logFileName<#=#>$skipInterval" >> $MAP_PATTERN_CONF_FILE
+ fi
+ fi
+ done < $TEMP_PATTERN_CONF_FILE
+ # Sort the config file based on file names to minimise the duplicate delta file generation
+ if [ -f $MAP_PATTERN_CONF_FILE ]; then
+ if [ -f $output_file ]; then
+ rm -f $output_file
+ fi
+ awk -F '<#=#>' '{print $3,$0}' $MAP_PATTERN_CONF_FILE | sort -n | cut -d ' ' -f 2- > $output_file
+ fi
+
+}
+
+ echo "triggertype------------"$triggerType
+# Reschedule the cron based on diagnositic mode
+if [ $triggerType -eq 3 ] ; then
+ echo_t "$timestamp: dca: Processing rescheduleCron job" >> $RTL_LOG_FILE
+ scheduleCron
+ ## Telemetry must be invoked only for reschedule cron job
+ pidCleanup
+ exit 0
+fi
+
+# Pull the settings from Telemetry server periodically
+estbMacAddress=`ifconfig erouter0 | grep HWaddr | cut -c39-55`
+JSONSTR=$estbMacAddress
+CURL_CMD="curl '$DCM_LOG_SERVER_URL?estbMacAddress=$JSONSTR&model=$MODEL_NAME' -o $DCMRESPONSE > /tmp/httpcode.txt"
+
+# Execute curl command
+result= eval $CURL_CMD
+sleep 5
+echo "sleep for :------------------$timeout"
+
+# Regenerate config only during boot-up and when there is an update
+if [ ! -f $SORTED_PATTERN_CONF_FILE ] || [ $triggerType -eq 1 -a ! -f $TELEMETRY_PREVIOUS_LOG ] ; then
+# Start crond daemon for yocto builds
+ pidof crond
+ if [ $? -ne 0 ]; then
+ mkdir -p $CRON_SPOOL
+ touch $CRON_SPOOL/root
+ crond -c $CRON_SPOOL -l 9
+ fi
+
+ if [ "x$DCA_MULTI_CORE_SUPPORTED" = "xyes" ]; then
+ while [ ! -f $DCMRESPONSE ]
+ do
+ echo "WARNING !!! Unable to locate $DCMRESPONSE .. Retrying " >> $RTL_LOG_FILE
+ GetConfigFile $PEER_COMM_ID
+ scp -i $PEER_COMM_ID -r $ARM_INTERFACE_IP:$DCMRESPONSE $DCMRESPONSE > /dev/null 2>&1
+ rm -f $PEER_COMM_ID
+ sleep 10
+ done
+ fi
+ echo "calling processJsonResponse--------"
+ processJsonResponse $DCMRESPONSE
+ echo "after calling processJsonResponse-----------"
+ clearTelemetryConfig
+ echo "after calling clearTelemetryConfig-----------"
+ generateTelemetryConfig $TELEMETRY_PROFILE_PATH $SORTED_PATTERN_CONF_FILE
+ echo "after calling generateTelemetryConfig--------"
+ scheduleCron
+ echo "after calling scheduleCron-------------------"
+ if [ $triggerType -eq 1 ]; then
+ bootupTelemetryBackup=true
+ ## Telemetry must be invoked only via cron and not during boot-up
+ # pidCleanup
+ #exit 0
+ fi
+fi
+
+mkdir -p $TELEMETRY_PATH_TEMP
+
+if [ "x$DCA_MULTI_CORE_SUPPORTED" = "xyes" ]; then
+ dropbearRecovery
+ mkdir -p $LOG_PATH
+ TMP_SCP_PATH="/tmp/scp_logs"
+ mkdir -p $TMP_SCP_PATH
+ GetConfigFile $PEER_COMM_ID
+ scp -i $PEER_COMM_ID -r $ARM_INTERFACE_IP:$LOG_PATH/* $TMP_SCP_PATH/ > /dev/null 2>&1
+ scp -i $PEER_COMM_ID -r $ARM_INTERFACE_IP:$LOG_SYNC_PATH/$SelfHealBootUpLogFile $ARM_INTERFACE_IP:$LOG_SYNC_PATH/$PcdLogFile $TMP_SCP_PATH/ > /dev/null 2>&1
+ rm -f $PEER_COMM_ID
+
+ RPC_RES=`rpcclient $ARM_ARPING_IP "touch $SCP_COMPLETE"`
+ RPC_OK=`echo $RPC_RES | grep "RPC CONNECTED"`
+ if [ "$RPC_OK" == "" ]; then
+ echo_t "RPC touch failed : attemp 1"
+
+ RPC_RES=`rpcclient $ARM_ARPING_IP "touch $SCP_COMPLETE"`
+ RPC_OK=`echo $RPC_RES | grep "RPC CONNECTED"`
+ if [ "$RPC_OK" == "" ]; then
+ echo_t "RPC touch failed : attemp 2"
+ fi
+ fi
+
+ ATOM_FILE_LIST=`echo ${ATOM_FILE_LIST} | sed -e "s/{//g" -e "s/}//g" -e "s/,/ /g"`
+ for file in $ATOM_FILE_LIST
+ do
+ if [ -f $TMP_SCP_PATH/$file ]; then
+ rm -f $TMP_SCP_PATH/$file
+ fi
+ done
+
+ if [ -d $TMP_SCP_PATH ]; then
+ cp -r $TMP_SCP_PATH/* $LOG_PATH/
+ rm -rf $TMP_SCP_PATH
+ fi
+
+ sleep 2
+fi
+
+#Clear the final result file
+rm -f $TELEMETRY_JSON_RESPONSE
+
+
+## Generate output file with pattern to match count values
+if [ ! -f $SORTED_PATTERN_CONF_FILE ]; then
+ echo "WARNING !!! Unable to locate telemetry config file $SORTED_PATTERN_CONF_FILE. Exiting !!!" >> $RTL_LOG_FILE
+else
+ # echo_t "Using telemetry pattern stored in : $SORTED_PATTERN_CONF_FILE.!!!" >> $RTL_LOG_FILE
+ defaultOutputJSON="{\"searchResult\":[{\"<remaining_keys>\":\"<remaining_values>\"}]}"
+ echo "nice -n 19 $DCA_BINARY $SORTED_PATTERN_CONF_FILE $previousLogPath" >> $RTL_LOG_FILE
+ dcaOutputJson=`nice -n 19 $DCA_BINARY $SORTED_PATTERN_CONF_FILE $previousLogPath 2>> $RTL_LOG_FILE`
+ if [ -z "$dcaOutputJson" ];
+ then
+ dcaOutputJson=$defaultOutputJSON
+ fi
+
+ echo "dcaoutputjson----!!!!!!!!!!!!----"$dcaOutputJson
+ singleEntry=true
+
+ # Get the snmp and performance values when enabled
+ # Need to check only when SNMP is enabled in future
+ if [ "$snmpCheck" == "true" ] ; then
+ while read line
+ do
+ pattern=`echo "$line" | awk -F '<#=#>' '{print $1}'`
+ filename=`echo "$line" | awk -F '<#=#>' '{print $2}'`
+ if [ $filename == "snmp" ] || [ $filename == "SNMP" ]; then
+ retvalue=$(getSNMPUpdates $pattern)
+ header=`grep "$pattern<#=#>$filename" $MAP_PATTERN_CONF_FILE | head -n 1 | awk -F '<#=#>' '{print $1}'`
+ if $singleEntry ; then
+ tuneData="{\"$header\":\"$retvalue\"}"
+ outputJson="$outputJson$tuneData"
+ singleEntry=false
+ else
+ tuneData=",{\"$header\":\"$retvalue\"}"
+ outputJson="$outputJson$tuneData"
+ fi
+ fi
+ done < $SORTED_PATTERN_CONF_FILE
+ fi
+
+
+ ## This interface is not accessible from ATOM, replace value from ARM
+ estbMac=$(getEstbMac)
+ firmwareVersion=$(getFWVersion)
+ firmwareVersion=$(echo $firmwareVersion | sed -e "s/imagename://g")
+ partnerId=$(getPartnerId)
+ accountId=$(getAccountId)
+ erouterIpv4=$(getErouterIpv4)
+ erouterIpv6=$(getErouterIpv6)
+
+
+ if [ "$triggerType" = "1" ]; then
+ if [ "$erouterIpv4" = "null" ]; then
+ erouterIpv4="$DEFAULT_IPV4"
+ fi
+ if [ "$erouterIpv6" = "null" ]; then
+ erouterIpv6="$DEFAULT_IPV6"
+ fi
+ fi
+
+ cur_time=`date "+%Y-%m-%d %H:%M:%S"`
+
+ if $singleEntry ; then
+ outputJson="$outputJson{\"Profile\":\"RDKB\"},{\"mac\":\"$estbMac\"},{\"erouterIpv4\":\"$erouterIpv4\"},{\"erouterIpv6\":\"$erouterIpv6\"},{\"PartnerId\":\"$partnerId\"},{\"AccountId\":\"$accountId\"},{\"Version\":\"$firmwareVersion\"},{\"Time\":\"$cur_time\"}"
+ singleEntry=false
+ else
+ outputJson="$outputJson,{\"Profile\":\"RDKB\"},{\"mac\":\"$estbMac\"},{\"erouterIpv4\":\"$erouterIpv4\"},{\"erouterIpv6\":\"$erouterIpv6\"},{\"PartnerId\":\"$partnerId\"},{\"AccountId\":\"$accountId\"},{\"Version\":\"$firmwareVersion\"},{\"Time\":\"$cur_time\"}"
+ fi
+ echo "outputjson---------------"$outputJson
+
+ remain="{\"<remaining_keys>\":\"<remaining_values>\"}"
+ outputJson=`echo "$dcaOutputJson" | sed "s/$remain/$outputJson/"`
+ echo "outputjson1---------------"$outputJson
+ echo "$outputJson" > $TELEMETRY_JSON_RESPONSE
+ sleep 2
+
+ echo "TELEMETRY_JSON_RESPONSE file is -----------"$TELEMETRY_JSON_RESPONSE
+ if [ "x$DCA_MULTI_CORE_SUPPORTED" = "xyes" ]; then
+ echo "Notify ARM to pick the updated JSON message in $TELEMETRY_JSON_RESPONSE and upload to splunk" >> $RTL_LOG_FILE
+ # Trigger inotify event on ARM to upload message to splunk
+ GetConfigFile $PEER_COMM_ID
+ if [ $triggerType -eq 2 ]; then
+ ssh -I $IDLE_TIMEOUT -i $PEER_COMM_ID root@$ARM_INTERFACE_IP "/bin/echo 'notifyFlushLogs' > $TELEMETRY_INOTIFY_EVENT" > /dev/null 2>&1
+ echo_t "notify ARM for dca execution completion" >> $RTL_LOG_FILE
+ else
+ if [ -f $TELEMETRY_PREVIOUS_LOG -a $triggerType -eq 1 ];then
+ ssh -I $IDLE_TIMEOUT -i $PEER_COMM_ID root@$ARM_INTERFACE_IP "/bin/echo 'previousLog' > $TELEMETRY_INOTIFY_EVENT" > /dev/null 2>&1
+ echo_t "notify ARM for dca running is for previous log" >> $RTL_LOG_FILE
+ else
+ if [ "$bootupTelemetryBackup" = "true" -a $triggerType -eq 1 ];then
+ ssh -I $IDLE_TIMEOUT -i $PEER_COMM_ID root@$ARM_INTERFACE_IP "/bin/echo 'bootupBackup' > $TELEMETRY_INOTIFY_EVENT" > /dev/null 2>&1
+ else
+ ssh -I $IDLE_TIMEOUT -i $PEER_COMM_ID root@$ARM_INTERFACE_IP "/bin/echo 'splunkUpload' > $TELEMETRY_INOTIFY_EVENT" > /dev/null 2>&1
+ fi
+ fi
+ fi
+ rm -f $PEER_COMM_ID
+ else
+ if [ $triggerType -eq 2 ]; then
+ touch $TELEMETRY_EXEC_COMPLETE
+ fi
+ if [ $triggerType -eq 1 -a -f $TELEMETRY_PREVIOUS_LOG ];
+ then
+ echo "calling splunkupload----------------------------"
+ sh /lib/rdk/dcaSplunkUpload.sh logbackup_without_upload &
+ else
+ sh /lib/rdk/dcaSplunkUpload.sh &
+ fi
+ proUpdel=`cat /tmp/DCMSettings.conf | grep -i uploadRepository:uploadProtocol | tr -dc '"' |wc -c`
+ echo "number of proUPdel:"$proUpdel
+ #proUpdel=$((proUpdel - 1))
+ uploadProto=`cat /tmp/DCMSettings.conf | grep -i urn:settings:TelemetryProfile | cut -d '"' -f$proUpdel`
+ echo "Upload protocol is:"$uploadProto
+ if [ "$uploadProto" != "TFTP" ]; then
+ HTTPLOGUPLOADURL=`cat /tmp/DCMSettings.conf | grep -i "urn:settings:LogUploadSettings:RepositoryURL" | cut -d "=" -f2`
+ if [ "$HTTPLOGUPLOADURL" == "" ]; then
+ echo "No HTTP URL configured in xconf,going with internal one !!"
+ HTTPLOGUPLOADURL=$DCM_LA_SERVER_URL
+ fi
+ echo "HTTPURL:"$HTTPLOGUPLOADURL
+ sh $RDK_PATH/uploadSTBLogs.sh $HTTPLOGUPLOADURL 1 1 1 0 0 &
+ else
+ delimnr=`cat /tmp/DCMSettings.conf | grep -i urn:settings:TelemetryProfile | tr -dc ':' |wc -c`
+ echo "number of deli:"$delimnr
+ delimnr=$((delimnr - 1))
+ TFTPIP=`cat /tmp/DCMSettings.conf | grep -i urn:settings:TelemetryProfile | cut -d ":" -f$delimnr | cut -d '"' -f 2`
+ echo "TFTPIP:"$TFTPIP
+ sh $RDK_PATH/uploadSTBLogs.sh $TFTPIP 1 1 1 0 0 &
+ fi
+ fi
+fi
+
+if [ -f $RTL_DELTA_LOG_FILE ]; then
+ rm -f $RTL_DELTA_LOG_FILE
+fi
+
+if [ -f $TEMP_PATTERN_CONF_FILE ]; then
+ rm -f $TEMP_PATTERN_CONF_FILE
+fi
+
+if [ $triggerType -eq 2 ]; then
+ echo_t "forced DCA execution before log upload/reboot. Clearing all markers !!!" >> $RTL_LOG_FILE
+ # Forced execution before flusing of logs, so clear the markers
+ if [ -d $TELEMETRY_PATH_TEMP ]; then
+ rm -rf $TELEMETRY_PATH_TEMP
+ fi
+ rm -rf $TELEMETRY_PATH
+
+fi
+
+if [ -f $EXEC_COUNTER_FILE ]; then
+ dcaNexecCounter=`cat $EXEC_COUNTER_FILE`
+ dcaNexecCounter=`expr $dcaNexecCounter + 1`
+else
+ dcaNexecCounter=0;
+fi
+
+if [ -f $TELEMETRY_PREVIOUS_LOG ]; then
+ echo_t "dca for previous log done" >> $RTL_LOG_FILE
+ rm -f $TELEMETRY_PREVIOUS_LOG $SORTED_PATTERN_CONF_FILE
+ rm -rf $TEMP_NVRAM_LOG_PATH
+ touch $TELEMETRY_PREVIOUS_LOG_COMPLETE
+fi
+
+echo "$dcaNexecCounter" > $EXEC_COUNTER_FILE
+# PID file cleanup
+pidCleanup
diff --git a/recipes-rdkb/sysint-broadband/files/dcm-log.service b/recipes-rdkb/sysint-broadband/files/dcm-log.service
new file mode 100755
index 0000000..1dd1d90
--- /dev/null
+++ b/recipes-rdkb/sysint-broadband/files/dcm-log.service
@@ -0,0 +1,37 @@
+##########################################################################
+# If not stated otherwise in this file or this component's Licenses.txt
+# file the following copyright and licenses apply:
+#
+# Copyright 2018 RDK Management
+#
+# 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.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+##########################################################################
+[Unit]
+Description=DCM Log Service
+
+After=local-fs.target nvram.service previous-log-backup.service network-online.target systemd-timesyncd.service dump-log.service tr69hostif.service
+Requires=network-online.target
+
+[Service]
+Type=oneshot
+EnvironmentFile=/etc/device.properties
+EnvironmentFile=/etc/dcm.properties
+EnvironmentFile=-/opt/dcm.properties
+ExecStartPre=/bin/sh -c '/bin/touch /rdklogs/logs/dcmscript.log'
+ExecStartPre=/bin/sh -c 'if [ "$DEVICE_TYPE" == "mediaclient" ]; then echo "Not triggered" > /opt/loguploadstatus.txt; fi'
+ExecStart=/bin/sh -c '/lib/rdk/StartDCM.sh >> /rdklogs/logs/telemetry.log &'
+RemainAfterExit=yes
+
+[Install]
+WantedBy=multi-user.target
+
diff --git a/recipes-rdkb/sysint-broadband/files/getaccountid.sh b/recipes-rdkb/sysint-broadband/files/getaccountid.sh
new file mode 100755
index 0000000..44ca3cd
--- /dev/null
+++ b/recipes-rdkb/sysint-broadband/files/getaccountid.sh
@@ -0,0 +1,77 @@
+#!/bin/sh
+
+####################################################################################
+# If not stated otherwise in this file or this component's Licenses.txt file the
+# following copyright and licenses apply:
+#
+# Copyright 2018 RDK Management
+#
+# 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.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+##################################################################################
+
+if [ -f /etc/os-release ] || [ -f /etc/device.properties ]; then
+ LOG_FOLDER="/rdklogs"
+else
+ LOG_FOLDER="/var/tmp"
+fi
+
+KEY_LEN="32"
+CONSOLEFILE="$LOG_FOLDER/logs/Consolelog.txt.0"
+
+echo_time()
+{
+ echo "`date +"%y%m%d-%T.%6N"` getAccountId() called from: $0 - $1"
+}
+
+
+check_accountid()
+{
+accountId="$1"
+accountIdlen="$(echo ${#accountId})"
+checkisalnum=`echo $accountId | grep -E '^[-_0-9a-zA-Z]*$'`
+
+if [ "$accountIdlen" -lt "$KEY_LEN" ] && [[ "$checkisalnum" != "" ]] && [[ "$accountId" != "*['!'@'#'"$"%^&*()+]*" ]]; then
+ echo_time "accountId is valid and value retrieved from tr181/webpa param..." >>$CONSOLEFILE
+ echo "$accountId"
+else
+ echo_time "accountId is invalid as contains specail characters or larger than max $KEY_LEN characters..." >>$CONSOLEFILE
+ echo "Unknown"
+fi
+
+}
+
+# Function to get account_id
+getAccountId()
+{
+
+#Get AccountID set in the system via syscfg get command
+accountId=`syscfg get AccountID`
+
+#Try "dmcli" to retrieve accountId if "sysconf" returned null. It's a fallback check.
+if [ "$accountId" == "" ];then
+ accountId=`dmcli eRT getv Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.AccountInfo.AccountID | grep string | awk '{print $5}'`
+
+ if [ "$accountId" == "" ]; then
+ echo_time "account_id is not available from syscfg.db or tr181 param, defaulting to Unknown...">>$CONSOLEFILE
+ echo "Unknown"
+ else
+ echo_time "Checking accountId is alphanumeric and not greater than $KEY_LEN characters...">>$CONSOLEFILE
+ check_accountid $accountId
+ fi
+
+else
+ echo_time "Checking accountId is alphanumeric and not greater than $KEY_LEN characters...">>$CONSOLEFILE
+ check_accountid $accountId
+fi
+}
+
diff --git a/recipes-rdkb/sysint-broadband/files/getpartnerid.sh b/recipes-rdkb/sysint-broadband/files/getpartnerid.sh
new file mode 100755
index 0000000..4a05777
--- /dev/null
+++ b/recipes-rdkb/sysint-broadband/files/getpartnerid.sh
@@ -0,0 +1,86 @@
+#!/bin/sh
+
+####################################################################################
+# If not stated otherwise in this file or this component's Licenses.txt file the
+# following copyright and licenses apply:
+#
+# Copyright 2018 RDK Management
+#
+# 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.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+##################################################################################
+
+if [ -f /etc/os-release ] || [ -f /etc/device.properties ]; then
+ LOG_FOLDER="/rdklogs"
+else
+ LOG_FOLDER="/var/tmp"
+fi
+
+source /lib/rdk/t2Shared_api.sh
+
+. /etc/device.properties
+
+CONSOLEFILE="$LOG_FOLDER/logs/Consolelog.txt.0"
+
+echo_time()
+{
+ echo "`date +"%y%m%d-%T.%6N"` getPartnerId() called from: $0 - $1"
+}
+
+# Function to get partner_id
+getPartnerId()
+{
+#Get PartnerID set in the system via syscfg get command
+partner_id=`syscfg get PartnerID`
+syscfg_err=`echo $partner_id | grep -i error`
+
+#Try "dmcli" to retrieve partner_id if "sysconf" returned null. It's a fallback check.
+if [ "$partner_id" == "" ] || [ "$syscfg_err" != "" ];then
+ partner_id=`dmcli eRT getv Device.DeviceInfo.X_RDKCENTRAL-COM_Syndication.PartnerId | grep string | awk '{print $5}'`
+
+ #Check for PartnerID in device.properties if its not set already.
+ if [ "$partner_id" == "" ];then
+ if [ -f "/etc/device.properties" ];then
+# PARTNER_ID is read from etc/device.properties file
+ partner_id=`echo $PARTNER_ID`
+ if [ "$partner_id" == "" ];then
+ echo_time "partner_id is not available from syscfg.db or tr181 param or device.properties, defaulting to comcast..">>$CONSOLEFILE
+ t2CountNotify "SYS_ERROR_PartnerId_missing_sycfg"
+ echo "comcast"
+ else
+ echo_time "partner_id is not available from syscfg.db or tr181 param, value retrieved from device.properties : $partner_id">>$CONSOLEFILE
+ echo "$partner_id"
+ fi
+ else
+ echo_time "partner_id is not available, defaulting to comcast.">>$CONSOLEFILE
+ echo "comcast"
+ fi
+ else
+ echo_time "partner_id is not available from syscfg.db, value retrieved from tr181 param : $partner_id">>$CONSOLEFILE
+ echo "$partner_id"
+ fi
+else
+ echo_time "partner_id retrieved from syscfg.db : $partner_id">>$CONSOLEFILE
+ echo "$partner_id"
+fi
+}
+
+getExperience()
+{
+ echo ""
+}
+
+case=$1
+if [ "$case" = "GetPartnerID" ]; then
+ getPartnerId
+fi
+
diff --git a/recipes-rdkb/sysint-broadband/files/interfaceCalls.sh b/recipes-rdkb/sysint-broadband/files/interfaceCalls.sh
new file mode 100755
index 0000000..05f2fd6
--- /dev/null
+++ b/recipes-rdkb/sysint-broadband/files/interfaceCalls.sh
@@ -0,0 +1,93 @@
+#!/bin/sh
+##########################################################################
+# If not stated otherwise in this file or this component's Licenses.txt
+# file the following copyright and licenses apply:
+#
+# Copyright 2018 RDK Management
+#
+# 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.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+##########################################################################
+. /etc/include.properties
+. /etc/device.properties
+#. /etc/env_setup.sh
+
+processCheck()
+{
+ count=`ps | grep $1 | grep -v grep | wc -l`
+ if [ $count == 0 ]; then
+ echo "1"
+ else
+ echo "0"
+ fi
+}
+
+
+getMacAddress()
+{
+ ifconfig -a | grep $ESTB_INTERFACE | tr -s ' ' | cut -d ' ' -f5
+}
+
+syncLog()
+{
+ cWD=`pwd`
+ syncPath=`find $TEMP_LOG_PATH -type l -exec ls -l {} \; | cut -d ">" -f2`
+ if [ "$syncPath" != "$LOG_PATH" ] && [ -d "$TEMP_LOG_PATH" ]; then
+ cd "$TEMP_LOG_PATH"
+ for file in `ls *.txt *.log`
+ do
+ cat $file >> $LOG_PATH/$file
+ cat /dev/null > $file
+ done
+ cd $cWD
+ else
+ echo "Sync Not needed, Same log folder"
+ fi
+}
+
+rebootFunc()
+{
+ if [ -f savepwrstate.sh ]; then
+ sh /savepwrstate.sh
+ sleep 1
+ fi
+ sync
+
+ if [ ! -f $PERSISTENT_PATH/.lightsleepKillSwitchEnable ]; then
+ syncLog
+
+ if [ -f $TEMP_LOG_PATH/error.log ]; then
+ cat $TEMP_LOG_PATH/error.log >> $PERSISTENT_PATH/www/error.log
+ cat /dev/null > $TEMP_LOG_PATH/error.log
+ fi
+
+ if [ -f $TEMP_LOG_PATH/.systime ]; then
+ cp $TEMP_LOG_PATH/.systime $PERSISTENT_PATH/
+ fi
+
+ if [ -f $TEMP_LOG_PATH/access.log ]; then
+ cat $TEMP_LOG_PATH/access.log >> $PERSISTENT_PATH/www/access.log
+ cat /dev/null > $TEMP_LOG_PATH/access.log
+ fi
+ fi
+
+ reboot
+}
+
+
+# Return system uptime in seconds
+Uptime()
+{
+ cat /proc/uptime | awk '{ split($1,a,"."); print a[1]; }'
+}
+
+
diff --git a/recipes-rdkb/sysint-broadband/files/logfiles.sh b/recipes-rdkb/sysint-broadband/files/logfiles.sh
new file mode 100755
index 0000000..3d11724
--- /dev/null
+++ b/recipes-rdkb/sysint-broadband/files/logfiles.sh
@@ -0,0 +1,829 @@
+#!/bin/sh
+##########################################################################
+# If not stated otherwise in this file or this component's Licenses.txt
+# file the following copyright and licenses apply:
+#
+# Copyright 2018 RDK Management
+#
+# 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.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+##########################################################################
+#
+
+. /etc/include.properties
+. /etc/device.properties
+
+#RDK-B LOGS
+BootTimeLog="BootTime.log"
+BootTimeLogBackup="BootTime.log.*"
+speedtestLog="speedtest.log"
+speedtestLogBackup="speedtest.log.*"
+ArmConsolelog="ArmConsolelog.txt.0"
+ArmConsolelogBackup="ArmConsolelog.txt.*"
+Consolelog="Consolelog.txt.0"
+ConsolelogBackup="Consolelog.txt.*"
+LMlog="LM.txt.0"
+LMlogBackup="LM.txt.*"
+PAMlog="PAMlog.txt.0"
+PAMlogBackup="PAMlog.txt.*"
+PARODUSlog="PARODUSlog.txt.0"
+PARODUSlogBackup="PARODUSlog.txt.*"
+PSMlog="PSMlog.txt.0"
+PSMlogBackup="PSMlog.txt.*"
+TDMlog="TDMlog.txt.0"
+TDMlogBackup="TDMlog.txt.*"
+TR69log="TR69log.txt.0"
+TR69logBackup="TR69log.txt.*"
+WEBPAlog="WEBPAlog.txt.0"
+WEBPAlogBackup="WEBPAlog.txt.*"
+WiFilog="WiFilog.txt.0"
+WiFilogBackup="WiFilog.txt.*"
+FirewallDebug="FirewallDebug.txt"
+FirewallDebugBackup="FirewallDebug.txt.*"
+MnetDebug="MnetDebug.txt"
+MnetDebugBackup="MnetDebug.txt.*"
+wifihealthlog="wifihealth.txt"
+wifihealthBackup="wifihealth.txt.*"
+CRLog="CRlog.txt.0"
+CRLogBackup="CRlog.txt.*"
+
+xreLog="receiver.log"
+cecLog="cec_log.txt"
+cecLogsBackup="cec_log.txt.*"
+xreLogsBackup="receiver.log.*"
+receiverMON="ReceiverMON.txt"
+runXreLog="runXRE_log.txt"
+runXreLogsBackup="runXRE_log.txt.*"
+greenpeakLog="greenpeak.log"
+greenpeakLogsBackup="greenpeak.log.*"
+appStatusLog="app_status.log"
+appStatusLogsBackup="app_status.log.*"
+gpInitLog="gp_init.log"
+gpInitLogsBackup="gp_init.log.*"
+#demsg Logs
+dmesgLog="messages_printk.txt"
+dmesgLogsBackup="messages_printk_bak*"
+sysLog="messages.txt"
+ntpLog="ntp.log"
+sysLogsBackup="messages.txt.*"
+ntpLogsBackup="ntp.log.*"
+sysDmesgLog="messages-dmesg.txt"
+sysDmesgLogsBackup="messages-dmesg.txt.*"
+startupDmesgLog="startup_stdout_log.txt"
+startupDmesgLogsBackup="startup_stdout_log.*"
+lighttpdErrorLog="lighttpd.error.log"
+lighttpdErrorLogsBackup="lighttpd.error.log.*"
+lighttpdAccessLog="lighttpd.access.log"
+lighttpdAccessLogsBackup="lighttpd.access.log.*"
+dcmLog="dcmscript.log"
+dcmLogsBackup="dcmscript.log.*"
+uiLog="uimgr_log.txt"
+uiLogsBackup="uimgr_log.txt.*"
+storagemgrLog="storagemgr.log"
+storagemgrLogsBackup="storagemgr.log.*"
+rf4ceLog="rf4ce_log.txt"
+rf4ceLogsBackup="rf4ce_log.txt.*"
+ctrlmLog="ctrlm_log.txt"
+ctrlmLogsBackup="ctrlm_log.txt.*"
+xDiscoveryLog="xdiscovery.log"
+xDiscoveryLogsBackup="xdiscovery.log.*"
+xDiscoveryListLog="xdiscoverylist.log"
+xDiscoveryListLogsBackup="xdiscoverylist.log.*"
+hdmiLog="hdmi_log.txt"
+rebootLog="reboot.log"
+rebootInfoLog="rebootInfo.log"
+ueiLog="uei_init.log"
+wbLog="wbdevice.log"
+swUpdateLog="swupdate.log"
+topLog="top_log.txt"
+topLogsBackup="top_log.txt.*"
+mocaLog="mocalog.txt"
+coreLog="coredump.log"
+coreDumpLog="core_log.txt"
+coreDumpLogsBackup="core_log.txt.*"
+version="version.txt"
+fusionDaleLog="fusiondale_log.txt"
+socProvisionLog="socprov.log"
+socProvisionLogsBackup="socprov.log.*"
+socProvisionCryptoLog="socprov-crypto.log"
+socProvisionCryptoLogsBackup="socprov-crypto.log.*"
+applicationsLog="applications.log"
+applicationsLogsBackup="applications.log.*"
+systemLog="system.log"
+systemLogsBackup="system.log.*"
+bootUpLog="bootlog"
+resetLog="Reset.txt"
+resetLogsBackup="Reset.txt"
+backUpDumpLog="backupCoreDumpLog.txt"
+gpLog="gp.log"
+gpLogsBackup="gp.log.*"
+diskInfoLog="diskInfo.txt"
+diskEventsLog="diskEvents.txt"
+
+rmfLog="rmfstr_log.txt"
+rmfLogsBackup="rmfstr_log.txt.*"
+podLog="pod_log.txt"
+podLogsBackup="pod_log.txt.*"
+vodLog="vodclient_log.txt"
+vodLogsBackup="vodclient_log.txt.*"
+rstreamFdLog="rstreamer_fdlist.txt"
+
+recorderLog="/opt/rec_debug.log"
+fdsLog="fds.log"
+fdsLogsBackup="fds.log.*"
+trmLog="trm.log"
+trmMgrLog="trmmgr.log"
+trmLogsBackup="trm.log.*"
+trmMgrLogsBackup="trmmgr.log.*"
+threadLog="vlthreadanalyzer_log.txt"
+threadLogsBackup="vlthreadanalyzer_log.txt.*"
+xDeviceLog="xdevice.log"
+xDeviceLogsBackup="xdevice.log.*"
+authServiceLog="authservice.log"
+cardProvisionCheckLog="card-provision-check.log"
+ipdnlLog="ipdllogfile.txt"
+diskCleanupInfoLog="disk_cleanup_info.log"
+topOsalLog="top_osal.txt"
+topOsalLogsBackup="top_osal.txt.*"
+mocaStatusLog="mocaStatus.log"
+mocaStatusLogsBackup="mocaStatus.log.*"
+mfrLog="mfrlib_log.txt"
+mfrLogsBackup="mfrlib_log.txt.*"
+mfrLogRdk="mfr_log.txt"
+mfrLogsRdkBackup="mfr_log.txt.*"
+adobeCleanupLog="cleanAdobe.log"
+
+cefLog="cef.log"
+cefLogsBackup="cef.log.*"
+diskCleanupLog="disk_cleanup.log"
+diskCleanupLog1="disk_cleanup.log"
+diskCleanupLogsBackup="disk_cleanup.log.*"
+decoderStatusLog="procStatus.log"
+decoderStatusLogsBackup="procStatus.log.*"
+recorderLog="/opt/rec_debug.log"
+psLogsBackup=ps_out.txt*
+netsrvLog="netsrvmgr.log"
+netsrvLogsBackup="netsrvmgr.log.*"
+samhainLog="samhain.log"
+samhainLogsBackup="samhain.log.*"
+fogLog="fog.log"
+fogLogsBackup="fog.log.*"
+hddStatusLog="diskinfo.log"
+hddStatusLogsBackup="diskinfo.log.*"
+xiRecoveryLog="discoverV4Client.log"
+xiRecoveryLogsBackup="discoverV4Client.log.*"
+dropbearLog="dropbear.log"
+dropbearLogsBackup="dropbear.log.*"
+bluetoothLog="btmgrlog.txt"
+bluetoothLogBackup="btmgrlog.txt.*"
+mountLog="mount_log.txt"
+mountLogBackup="mount_log.txt.*"
+rbiDaemonLog="rbiDaemon.log"
+rbiDaemonLogsBackup="rbiDaemon.log.*"
+rfcLog="rfcscript.log"
+rfcLogsBackup="rfcscript.log.*"
+tlsLog="tlsError.log"
+tlsLogsBackup="tlsError.log.*"
+playreadycdmiLog="playreadycdmi.log"
+playreadycdmiLogsBackup="playreadycdmi.log.*"
+wpecdmiLog="wpecdmi.log"
+wpecdmiLogsBackup="wpecdmi.log.*"
+pingTelemetryLog="ping_telemetry.log"
+pingTelemetryLogsBackup="ping_telemetry.log.*"
+deviceDetailsLog="device_details.log"
+zramLog="zram.log"
+zramLogsBackup="zram.log.*"
+appmanagerLog="appmanager.log"
+appmanagerLogsBackup="appmanager.log.*"
+hwselfLog="hwselftest.log"
+hwselfLogsBackup="hwselftest.log.*"
+easPcapFile="eas.pcap"
+mocaPcapFile="moca.pcap"
+nlmonLog="nlmon.log"
+nlmonLogsBackup="nlmon.log.*"
+audiocapturemgrLogs="audiocapturemgr.log"
+
+if [ "$CONTAINER_SUPPORT" == "true" ];then
+ xreLxcLog="xre.log"
+ xreLxcLogsBackup="xre.log.*"
+ xreLxcApplicationsLog="xre-applications.log"
+ xreLxcApplicationsLogsBackup="xre-applications.log.*"
+fi
+
+if [ "$SOC" = "BRCM" ];then
+ nxSvrLog="nxserver.log"
+ nxSvrLogsBackup="nxserver.log.*"
+ procStatusLog="proc-status-logger.log"
+ procStatusLogsBackup="proc-status-logger.log.*"
+fi
+
+
+if [ "$DEVICE_TYPE" != "mediaclient" ]; then
+ riLog="ocapri_log.txt"
+ riLogsBackup="ocapri_log.txt.*"
+ riLogsBackup1="ocapri_log.txt_1"
+ mpeosmainMON="mpeos-mainMON.txt"
+ mpeosRebootLog="/opt/mpeos_reboot_log.txt"
+ cardStatusLog="card_status.log"
+ heapDmpLog="jvmheapdump.txt"
+ rfStatisticsLog="rf_statistics_log.txt"
+ ablReasonLog="ABLReason.txt"
+ ecmLog="messages-ecm.txt"
+ ecmLogsBackup="messages-ecm.txt.*"
+ pumaLog="messages-puma.txt"
+ pumaLogsBackup="messages-puma.txt.*"
+ pumaLog1="messages-ecm.txt"
+ pumaLogsBackup1="messages-ecm.txt.*"
+ xfsdmesgLog="xfs_mount_dmesg.txt"
+ snmpdLog="snmpd.log"
+ snmpdLogsBackup="snmpd.log.*"
+ upstreamStatsLog="upstream_stats.log"
+ upstreamStatsLogsBackup="upstream_stats.log.*"
+ dibblerLog="dibbler.log"
+ dibblerLogsBackup="dibbler.log.*"
+ dnsmasqLog="dnsmasq.log"
+ dnsmasqLogsBackup="dnsmasq.log.*"
+else
+ ablReasonLog="ABLReason.txt"
+ wifiTelemetryLog="wifi_telemetry.log"
+ wifiTelemetryLogBackup="wifi_telemetry.log.*"
+ tr69Log="tr69Client.log"
+ tr69AgentLog="tr69agent.log"
+ tr69HostIfLog="tr69hostif.log"
+ gatewayLog="gwSetupLogs.txt"
+ ipSetupLog="ipSetupLogs.txt"
+ tr69DownloadLog="tr69FWDnld.log"
+ tr69AgentHttpLog="tr69agent_HTTP.log"
+ tr69AgentHttpLogsBackup="tr69agent_HTTP.log.*"
+ tr69AgentSoapLog="tr69agent_SoapDebug.log"
+ tr69AgentSoapLogsBackup="tr69agent_SoapDebug.log.*"
+ webpavideoLog="webpavideo.log"
+ webpavideoLogsBackup="webpavideo.log.*"
+ xiConnectionStatusLog="xiConnectionStats.txt"
+ xiConnectionStatusLogsBackup="xiConnectionStats.txt.*"
+fi
+if [ "$WIFI_SUPPORT" == "true" ];then
+ wpaSupplicantLog="wpa_supplicant.log"
+ wpaSupplicantLogsBackup="wpa_supplicant.log.*"
+ dhcpWifiLog="dhcp-wifi.log"
+ dhcpWifiLogsBackup="dhcp-wifi.log.*"
+fi
+if [ "$DEVICE_TYPE" == "XHC1" ];then
+
+ streamsrvLog="stream_server_log.txt"
+ streamsrvLogsBackup="stream_server_log.txt.*"
+
+ stunnelHttpsLog="stunnel_https_log.txt"
+ stunnelHttpsLogsBackup="stunnel_https_log.txt.*"
+
+ upnpLog="upnp_log.txt"
+ upnpLogsBackup="upnp_log.txt.*"
+
+ upnpigdLog="upnpigd_log.txt"
+ upnpigdLogsBackup="upnpigd_log.txt.*"
+
+ cgiLog="cgi_log.txt"
+ cgiLogsBackup="cgi_log.txt.*"
+
+ systemLog="system_log.txt"
+ systemLogsBackup="system_log.txt.*"
+
+ eventLog="event_log.txt"
+ eventLogsBackup="event_log.txt.*"
+
+ xw3MonitorLog="oem_log.txt"
+ xw3MonitorLogsBackup="oem_log.txt.*"
+
+ sensorDLog="sensor_daemon_log.txt"
+ sensorDLogsBackup="sensor_daemon_log.txt.*"
+
+ webpaLog="webpa_log.txt"
+ webpaLogsBackup="webpa_log.txt.*"
+
+ xwclientLog="xwclient_log.txt"
+ xwclientLogsBackup="xwclient_log.txt.*"
+
+ xwswupdateLog="xwswupdate.log"
+ xwswupdateLogsBackup="xwswupdate.log.*"
+
+ userLog="user_log.txt"
+ userLogsBackup="user_log.txt.*"
+
+ webrtcStreamingLog="webrtc_streaming_log.txt"
+ webrtcStreamingLogsBackup="webrtc_streaming_log.txt.*"
+
+ cvrPollLog="cvrpoll_log.txt"
+ cvrPollLogsBackup="cvrpoll_log.txt.*"
+
+ thumbnailUploadLog="thumbnail_log.txt"
+ thumbnailUploadBackupLog="thumbnail_log.txt.*"
+
+ metricsLog="dmesg_log.txt"
+ metricsLogsBackup="dmesg_log.txt.*"
+
+ wifiLog="wifi_log.txt"
+ wifiLogsBackup="wifi_log.txt.*"
+
+ rfcLog="rfcscript.log"
+ rfcLogsBackup="rfcscript.log.*"
+
+ overlayLog="overlay_log.txt"
+ overlayLogsBackup="overlay_log.txt.*"
+
+ xvisionLog="xvision_log.txt"
+ xvisionLogsBackup="xvision_log.txt.*"
+
+ ivaDaemonLog="iva_daemon_log.txt"
+ ivaDaemonLogsBackup="iva_daemon_log.txt.*"
+
+ evoLog="evo_log.txt"
+ evoBackupLog="evo_log.txt.*"
+
+ camstreamsrvLog="camstreamserver.log"
+ camstreamsrvLogsBackup="camstreamserver.log.*"
+
+ mongsLog="mongoose-cam-stream-server.txt"
+ mongsLogsBackup="mongoose-cam-stream-server.txt.*"
+fi
+
+if [ "$HDD_ENABLED" = "false" ]; then
+ sysLogBAK1="bak1_messages.txt"
+ sysLogBAK2="bak2_messages.txt"
+ sysLogBAK3="bak3_messages.txt"
+ logBAK1="bak1_*"
+ logBAK2="bak2_*"
+ logBAK3="bak3_*"
+fi
+
+moveFile()
+{
+ if [[ -f $1 ]]; then mv $1 $2; fi
+}
+
+moveFiles()
+{
+ currentDir=`pwd`
+ cd $2
+
+ for f in `ls $3 2>/dev/null`
+ do
+ $1 $f $4
+ done
+
+ cd $currentDir
+}
+
+backup()
+{
+ source=$1
+ destn=$2
+ operation=$3
+ if [ "$DEVICE_TYPE" != "mediaclient" ]; then
+ if [ -f $source$riLog ] ; then $operation $source$riLog $destn; fi
+ if [ -f $mpeosRebootLog ] ; then
+ if [ "$BUILD_TYPE" = "dev" ]; then
+ cp $mpeosRebootLog $destn
+ mv $recorderLog $destn
+ else
+ mv $recorderLog $destn
+ $operation $mpeosRebootLog $destn
+ fi
+ fi
+ fi
+ if [ -f $source$xreLog ] ; then $operation $source$xreLog $destn; fi
+ if [ -f $source$cecLog ] ; then $operation $source$cecLog $destn; fi
+ if [ -f $source$wbLog ] ; then $operation $source$wbLog $destn; fi
+ if [ -f $source$sysLog ] ; then $operation $source$sysLog $destn; fi
+ if [ -f $source$ntpLog ] ; then $operation $source$ntpLog $destn; fi
+ if [ -f $source/$uiLog ] ; then $operation $source/$uiLog $destn; fi
+ if [ -f $source/$storagemgrLog ] ; then $operation $source/$storagemgrLog $destn; fi
+ if [ -f $source/$rf4ceLog ] ; then $operation $source/$rf4ceLog $destn; fi
+ if [ -f $source/$ctrlmLog ] ; then $operation $source/$ctrlmLog $destn; fi
+ if [ -f $source/$applicationsLog ] ; then $operation $source/$applicationsLog $destn; fi
+ if [ -f $source/$systemLog ] ; then $operation $source/$systemLog $destn; fi
+ if [ -f $source/$bootUpLog ] ; then $operation $source/$bootUpLog $destn; fi
+ if [ -f $source/$startupDmesgLog ] ; then $operation $source/$startupDmesgLog $destn; fi
+ if [ -f $source/$diskCleanupLog ] ; then $operation $source/$diskCleanupLog $destn; fi
+ if [ -f $source/$diskCleanupInfoLog ] ; then $operation $source/$diskCleanupInfoLog $destn; fi
+ if [ -f $source/$diskCleanupLog1 ] ; then $operation $source/$diskCleanupLog1 $destn; fi
+ if [ -f $source$sysDmesgLog ] ; then $operation $source$sysDmesgLog $destn; fi
+ if [ -f $source$coreDumpLog ] ; then $operation $source$coreDumpLog $destn; fi
+ if [ -f $source$adobeCleanupLog ] ; then $operation $source$adobeCleanupLog $destn; fi
+ if [ -f $source$bluetoothLog ] ; then $operation $source$bluetoothLog $destn; fi
+ if [ -f $source$easPcapFile ] ; then $operation $source$easPcapFile $destn; fi
+ if [ -f $source$mocaPcapFile ] ; then $operation $source$mocaPcapFile $destn; fi
+ if [ -f $source$mountLog ] ; then $operation $source$mountLog $destn; fi
+ if [ "$CONTAINER_SUPPORT" == "true" ];then
+ if [ -f $source$xreLxcLog ] ; then $operation $source$xreLxcLog $destn; fi
+ if [ -f $source/$xreLxcApplicationsLog ] ; then $operation $source/$xreLxcApplicationsLog $destn; fi
+ fi
+
+ if [ "$SOC" = "BRCM" ];then
+ if [ -f $source$nxSvrLog ] ; then $operation $source$nxSvrLog $destn; fi
+ if [ -f $source$procStatusLog ] ; then $operation $source$procStatusLog $destn; fi
+ fi
+}
+
+crashLogsBackup()
+{
+ opern=$1
+ src=$2
+ destn=$3
+
+ moveFiles $opern $src receiver.log_* $destn
+ moveFiles $opern $src ocapri_log.txt_* $destn
+ moveFiles $opern $src messages.txt_* $destn
+ moveFiles $opern $src app_status_backup.log_* $destn
+}
+
+backupAppBackupLogFiles()
+{
+ opern=$1
+ source=$2
+ destn=$3
+
+ if [ "$DEVICE_TYPE" != "mediaclient" ]; then
+ moveFiles $opern $source $BootTimeLogBackup $destn
+ moveFiles $opern $source $speedtestLogBackup $destn
+ moveFiles $opern $source $ArmConsolelogBackup $destn
+ moveFiles $opern $source $ConsolelogBackup $destn
+ moveFiles $opern $source $PAMlogBackup $destn
+ moveFiles $opern $source $PARODUSlogBackup $destn
+ moveFiles $opern $source $PSMlogBackup $destn
+ moveFiles $opern $source $TDMlogBackup $destn
+ moveFiles $opern $source $TR69logBackup $destn
+ moveFiles $opern $source $WEBPAlogBackup $destn
+ moveFiles $opern $source $WiFilogBackup $destn
+ moveFiles $opern $source $FirewallDebugBackup $destn
+ moveFiles $opern $source $MnetDebugBackup $destn
+ moveFiles $opern $source $wifihealthBackup $destn
+ moveFiles $opern $source $CRLogBackup $destn
+ moveFiles $opern $source $LMlogBackup $destn
+
+ moveFiles $opern $source $riLogsBackup $destn
+ moveFiles $opern $source $riLogsBackup1 $destn
+ moveFiles $opern $source $ecmLogsBackup $destn
+ moveFiles $opern $source $pumaLogsBackup $destn
+ moveFiles $opern $source $pumaLogsBackup1 $destn
+ moveFiles $opern $source $snmpdLogsBackup $destn
+ moveFiles $opern $source $upstreamStatsLogsBackup $destn
+ moveFiles $opern $source $dibblerLogsBackup $destn
+ moveFiles $opern $source $dnsmasqLogsBackup $destn
+ else
+ moveFiles $opern $source $wifiTelemetryLogBackup $destn
+ moveFiles $opern $source $tr69AgentHttpLogsBackup $destn
+ moveFiles $opern $source $tr69AgentSoapLogsBackup $destn
+ moveFiles $opern $source $webpavideoLogsBackup $destn
+ moveFiles $opern $source $xiConnectionStatusLogsBackup $destn
+ fi
+ if [ "$WIFI_SUPPORT" == "true" ];then
+ moveFiles $opern $source $wpaSupplicantLogsBackup $destn
+ moveFiles $opern $source $dhcpWifiLogsBackup $destn
+ fi
+ if [ "$DEVICE_TYPE" == "XHC1" ];then
+ moveFiles $opern $source $streamsrvLogsBackup $destn
+ moveFiles $opern $source $stunnelHttpsLogsBackup $destn
+ moveFiles $opern $source $upnpLogsBackup $destn
+ moveFiles $opern $source $upnpigdLogsBackup $destn
+ moveFiles $opern $source $cgiLogsBackup $destn
+ moveFiles $opern $source $systemLogsBackup $destn
+ moveFiles $opern $source $eventLogsBackup $destn
+ moveFiles $opern $source $xw3MonitorLogsBackup $destn
+ moveFiles $opern $source $sensorDLogsBackup $destn
+ moveFiles $opern $source $webpaLogsBackup $destn
+ moveFiles $opern $source $xwclientLogsBackup $destn
+ moveFiles $opern $source $xwswupdateLogsBackup $destn
+ moveFiles $opern $source $userLogsBackup $destn
+ moveFiles $opern $source $webrtcStreamingLogsBackup $destn
+ moveFiles $opern $source $cvrPollLogsBackup $destn
+ moveFiles $opern $source $ivaDaemonLogsBackup $destn
+ moveFiles $opern $source $thumbnailUploadBackupLog $destn
+ moveFiles $opern $source $metricsLogsBackup $destn
+ moveFiles $opern $source $wifiLogsBackup $destn
+ moveFiles $opern $source $dcmLogsBackup $destn
+ moveFiles $opern $source $netsrvLogsBackup $destn
+ moveFiles $opern $source $diskCleanupLogsBackup $destn
+ moveFiles $opern $source $applicationsLogsBackup $destn
+ moveFiles $opern $source $rfcLogsBackup $destn
+ moveFiles $opern $source $overlayLogsBackup $destn
+ moveFiles $opern $source $sysLogsBackup $destn
+ moveFiles $opern $source $startupDmesgLogsBackup $destn
+ moveFiles $opern $source $sysDmesgLogsBackup $destn
+ moveFiles $opern $source $xvisionLogsBackup $destn
+ moveFiles $opern $source $evoBackupLog $destn
+ moveFiles $opern $source $camstreamsrvLogsBackup $destn
+ moveFiles $opern $source $mongsLogsBackup $destn
+ else
+ moveFiles $opern $source $mocaStatusLogsBackup $destn
+ moveFiles $opern $source $runXreLogsBackup $destn
+ moveFiles $opern $source $xreLogsBackup $destn
+ moveFiles $opern $source $cecLogsBackup $destn
+ moveFiles $opern $source $sysLogsBackup $destn
+ moveFiles $opern $source $ntpLogsBackup $destn
+ moveFiles $opern $source $startupDmesgLogsBackup $destn
+ moveFiles $opern $source $gpInitLogsBackup $destn
+ moveFiles $opern $source $appStatusLogsBackup $destn
+ moveFiles $opern $source $dmesgLogsBackup $destn
+ moveFiles $opern $source $xDiscoveryLogsBackup $destn
+ moveFiles $opern $source $xDiscoveryListLogsBackup $destn
+ moveFiles $opern $source $uiLogsBackup $destn
+ moveFiles $opern $source $storagemgrLogsBackup $destn
+ moveFiles $opern $source $rf4ceLogsBackup $destn
+ moveFiles $opern $source $ctrlmLogsBackup $destn
+ moveFiles $opern $source $lighttpdErrorLogsBackup $destn
+ moveFiles $opern $source $lighttpdAccessLogsBackup $destn
+ moveFiles $opern $source $dcmLogsBackup $destn
+ moveFiles $opern $source $greenpeakLogsBackup $destn
+ moveFiles $opern $source $trmLogsBackup $destn
+ moveFiles $opern $source $trmMgrLogsBackup $destn
+ moveFiles $opern $source $rmfLogsBackup $destn
+ moveFiles $opern $source $podLogsBackup $destn
+ moveFiles $opern $source $vodLogsBackup $destn
+ moveFiles $opern $source $fdsLogsBackup $destn
+ moveFiles $opern $source $threadLogsBackup $destn
+ moveFiles $opern $source $xDeviceLogsBackup $destn
+ moveFiles $opern $source $coreDumpLogsBackup $destn
+ moveFiles $opern $source $applicationsLogsBackup $destn
+ moveFiles $opern $source $socProvisionLogsBackup $destn
+ moveFiles $opern $source $socProvisionCryptoLogsBackup $destn
+ moveFiles $opern $source $topOsalLogsBackup $destn
+ moveFiles $opern $source $decoderStatusLogsBackup $destn
+ moveFiles $opern $source $mfrLogsBackup $destn
+ moveFiles $opern $source $mfrLogsRdkBackup $destn
+ moveFiles $opern $source $sysDmesgLogsBackup $destn
+ moveFiles $opern $source $resetLogsBackup $destn
+ moveFiles $opern $source $gpLogsBackup $destn
+ moveFiles $opern $source $psLogsBackup $destn
+ moveFiles $opern $source $cefLogsBackup $destn
+ moveFiles $opern $source $topLogsBackup $destn
+ moveFiles $opern $source $netsrvLogsBackup $destn
+ moveFiles $opern $source $diskCleanupLogsBackup $destn
+ moveFiles $opern $source $samhainLogsBackup $destn
+ moveFiles $opern $source $fogLogsBackup $destn
+ moveFiles $opern $source $hddStatusLogsBackup $destn
+ moveFiles $opern $source $xiRecoveryLogsBackup $destn
+ moveFiles $opern $source $dropbearLogsBackup $destn
+ moveFiles $opern $source $bluetoothLogBackup $destn
+ moveFiles $opern $source $easPcapFile $destn
+ moveFiles $opern $source $mocaPcapFile $destn
+ moveFiles $opern $source $mountLogBackup $destn
+ moveFiles $opern $source $rbiDaemonLogsBackup $destn
+ moveFiles $opern $source $rfcLogsBackup $destn
+ moveFiles $opern $source $tlsLogsBackup $destn
+ moveFiles $opern $source $playreadycdmiLogsBackup $destn
+ moveFiles $opern $source $wpecdmiLogsBackup $destn
+ moveFiles $opern $source $pingTelemetryLogsBackup $destn
+ moveFiles $opern $source $zramLogsBackup $destn
+ moveFiles $opern $source $appmanagerLogsBackup $destn
+ moveFiles $opern $source $nlmonLogsBackup $destn
+ moveFiles $opern $source $hwselfLogsBackup $destn
+ fi
+
+ if [ "$CONTAINER_SUPPORT" == "true" ];then
+ moveFiles $opern $source $xreLxcLogsBackup $destn
+ moveFiles $opern $source $xreLxcApplicationsLogsBackup $destn
+ fi
+
+ moveFiles $opern $source $systemLogsBackup $destn
+ if [ "$SOC" = "BRCM" ];then
+ moveFiles $opern $source $nxSvrLogsBackup $destn
+ moveFiles $opern $source $procStatusLogsBackup $destn
+ fi
+ # backup older cycle logs
+ if [ "$MEMORY_LIMITATION_FLAG" = "true" ]; then
+ moveFiles $opern $source $logBAK1 $destn
+ moveFiles $opern $source $logBAK2 $destn
+ moveFiles $opern $source $logBAK3 $destn
+ fi
+
+}
+
+backupSystemLogFiles()
+{
+ operation=$1
+ source=$2
+ destn=$3
+
+ if [ -f $source/$BootTimeLog ] ; then $operation $source/$BootTimeLog $destn; fi
+ if [ -f $source/$speedtestLog ] ; then $operation $source/$speedtestLog $destn; fi
+ if [ -f $source/$ArmConsolelog ] ; then $operation $source/$ArmConsolelog $destn; fi
+ if [ -f $source/$Consolelog ] ; then $operation $source/$Consolelog $destn; fi
+ if [ -f $source/$LMlog ] ; then $operation $source/$LMlog $destn; fi
+ if [ -f $source/$PAMlog ] ; then $operation $source/$PAMlog $destn; fi
+ if [ -f $source/$PARODUSlog ] ; then $operation $source/$PARODUSlog $destn; fi
+ if [ -f $source/$PSMlog ] ; then $operation $source/$PSMlog $destn; fi
+ if [ -f $source/$TDMlog ] ; then $operation $source/$TDMlog $destn; fi
+ if [ -f $source/$TR69log ] ; then $operation $source/$TR69log $destn; fi
+ if [ -f $source/$WEBPAlog ] ; then $operation $source/$WEBPAlog $destn; fi
+ if [ -f $source/$WiFilog ] ; then $operation $source/$WiFilog $destn; fi
+ if [ -f $source/$FirewallDebug ] ; then $operation $source/$FirewallDebug $destn; fi
+ if [ -f $source/$MnetDebug ] ; then $operation $source/$MnetDebug $destn; fi
+ if [ -f $source/$wifihealthlog ] ; then $operation $source/$wifihealthlog $destn; fi
+ if [ -f $source/$CRLog ] ; then $operation $source/$CRLog $destn; fi
+
+
+ # generic Logs
+ if [ -f $source/$systemLog ] ; then $operation $source/$systemLog $destn; fi
+ if [ -f $source/$resetLog ] ; then $operation $source/$resetLog $destn; fi
+ if [ -f $source/$backUpDumpLog ] ; then $operation $source/$backUpDumpLog $destn; fi
+ if [ -f $source/$bootUpLog ] ; then $operation $source/$bootUpLog $destn; fi
+ if [ -f $source/$applicationsLog ] ; then $operation $source/$applicationsLog $destn; fi
+ if [ -f $source/$runXreLog ] ; then $operation $source/$runXreLog $destn; fi
+ if [ -f $source/$xreLog ] ; then $operation $source/$xreLog $destn; fi
+ if [ -f $source/$cecLog ] ; then $operation $source/$cecLog $destn; fi
+ if [ -f $source/$gpInitLog ] ; then $operation $source/$gpInitLog $destn; fi
+ if [ -f $source/$hdmiLog ] ; then $operation $source/$hdmiLog $destn; fi
+ if [ -f $source/$uiLog ] ; then $operation $source/$uiLog $destn; fi
+ if [ -f $source/$storagemgrLog ] ; then $operation $source/$storagemgrLog $destn; fi
+ if [ -f $source/$rf4ceLog ] ; then $operation $source/$rf4ceLog $destn; fi
+ if [ -f $source/$ctrlmLog ] ; then $operation $source/$ctrlmLog $destn; fi
+ if [ -f $source/$ipdnlLog ] ; then $operation $source/$ipdnlLog $destn; fi
+
+ if [ -f $source/$fdsLog ] ; then $operation $source/$fdsLog $destn; fi
+ if [ -f $source/$dmesgLog ] ; then $operation $source/$dmesgLog $destn; fi
+ if [ -f $source/$appStatusLog ] ; then $operation $source/$appStatusLog $destn; fi
+ if [ -f $source/$gpLog ]; then $operation $source/$gpLog $destn; fi
+ if [ -f $source/$sysLog ] ; then $operation $source/$sysLog $destn; fi
+ if [ -f $source/$ntpLog ] ; then $operation $source/$ntpLog $destn; fi
+ if [ -f $source/$wbLog ] ; then $operation $source/$wbLog $destn; fi
+ if [ -f $source/$ueiLog ] ; then $operation $source/$ueiLog $destn; fi
+ if [ -f $source/$receiverMON ] ; then $operation $source/$receiverMON $destn; fi
+ if [ -f $source/$swUpdateLog ] ; then $operation $source/$swUpdateLog $destn; fi
+ if [ -f $source/$topLog ] ; then $operation $source/$topLog $destn; fi
+ if [ -f $source/$fusionDaleLog ] ; then $operation $source/$fusionDaleLog $destn; fi
+
+ if [ -f $source/$mfrLog ] ; then $operation $source/$mfrLog $destn; fi
+ if [ -f $source/$mocaLog ] ; then $operation $source/$mocaLog $destn; fi
+ if [ -f $source/$rebootLog ] ; then $operation $source/$rebootLog $destn; fi
+ if [ -f $source/$rebootInfoLog ] ; then $operation $source/$rebootInfoLog $destn; fi
+ if [ -f $source/$xDiscoveryLog ] ; then $operation $source/$xDiscoveryLog $destn; fi
+ if [ -f $source/$xDiscoveryListLog ] ; then $operation $source/$xDiscoveryListLog $destn; fi
+
+ if [ -f $source/$socProvisionLog ] ; then $operation $source/$socProvisionLog $destn; fi
+ if [ -f $source/$socProvisionCryptoLog ] ; then $operation $source/$socProvisionCryptoLog $destn; fi
+ if [ -f $source/$lighttpdErrorLog ] ; then $operation $source/$lighttpdErrorLog $destn; fi
+ if [ -f $source/$lighttpdAccessLog ] ; then $operation $source/$lighttpdAccessLog $destn; fi
+ if [ -f $source/$dcmLog ] ; then $operation $source/$dcmLog $destn; fi
+ if [ -f $source/$coreDumpLog ] ; then $operation $source/$coreDumpLog $destn; fi
+ if [ -f $source/$mountLog ] ; then $operation $source/$mountLog $destn; fi
+ if [ -f $source/$rbiDaemonLog ] ; then $operation $source/$rbiDaemonLog $destn; fi
+ if [ -f $source/$rfcLog ] ; then $operation $source/$rfcLog $destn; fi
+ if [ -f $source/$tlsLog ] ; then $operation $source/$tlsLog $destn; fi
+ if [ -f $source/$playreadycdmiLog ] ; then $operation $source/$playreadycdmiLog $destn; fi
+ if [ -f $source/$wpecdmiLog ] ; then $operation $source/$wpecdmiLog $destn; fi
+ if [ -f $source/$pingTelemetryLog ] ; then $operation $source/$pingTelemetryLog $destn; fi
+ if [ -f $source/$deviceDetailsLog ] ; then $operation $source/$deviceDetailsLog $destn; fi
+ if [ -f $source/$zramLog ] ; then $operation $source/$zramLog $destn; fi
+ if [ -f $source/$appmanagerLog ] ; then $operation $source/$appmanagerLog $destn; fi
+ if [ -f $source/$nlmonLog ] ; then $operation $source/$nlmonLog $destn; fi
+ if [ -f $source/$hwselfLog ] ; then $operation $source/$hwselfLog $destn; fi
+ if [ "$CONTAINER_SUPPORT" == "true" ];then
+ if [ -f $source/$xreLxcApplicationsLog ] ; then $operation $source/$xreLxcApplicationsLog $destn; fi
+ if [ -f $source/$xreLxcLog ] ; then $operation $source/$xreLxcLog $destn; fi
+ fi
+
+ #Adding a work around to create core_log.txt whith restricted user privilege
+ #if linux multi user is enabled
+ if [ "$ENABLE_MULTI_USER" == "true" ] && [ ! -f /etc/os-release ] ; then
+ if [ "$BUILD_TYPE" == "prod" ] ; then
+ touch $source/$coreDumpLog
+ chown restricteduser:restrictedgroup $source/$coreDumpLog
+ else
+ if [ ! -f /opt/disable_chrootXREJail ]; then
+ touch $source/$coreDumpLog
+ chown restricteduser:restrictedgroup $source/$coreDumpLog
+ fi
+ fi
+ fi
+ #End of work around related to core_log.txt for Linux multi user support
+ if [ -f $source/$trmLog ] ; then $operation $source/$trmLog $destn; fi
+ if [ -f $source/$trmMgrLog ] ; then $operation $source/$trmMgrLog $destn; fi
+ if [ -f $source/$threadLog ] ; then $operation $source/$threadLog $destn; fi
+ if [ -f $source/$greenpeakLog ]; then $operation $source/$greenpeakLog $destn; fi
+ if [ -f $source/$startupDmesgLog ] ; then $operation $source/$startupDmesgLog $destn; fi
+ if [ -f $source/$coreLog ] ; then $operation $source/$coreLog $destn; fi
+ if [ -f $source/$xDeviceLog ] ; then $operation $source/$xDeviceLog $destn; fi
+ if [ -f $source/$rmfLog ] ; then $operation $source/$rmfLog $destn; fi
+ if [ "$DEVICE_TYPE" != "mediaclient" ]; then
+ if [ -f $source/$podLog ] ; then $operation $source/$podLog $destn; fi
+ if [ -f $source/$vodLog ] ; then $operation $source/$vodLog $destn; fi
+ if [ -f $source/$diskEventsLog ] ; then $operation $source/$diskEventsLog $destn; fi
+ if [ -f $source/$diskInfoLog ] ; then $operation $source/$diskInfoLog $destn; fi
+ if [ -f $source/$ablReasonLog ] ; then $operation $source/$ablReasonLog $destn; fi
+ if [ -f $source/$mpeosmainMON ] ; then $operation $source/$mpeosmainMON $destn; fi
+ if [ -f $source/$ecmLog ] ; then $operation $source/$ecmLog $destn; fi
+ if [ -f $source/$pumaLog ] ; then $operation $source/$pumaLog $destn; fi
+ if [ -f $source/$pumaLog1 ] ; then $operation $source/$pumaLog1 $destn; fi
+ if [ -f $source/$heapDmpLog ] ; then $operation $source/$heapDmpLog $destn; fi
+ if [ -f $source/$cardStatusLog ] ; then $operation $source/$cardStatusLog $destn; fi
+ if [ -f $source/$rfStatisticsLog ] ; then $operation $source/$rfStatisticsLog $destn; fi
+ if [ -f $source/$riLog ] ; then $operation $source/$riLog $destn; fi
+ if [ -f $source/$xfsdmesgLog ] ; then $operation $source/$xfsdmesgLog $destn; fi
+ if [ -f $mpeosRebootLog ] ; then
+ if [ "$BUILD_TYPE" = "dev" ]; then
+ cp $mpeosRebootLog $destn
+ else
+ $operation $mpeosRebootLog $destn
+ fi
+ fi
+ if [ "$LIGHTSLEEP_ENABLE" = "true" ]; then
+ if [ -f $source/lightsleep.log ] ; then $operation $source/lightsleep.log $destn; fi
+ fi
+ if [ -f $source/$snmpdLog ] ; then $operation $source/$snmpdLog $destn; fi
+ if [ -f $source/$upstreamStatsLog ] ; then $operation $source/$upstreamStatsLog $destn; fi
+ if [ -f $source/$dibblerLog ] ; then $operation $source/$dibblerLog $destn; fi
+ if [ -f $source/$dnsmasqLog ] ; then $operation $source/$dnsmasqLog $destn; fi
+ else
+ if [ -f $source/$wifiTelemetryLog ] ; then $operation $source/$wifiTelemetryLog $destn; fi
+ if [ -f $source/$tr69Log ] ; then $operation $source/$tr69Log $destn; fi
+ if [ -f $source/$tr69AgentLog ] ; then $operation $source/$tr69AgentLog $destn; fi
+ if [ -f $source/$tr69HostIfLog ] ; then $operation $source/$tr69HostIfLog $destn; fi
+ if [ -f $source/$tr69DownloadLog ] ; then $operation $source/$tr69DownloadLog $destn; fi
+ if [ -f $source/$gatewayLog ] ; then $operation $source/$gatewayLog $destn; fi
+ if [ -f $source/$ipSetupLog ] ; then $operation $source/$ipSetupLog $destn; fi
+ if [ -f $source/$tr69AgentHttpLog ] ; then $operation $source/$tr69AgentHttpLog $destn; fi
+ if [ -f $source/$tr69AgentSoapLog ] ; then $operation $source/$tr69AgentSoapLog $destn; fi
+ if [ -f $source/$webpavideoLog ] ; then $operation $source/$webpavideoLog $destn; fi
+ if [ -f $source/$xiConnectionStatusLog ] ; then $operation $source/$xiConnectionStatusLog $destn; fi
+ fi
+ # backup version.txt
+ if [ -f $source/$version ] ; then
+ $operation $source/$version $destn
+ else
+ cp /$version $destn
+ fi
+ # backup older cycle logs
+ if [ -f $source/$rstreamFdLog ] ; then $operation $source/$rstreamFdLog $destn; fi
+ if [ -f $source/$authServiceLog ] ; then $operation $source/$authServiceLog $destn; fi
+ if [ -f $source/$cardProvisionCheckLog ] ; then $operation $source/$cardProvisionCheckLog $destn; fi
+ if [ -f $source/$diskCleanupLog ] ; then $operation $source/$diskCleanupLog $destn; fi
+ if [ -f $source/$diskCleanupInfoLog ] ; then $operation $source/$diskCleanupInfoLog $destn; fi
+ if [ -f $recorderLog ]; then mv $recorderLog $destn; fi
+ if [ -f $source/$topOsalLog ] ; then $operation $source/$topOsalLog $destn; fi
+ if [ -f $source/$mocaStatusLog ] ; then $operation $source/$mocaStatusLog $destn; fi
+ if [ -f $source/$decoderStatusLog ] ; then $operation $source/$decoderStatusLog $destn; fi
+ if [ -f $source/$mfrLogRdk ] ; then $operation $source/$mfrLogRdk $destn; fi
+ if [ -f $source/$cefLog ] ; then $operation $source/$cefLog $destn; fi
+ if [ -f $source/$diskCleanupLog1 ] ; then $operation $source/$diskCleanupLog1 $destn; fi
+ if [ -f $source/$sysDmesgLog ] ; then $operation $source/$sysDmesgLog $destn; fi
+ if [ -f $source/$samhainLog ] ; then $operation $source/$samhainLog $destn; fi
+ if [ -f $source/$fogLog ] ; then $operation $source/$fogLog $destn; fi
+ if [ -f $source/$hddStatusLog ] ; then $operation $source/$hddStatusLog $destn; fi
+ if [ -f $source/$xiRecoveryLog ] ; then $operation $source/$xiRecoveryLog $destn; fi
+ if [ -f $source/$dropbearLog ] ; then $operation $source/$dropbearLog $destn; fi
+
+ if [ "$SOC" = "BRCM" ];then
+ if [ -f $source/$nxSvrLog ] ; then $operation $source/$nxSvrLog $destn; fi
+ if [ -f $source/$procStatusLog ] ; then $operation $source/$procStatusLog $destn; fi
+ fi
+ if [ -f $source/$netsrvLog ] ; then $operation $source/$netsrvLog $destn; fi
+ if [ -f $source/$adobeCleanupLog ] ; then $operation $source/$adobeCleanupLog $destn; fi
+
+ if [ "$DEVICE_TYPE" == "XHC1" ];then
+ if [ -f $source/$streamsrvLog ] ; then $operation $source/$streamsrvLog $destn; fi
+ if [ -f $source/$stunnelHttpsLog ] ; then $operation $source/$stunnelHttpsLog $destn; fi
+ if [ -f $source/$upnpLog ] ; then $operation $source/$upnpLog $destn; fi
+ if [ -f $source/$upnpigdLog ] ; then $operation $source/$upnpigdLog $destn; fi
+ if [ -f $source/$cgiLog ] ; then $operation $source/$cgiLog $destn; fi
+ if [ -f $source/$systemLog ] ; then $operation $source/$systemLog $destn; fi
+ if [ -f $source/$eventLog ] ; then $operation $source/$eventLog $destn; fi
+ if [ -f $source/$xw3MonitorLog ] ; then $operation $source/$xw3MonitorLog $destn; fi
+ if [ -f $source/$sensorDLog ] ; then $operation $source/$sensorDLog $destn; fi
+ if [ -f $source/$webpaLog ] ; then $operation $source/$webpaLog $destn; fi
+ if [ -f $source/$xwclientLog ] ; then $operation $source/$xwclientLog $destn; fi
+ if [ -f $source/$xwswupdateLog ] ; then $operation $source/$xwswupdateLog $destn; fi
+ if [ -f $source/$userLog ] ; then $operation $source/$userLog $destn; fi
+ if [ -f $source/$webrtcStreamingLog ] ; then $operation $source/$webrtcStreamingLog $destn; fi
+ if [ -f $source/$cvrPollLog ] ; then $operation $source/$cvrPollLog $destn; fi
+ if [ -f $source/$ivaDaemonLog ] ; then $operation $source/$ivaDaemonLog $destn; fi
+ if [ -f $source/$thumbnailUploadLog ] ; then $operation $source/$thumbnailUploadLog $destn; fi
+ if [ -f $source/$metricsLog ] ; then $operation $source/$metricsLog $destn; fi
+ if [ -f $source/$wifiLog ] ; then $operation $source/$wifiLog $destn; fi
+ if [ -f $source/$overlayLog ] ; then $operation $source/$overlayLog $destn; fi
+ if [ -f $source/$xvisionLog ] ; then $operation $source/$xvisionLog $destn; fi
+ if [ -f $source/$evoLog ] ; then $operation $source/$evoLog $destn; fi
+ if [ -f $source/$camstreamsrvLog ] ; then $operation $source/$camstreamsrvLog $destn; fi
+ if [ -f $source/$mongsLog ] ; then $operation $source/$mongsLog $destn; fi
+ fi
+ if [ "$WIFI_SUPPORT" == "true" ];then
+ if [ -f $source/$wpaSupplicantLog ] ; then $operation $source/$wpaSupplicantLog $destn; fi
+ if [ -f $source/$dhcpWifiLog ] ; then $operation $source/$dhcpWifiLog $destn; fi
+ fi
+ if [ -f $source/$audiocapturemgrLogs ] ; then $operation $source/$audiocapturemgrLogs $destn; fi
+
+}
+
+logCleanup()
+{
+ echo "Done Log Backup"
+}
+
diff --git a/recipes-rdkb/sysint-broadband/files/swupdate.service b/recipes-rdkb/sysint-broadband/files/swupdate.service
new file mode 100644
index 0000000..23dc72d
--- /dev/null
+++ b/recipes-rdkb/sysint-broadband/files/swupdate.service
@@ -0,0 +1,13 @@
+[Unit]
+Description=Software Update Service
+After=CcspPandMSsp.service
+StartLimitIntervalSec=120
+
+[Service]
+Type=forking
+ExecStartPre=/bin/sh -c '/bin/touch /rdklogs/logs/swupdate.log'
+ExecStart=/bin/sh -c '/lib/rdk/swupdate_utility.sh 2&> /rdklogs/logs/swupdate.log &'
+Restart=always
+
+[Install]
+WantedBy=multi-user.target
diff --git a/recipes-rdkb/sysint-broadband/files/swupdate_utility.sh b/recipes-rdkb/sysint-broadband/files/swupdate_utility.sh
new file mode 100755
index 0000000..69a11a8
--- /dev/null
+++ b/recipes-rdkb/sysint-broadband/files/swupdate_utility.sh
@@ -0,0 +1,186 @@
+#!/bin/bash
+. /etc/include.properties
+. /etc/device.properties
+
+#Utility Functions
+#=================
+
+check ()
+{
+ if [ $? != 0 ]; then
+ echo "FATAL: $*"
+ sleep 10
+ continue
+ fi
+}
+
+jsonparse() {
+ if [ -d $1 ]; then
+ printf "Usage 'jsonparse <parameter-name>'\n"
+ exit 1
+ fi
+ value=`cat /tmp/cloudurl.txt | json_reformat | grep -w $1 | cut -d':' -f2 | tr -d "\",\ "`
+ if [ -d $value ];then
+ echo "FATAL: JSON value not present, check /tmp/cloudurl.txt file"
+ exit 1
+ fi
+ echo $value
+}
+
+tftpDownload () {
+ mkdir -p /tmp/tftpimage
+ cd /tmp/tftpimage
+ echo "set IPtable rules for tftp !!"
+ iptables -t raw -I OUTPUT -j CT -p udp -m udp --dport 69 --helper tftp
+ echo "CloudFile: "$firmwareFilename
+ echo "CloudLocation: "$firmwareLocation
+
+ check_sum_file="${firmwareVersion}.txt"
+ echo "Checksum file to download from tftp server: $check_sum_file"
+ tftp -g -r $check_sum_file $firmwareLocation
+ if [ ! -f $PWD/$check_sum_file ]; then
+ echo "Cloud checksum file not downloaded from TFTP: verify tftp connection($firmwareLocation)"
+ sleep 2
+ continue
+ fi
+
+ echo "Downloading $firmwareFilename..."
+ tftp -g -r $firmwareFilename $firmwareLocation
+ if [ ! -f $PWD/$firmwareFilename ]; then
+ echo "Image itself not downloaded from TFTP: verify tftp connection($firmwareLocation)"
+ sleep 2
+ continue
+ fi
+ echo "Doing additional check: comparing checksum ..."
+ cloudcsfile_path="/tmp/tftpimage/$check_sum_file"
+ echo "checksum file to download with actual path: $cloudcsfile_path"
+ cloudcs=`cat $cloudcsfile_path | cut -f 1 -d ' '`
+ echo "cloudcs:cloud download md5sum file version: $cloudcs"
+ devcs=`md5sum /tmp/tftpimage/rdk*.tar | cut -f 1 -d " "`
+ echo "devcs:image download checksum md5sum file version: $devcs"
+
+ if [ "$devcs" != "$cloudcs" ]; then
+ echo "Mismatch in md5sum: tftp file not downloaded properly"
+ continue
+ fi
+ echo "checksum verification done: md5sum matches !!"
+ tar -xf /tmp/tftpimage/$firmwareVersion.tar -C /tmp/
+ check "Failed to untar $firmwareFilename"
+}
+
+httpDownload () {
+ mkdir -p /tmp/httpimage
+ cd /tmp/httpimage
+ echo "CloudFile: "$firmwareFilename
+ echo "CloudLocation: "$firmwareLocation
+
+ check_sum_file="${firmwareVersion}.txt"
+ echo "Checksum file to download from webserver: $check_sum_file"
+ wget http://$firmwareLocation/$check_sum_file -O $check_sum_file
+ if [ ! -f $PWD/$check_sum_file ]; then
+ echo "Cloud checksum file not downloaded from Webserver: verify connection to $firmwareLocation"
+ sleep 2
+ continue
+ fi
+
+ echo "Downloading $firmwareFilename..."
+ wget http://$firmwareLocation/$firmwareFilename -O $firmwareFilename
+ if [ ! -f $PWD/$firmwareFilename ]; then
+ echo "Image itself not downloaded from Webserver: verify connection to $firmwareLocation"
+ sleep 2
+ continue
+ fi
+ echo "Doing additional check: comparing checksum ..."
+ cloudcsfile_path="/tmp/httpimage/$check_sum_file"
+ echo "checksum file to download with actual path: $cloudcsfile_path"
+ cloudcs=`cat $cloudcsfile_path | cut -f 1 -d ' '`
+ echo "cloudcs:cloud download md5sum file version: $cloudcs"
+ devcs=`md5sum /tmp/httpimage/rdk*.tar | cut -f 1 -d " "`
+ echo "devcs:image download checksum md5sum file version: $devcs"
+
+ if [ "$devcs" != "$cloudcs" ]; then
+ echo "Mismatch in md5sum: http file not downloaded properly"
+ continue
+ fi
+ echo "checksum verification done: md5sum matches !!"
+ tar -xf /tmp/httpimage/$firmwareVersion.tar -C /tmp/
+ check "Failed to untar $firmwareFilename"
+}
+
+download_image() {
+ if [ $firmwareDownloadProtocol == "tftp" ]; then
+ tftpDownload
+ elif [ $firmwareDownloadProtocol == "http" ]; then
+ httpDownload
+ else
+ echo "Unknown protocol"
+ fi
+}
+
+echo "***Start of swupdate_utility.sh***"
+
+rebootRequired=false
+while [ 1 ]
+do
+if [ $rebootRequired == true ];then
+ echo "Reboot Pending: reboot is required before possible firmware upgrade"
+ sleep 10
+ continue
+fi
+#Getting update from cloud
+#=========================
+
+CLOUDURL=http://35.155.171.121:9092/xconf/swu/stb?eStbMac=
+erouterMac=`ifconfig $EROUTER_INTERFACE | grep HWaddr | cut -c39-55`
+CLOUD_URL=$CLOUDURL$erouterMac
+
+echo "CLOUD_URL: $CLOUD_URL"
+curl $CLOUD_URL -o /tmp/cloudurl.txt
+if [ $? != 0 ];then
+ echo "curl failed to fetch firmware details: check internet connection"
+ sleep 10
+ continue
+fi
+
+#version check
+#=============
+
+#Comparing image versions and will upgrade if there is a mismatch
+currentVersion=`grep "^imagename" /version.txt | cut -d ':' -f2`
+
+#eg. firmwareVersion=rdkb-generic-broadband-image_default_20200608060354
+firmwareVersion=`jsonparse firmwareVersion`
+cloudfirmwareversion=$firmwareVersion
+if [ "$currentVersion" == "$cloudfirmwareversion" ]; then
+ echo "Image versions remains same !!"
+ sleep 10
+ continue
+fi
+
+echo "cloud Image version: "$cloudfirmwareversion
+echo "Current Image version: "$currentVersion
+echo "Image versions mismatches !! start upgrade"
+
+#Environment setting
+#===================
+#eg. firmwareDownloadProtocol=tftp
+firmwareDownloadProtocol=`jsonparse firmwareDownloadProtocol`
+
+#eg. firmwareFilename=rdkb-generic-broadband-image_default_20200608060354.tar
+firmwareFilename=`jsonparse firmwareFilename`
+
+#eg. firmwareLocation=192.168.1.9
+firmwareLocation=`jsonparse firmwareLocation`
+
+#eg. rebootImmediately=false
+rebootImmediately=`jsonparse rebootImmediately`
+
+download_image
+/lib/rdk/TurrisFwUpgrade.sh
+check "TurrisFwUpgrade.sh failed to flash new Image"
+
+if [ $rebootImmediately == true ]; then
+ reboot
+fi
+rebootRequired=true
+done
diff --git a/recipes-rdkb/sysint-broadband/files/uploadSTBLogs.sh b/recipes-rdkb/sysint-broadband/files/uploadSTBLogs.sh
new file mode 100755
index 0000000..545ec5f
--- /dev/null
+++ b/recipes-rdkb/sysint-broadband/files/uploadSTBLogs.sh
@@ -0,0 +1,478 @@
+#!/bin/sh
+##########################################################################
+# If not stated otherwise in this file or this component's Licenses.txt
+# file the following copyright and licenses apply:
+#
+# Copyright 2018 RDK Management
+#
+# 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.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+##########################################################################
+
+. /etc/include.properties
+. /etc/device.properties
+
+. $RDK_PATH/utils.sh
+. $RDK_PATH/interfaceCalls.sh
+. $RDK_PATH/utils.sh
+. $RDK_PATH/logfiles.sh
+. $RDK_PATH/commonUtils.sh
+
+if [ $# -ne 6 ]; then
+ echo "USAGE: $0 <TFTP Server IP> <Flag (STB delay or not)> <SCP_SERVER> <UploadOnReboot> <UploadProtocol> <UploadHttpLink>"
+fi
+
+# assign the input arguments
+TFTP_SERVER=$1
+FLAG=$2
+DCM_FLAG=$3
+UploadOnReboot=$4
+UploadProtocol=$5
+UploadHttpLink=$6
+
+DCM_LOG_PATH=/upload
+
+if [ $FLAG -eq 0 ]; then
+ if [ -f $RAMDISK_PATH/.standby ]; then
+ echo "`/bin/timestamp` Exiting since box is in standby..!"
+ exit 0
+ fi
+fi
+
+# initialize the variables
+MAC=`getErouterMacAddress`
+HOST_IP=`getIPAddress`
+dt=`date "+%m-%d-%y-%I-%M%p"`
+LOG_FILE="$MAC_Logs_$dt.tgz"
+
+#MARKER_FILE=$MAC"_Logs_Marker_$dt.txt"
+VERSION="version.txt"
+# working folders
+PREV_LOG_PATH="$LOG_PATH/PreviousLogs"
+PREV_LOG_BACKUP_PATH="$LOG_PATH/PreviousLogs_backup/"
+DCM_UPLOAD_LIST="$LOG_PATH/dcm_upload"
+
+echo "Build Type: $BUILD_TYPE Log file: $LOG_FILE TFTP Server: $TFTP_SERVER Protocol: $UploadProtocol UploadHttpLink: $UploadHttpLink" >> $LOG_PATH/dcmscript.log
+
+prevUploadFlag=0
+
+if [ ! -d $PREV_LOG_PATH ]; then
+ echo "The Previous Logs folder is missing" >> $LOG_PATH/dcmscript.log
+ #if [ "true" != "$RDK_EMULATOR" ]; then
+ # exit 0
+ #else
+
+ if [ ! -d $LOG_PATH ]; then mkdir -p $LOG_PATH; fi
+ if [ ! -d $LOG_PATH/PreviousLogs ]; then mkdir -p $LOG_PATH/PreviousLogs; fi
+ if [ ! -d $LOG_PATH/PreviousLogs_backup ]; then mkdir -p $LOG_PATH/PreviousLogs_backup; fi
+ rm -rf $LOG_PATH/PreviousLogs_backup/*
+
+ backupSystemLogFiles mv $LOG_PATH $PREV_LOG_PATH
+ backupAppBackupLogFiles mv $LOG_PATH $PREV_LOG_PATH
+
+ #fi
+else
+ #if [ "true" != "$RDK_EMULATOR" ]; then
+ #echo ""
+ #else
+
+ rm -rf $LOG_PATH/PreviousLogs_backup/*
+ backupSystemLogFiles mv $LOG_PATH $PREV_LOG_PATH
+ backupAppBackupLogFiles mv $LOG_PATH $PREV_LOG_PATH
+ #cp $PREV_LOG_BACKUP_PATH/* $PREV_LOG_PATH/
+ #fi
+fi
+
+backupAppLogs()
+{
+ source=$1
+ destn=$2
+ if [ -f $source$RILog ] ; then cp $source$RILog $destn; fi
+ if [ -f $source$XRELog ] ; then cp $source$XRELog $destn; fi
+ if [ -f $source$WBLog ] ; then cp $source$WBLog $destn; fi
+ if [ -f $source$SysLog ] ; then cp $source$SysLog $destn; fi
+}
+renameRotatedLogs()
+{
+ logPath=$1
+ if [ -f $RDK_PATH/renameRotatedLogs.sh ]; then
+ if [ -f $logPath/ocapri_log.txt ] ; then sh $RDK_PATH/renameRotatedLogs.sh $logPath/ocapri_log.txt; fi
+ if [ -f $logPath/receiver.log ] ; then sh $RDK_PATH/renameRotatedLogs.sh $logPath/receiver.log; fi
+ if [ -f $logPath/greenpeak.log ] ; then sh $RDK_PATH/renameRotatedLogs.sh $logPath/greenpeak.log; fi
+ if [ -f $logPath/gp_init.log ] ; then sh $RDK_PATH/renameRotatedLogs.sh $logPath/gp_init.log; fi
+ if [ -f $logPath/app_status.log ] ; then sh $RDK_PATH/renameRotatedLogs.sh $logPath/app_status.log; fi
+ fi
+}
+processLogsFolder()
+{
+ srcLogPath=$1
+ destnLogPath=$2
+ backupAppLogs "$srcLogPath/" "$destnLogPath/"
+ backupSystemLogFiles "cp" $srcLogPath $destnLogPath
+ backupAppBackupLogFiles "cp" $srcLogPath $destnLogPath
+
+ if [ -f $RAMDISK_PATH/disk_log.txt ]; then cp $RAMDISK_PATH/disk_log.txt $destnLogPath ; fi
+
+ backupCount=`ls $srcLogPath/logbackup-* 2>/dev/null | wc -l`
+ if [ $backupCount -gt 0 ]; then
+ cp -r $srcLogPath/logbackup-* $destnLogPath
+ fi
+
+ if [ -f $srcLogPath/$rebootLog ]; then cp $srcLogPath/$rebootLog $destnLogPath; fi
+ if [ -f $srcLogPath/$ablReasonLog ]; then cp $srcLogPath/$ablReasonLog $destnLogPath; fi
+ if [ -f $srcLogPath/$ueiLog ]; then cp $srcLogPath/$ueiLog $destnLogPath; fi
+ if [ -f $PERSISTENT_PATH/sventest/p3541_all_csven_AV_health_data_trigger.tar.gz ] ; then
+ cp $PERSISTENT_PATH/sventest/p3541_all_csven_AV_health_data_trigger.tar.gz $destnLogPath
+ fi
+ if [ "$DEVICE_TYPE" != "mediaclient" ]; then
+ renameRotatedLogs $srcLogPath
+ fi
+}
+modifyFileWithTimestamp()
+{
+ srcLogPath=$1
+ ret=`ls $srcLogPath/*.txt | wc -l`
+ if [ ! $ret ]; then
+ ret=`ls $srcLogPath/*.log | wc -l`
+ if [ ! $ret ]; then exit 1; fi
+ fi
+
+ dt=`date "+%m-%d-%y-%I-%M%p-"`
+ FILES=*.*
+ FILES1=".*-[0-9][0-9]AM-.*"
+ FILES2=".*-[0-9][0-9]PM-.*"
+
+ for f in $FILES
+ do
+ test1=0
+ test2=0
+ test3=0
+ test4=0
+
+ test1=`expr match $f $FILES1`
+ test2=`expr match $f $FILES2`
+ test3=`expr match $f $rebootLog`
+ test4=`expr match $f $ablReasonLog`
+
+ if [ $test1 -gt 0 -o $test2 -gt 0 -o $test3 -gt 0 -o $test4 -gt 0 ]; then
+ echo "`/bin/timestamp` Processing file...$f" >> $LOG_PATH/dcmscript.log
+ else
+ mv $f $dt$f
+ fi
+ done
+ #cp /version.txt ./$dt$VERSION
+}
+
+copyAllFiles ()
+{
+
+ EXCLUDE="dcm PreviousLogs_backup PreviousLogs"
+ cd $LOG_PATH
+
+ for fileName in *
+ do
+ COPY_BOOLEAN=true
+ for excl in $EXCLUDE
+ do
+ if [ $excl == $fileName ]; then
+ COPY_BOOLEAN=false
+ fi
+ done
+
+ if $COPY_BOOLEAN; then
+ cp -R $fileName $DCM_LOG_PATH
+ fi
+ done
+}
+copyOptLogsFiles ()
+{
+ cd $LOG_PATH
+ cp * $DCM_LOG_PATH >> $LOG_PATH/dcmscript.log 2>&1
+}
+
+HttpLogUpload()
+{
+ result=1
+ FILENAME='/tmp/httpresult.txt'
+ HTTP_CODE=/tmp/curl_httpcode
+
+ CLOUD_URL=$UploadHttpLink
+ #CLOUD_URL="$(UploadHttpLink)filename=$LOG_FILE"
+
+ CURL_CMD="curl -w '%{http_code}\n' -F \"filename=@$1\" -o \"$FILENAME\" \"$CLOUD_URL\" --connect-timeout 10 -m 10"
+ echo URL_CMD: $CURL_CMD
+ ret= eval $CURL_CMD > $HTTP_CODE
+ http_code=$(awk -F\" '{print $1}' $HTTP_CODE)
+ if [ $http_code -eq 200 ];then
+ echo "`/timestamp` Done Uploading Logs through HTTP" >> $LOG_PATH/dcmscript.log
+ result=0
+ elif [ $http_code -eq 302 ];then
+ #Get the url from FILENAME
+ NewUrl=$(awk -F\" '{print $1}' $FILENAME)
+
+ CURL_CMD="curl -w '%{http_code}\n' -o \"$FILENAME\" \"$NewUrl\" --connect-timeout 10 -m 10"
+ echo URL_CMD: $CURL_CMD
+ result= eval $CURL_CMD > $HTTP_CODE
+ http_code=$(awk -F\" '{print $1}' $HTTP_CODE)
+
+ if [ $http_code -eq 200 ];then
+ echo "`/timestamp` Done Uploading Logs through - HTTP" >> $LOG_PATH/dcmscript.log
+ result=0
+ else
+ echo "`/timestamp` Failed Uploading Logs through - HTTP" >> $LOG_PATH/dcmscript.log
+ fi
+ fi
+ echo $result
+}
+
+uploadDCMLogs()
+{
+
+ cd $DCM_LOG_PATH
+ echo " Uploading Logs through DCM cron job" >> $LOG_PATH/dcmscript.log
+ modifyFileWithTimestamp $DCM_LOG_PATH >> $LOG_PATH/dcmscript.log 2>&1
+ tar -zcvf $LOG_FILE * >> $LOG_PATH/dcmscript.log 2>&1
+ sleep 60
+ echo "Uploading logs $LOG_FILE onto $TFTP_SERVER" >> $LOG_PATH/dcmscript.log
+
+ retval=1
+
+ if [ "$UploadProtocol" == "HTTP" ];then
+ retval=$(HttpLogUpload $LOG_FILE)
+ fi
+ if [ $retval -eq 1 ];then #Http upload failed
+ tftp -p -r $LOG_FILE -l $LOG_FILE $TFTP_SERVER >> $LOG_PATH/dcmscript.log 2>&1
+ echo "`/bin/timestamp` Done Uploading Logs through TFTP" >> $LOG_PATH/dcmscript.log
+ sleep 1
+ fi
+
+ rm -rf $DCM_LOG_PATH/
+}
+uploadLogOnReboot()
+{
+ uploadLog=$1
+ echo "Sleeping for seven minutes "
+ if [ "true" != "$RDK_EMULATOR" ]; then
+ sleep 12
+ fi
+ echo "Done sleeping prev logpath "$PREV_LOG_PATH
+ ret=`ls $PREV_LOG_PATH/*.txt | wc -l`
+ if [ ! $ret ]; then
+ ret=`ls $PREV_LOG_PATH/*.log | wc -l`
+ if [ ! $ret ]; then exit 1; fi
+ fi
+ if [ "$HDD_ENABLED" = "true" ]; then
+ # Special processing - Permanently backup logs on box delete the logs older than
+ # 3 days to take care of old filename
+ sleep 2
+ stat=`find /opt/logs -name "*-*-*-*-*M-" -mtime +3 -exec rm -rf {} \;`
+ # for the new filenames with suffix logbackup
+ stat=`find /opt/logs -name "*-*-*-*-*M-logbackup" -mtime +3 -exec rm -rf {} \;`
+
+ TIMESTAMP=`date "+%m-%d-%y-%I-%M%p-logbackup"`
+ PERM_LOG_PATH="$LOG_PATH/$TIMESTAMP"
+ mkdir -p $PERM_LOG_PATH
+
+ processLogsFolder $PREV_LOG_PATH $PERM_LOG_PATH
+ fi
+ echo "ckp100-------------prev log path-------------"$PREV_LOG_PATH
+ cd $PREV_LOG_PATH
+ rm $LOG_FILE
+ modifyFileWithTimestamp $PREV_LOG_PATH >> $LOG_PATH/dcmscript.log 2>&1
+
+ echo "ckp101---------------------upload log-----"$uploadLog
+ ls -al
+ sleep 30
+ if $uploadLog; then
+ echo "ckp101--------------------------"
+ tar -zcvf $LOG_FILE * >> $LOG_PATH/dcmscript.log 2>&1
+ echo "Uploading logs $LOG_FILE onto $TFTP_SERVER" >> $LOG_PATH/dcmscript.log
+ sleep 60
+ #tftp -p -r $LOG_FILE -l $LOG_FILE $TFTP_SERVER >> $LOG_PATH/dcmscript.log 2>&1
+ #sleep 1
+ #echo "`/bin/timestamp` Done Uploading Logs" >> $LOG_PATH/dcmscript.log
+ proUpdel=`cat /tmp/DCMSettings.conf | grep -i uploadRepository:uploadProtocol | tr -dc '"' |wc -c`
+ echo "number of proUPdel2:"$proUpdel
+ #proUpdel=$((proUpdel - 1))
+ uploadProtocolla=`cat /tmp/DCMSettings.conf | grep -i urn:settings:TelemetryProfile | cut -d '"' -f$proUpdel`
+ echo "Upload protocol logupload is:"$uploadProtocolla
+ TurrisMacAddress=`ifconfig erouter0 | grep HWaddr | cut -c39-55`
+ cp $LOG_FILE $TurrisMacAddress-Logs-$LOG_FILE
+ if [ "$uploadProtocolla" != "TFTP" ];then
+ echo "before HTTP log upload"
+ HTTPLOGUPLOADURL=`cat /tmp/DCMSettings.conf | grep -i "urn:settings:LogUploadSettings:RepositoryURL" | cut -d "=" -f2`
+ if [ "$HTTPLOGUPLOADURL" == "" ]; then
+ echo "No HTTP URL configured in xconf,going with internal one !!"
+ HTTPLOGUPLOADURL=$DCM_LA_SERVER_URL
+ fi
+ echo "HTTPLOGUPLOADURL:"$HTTPLOGUPLOADURL
+ echo "upload log file is:"$LOG_FILE
+ CURL_CMD="curl -w '%{http_code}\n' -F filename=@$PREV_LOG_PATH/$TurrisMacAddress-Logs-$LOG_FILE '$HTTPLOGUPLOADURL' --connect-timeout 100 -m 100"
+ #echo_t "CURL_CMD http proto log upload: $CURL_CMD" >> $DCM_LOG_FILE
+ echo "------CURL_CMD2:"$CURL_CMD
+ HTTP_CODE=`result= eval $CURL_CMD`
+ http_code=$(echo $HTTP_CODE | cut -d "." -f 2)
+ echo "http_code is :"$http_code
+ if [ $http_code -eq 200 ] ; then
+ echo "HTTP log upload succeded!!!!!!!!!!!!!!!!!"
+ else
+ loguploadRetryCount=0
+ while [ $loguploadRetryCount -lt 2 ]
+ do
+ echo "Trying to upload log file..."
+ CURL_CMD="curl -w '%{http_code}\n' -F filename=@$PREV_LOG_PATH/$TurrisMacAddress-Logs-$LOG_FILE '$HTTPLOGUPLOADURL' --connect-timeout 100 -m 100"
+ HTTP_CODE=`result= eval $CURL_CMD`
+ http_code_la=$(echo $HTTP_CODE | cut -d "." -f 2)
+ echo "http_code is :"$http_code_la
+ if [ "$http_code_la" != "200" ]; then
+ echo "Error in uploading log file"
+ else
+ echo "logupload succeded in retry"
+ break
+ fi
+ loguploadRetryCount=`expr $loguploadRetryCount + 1`
+ done
+ if [ $loguploadRetryCount -eq 2]; then
+ echo "HTTP log upload failed!!!!!!!!!!!!!!!!!"
+ fi
+ fi
+ else
+ echo "Uploading logs $LOG_FILE onto $TFTP_SERVER" >> $LOG_PATH/dcmscript.log
+ tftp -p -r $TurrisMacAddress-Logs-$LOG_FILE -l $TurrisMacAddress-Logs-$LOG_FILE $TFTP_SERVER >> $LOG_PATH/dcmscript.log 2>&1
+ ret=$?
+ echo $ret
+ if [ "$ret" -eq 1 ]; then
+ tftplauploadRetryCount=0
+ while [ "$tftplauploadRetryCount" -lt 2 ]
+ do
+ echo "Trying to upload logs file using tftp again..."
+ tftp -p -r $TurrisMacAddress-Logs-$LOG_FILE -l $TurrisMacAddress-Logs-$LOG_FILE $TFTP_SERVER >> $LOG_PATH/dcmscript.log 2>&1
+ ret=$?
+ if [ "$ret" -eq 1 ]; then
+ echo "error in uploading logs using tftp"
+ else
+ echo "tftp upload in retry logs succeded"
+ ret=0
+ break
+ fi
+ tftplauploadRetryCount=`expr $tftplauploadRetryCount + 1`
+ done
+ if [ "$tftlauploadRetryCount" -eq 2 ]; then
+ ret=1
+ echo "TFTP log upload failed!!!!!!!!!!!!!!!!!"
+ else
+ echo "TFTP log upload succeded !!!"
+ ret=0
+ fi
+ fi
+ fi
+ sleep 60
+ echo "Done Uploading Logs and removing rtl_json.txt file"
+ rm -rf $PREV_LOG_PATH/$TurrisMacAddress-Logs-$LOG_FILE
+ rm -rf $TELEMETRY_JSON_RESPONSE
+ rm -rf $PERSISTENT_PATH/*TELE*
+ fi
+ cd $PREV_LOG_PATH
+ rm -rf $PREV_LOG_PATH/$LOG_FILE
+ rm -rf $PREV_LOG_BACKUP_PATH
+ mkdir -p $PREV_LOG_BACKUP_PATH
+ if [ "$BUILD_TYPE" = "dev" ] || [ "$HDD_ENABLED" = "false" ]; then
+
+ echo "Moving to Previous Logs Backup Folder " >> $LOG_PATH/dcmscript.log
+ mv * $PREV_LOG_BACKUP_PATH
+ else
+ echo "`/bin/timestamp` Deleting from Previous Logs Folder " >> $LOG_PATH/dcmscript.log
+ rm -rf *
+ fi
+}
+#if [ "$true" != "$RDK_EMULATOR" ]; then
+#if [ -d $DCM_LOG_PATH ]; then
+ # rm -rf $DCM_LOG_PATH/
+#fi
+#Remove *.tgz files from /opt/logs
+#if [ "true" != "$RDK_EMULATOR" ]; then
+#stat=`find $LOG_PATH -name "*.tgz" -exec rm -rf {} \;`
+
+#Remove files which have timestamp in it filename
+#for item in `ls $LOG_PATH/*-*-*-*-*M-* | grep "[0-9]*-[0-9]*-[0-9]*-[0-9]*-M*" | grep -v "logbackup"`;do
+ # if [ -f "$item" ];then
+ # echo "`/bin/timestamp` Removing $item" >> $LOG_PATH/dcmscript.log
+ # rm -rf $item
+ #fi
+#done
+#fi
+#fi
+if [ $DCM_FLAG -eq 0 ] ; then
+ echo "`/bin/timestamp` Uploading Without DCM" >> $LOG_PATH/dcmscript.log
+ uploadLogOnReboot true
+else
+ if [ $FLAG -eq 1 ] ; then
+ if [ $UploadOnReboot -eq 1 ]; then
+ echo "Uploading Logs with DCM UploadOnReboot set to true" >> $LOG_PATH/dcmscript.log
+ echo "call uploadLogOnReboot"
+ uploadLogOnReboot true
+
+ else
+ echo "`/bin/timestamp` Not Uploading Logs with DCM UploadOnReboot set to false" >> $LOG_PATH/dcmscript.log
+ uploadLogOnReboot false
+ echo $PERM_LOG_PATH >> $DCM_UPLOAD_LIST
+ fi
+
+ else
+ if [ $UploadOnReboot -eq 0 ]; then
+ mkdir -p $DCM_LOG_PATH
+ if [ "$HDD_ENABLED" = "true" ]; then
+ fileUploadCount=`cat "$DCM_UPLOAD_LIST" | wc -l`
+ if [ $fileUploadCount -gt 0 ]; then
+ while read line
+ do
+ echo $line
+ cp -R $line $DCM_LOG_PATH
+ done < $DCM_UPLOAD_LIST
+ copyOptLogsFiles
+ cat /dev/null > $DCM_UPLOAD_LIST
+ uploadDCMLogs
+ else
+ copyOptLogsFiles
+ uploadDCMLogs
+ fi
+ else
+ if [ -f $PREV_LOG_BACKUP_PATH/uploaded ]; then
+ copyOptLogsFiles
+ uploadDCMLogs
+ else
+ cd $PREV_LOG_BACKUP_PATH
+ foldertime=`ls *version.txt | cut -c 1-16`
+ if [ -z $foldertime ]; then
+ foldertime=`date +%m-%d-%y-%I-%M%p`
+ fi
+ TIMESTAMP=$foldertime-logbackup
+ PERM_LOG_PATH="/mnt/memory/dcm/$TIMESTAMP"
+ mkdir -p $PERM_LOG_PATH
+ cp * $PERM_LOG_PATH
+ copyOptLogsFiles
+ uploadDCMLogs
+ cd $PREV_LOG_BACKUP_PATH
+ touch uploaded
+ fi
+ fi
+
+ else
+ if [ "$HDD_ENABLED" = "true" ]; then
+ touch $DCM_INDEX
+ copyAllFiles
+ uploadDCMLogs
+ fi
+ fi
+ fi
+fi
+
diff --git a/recipes-rdkb/sysint-broadband/files/utils.sh b/recipes-rdkb/sysint-broadband/files/utils.sh
new file mode 100755
index 0000000..2d83cdd
--- /dev/null
+++ b/recipes-rdkb/sysint-broadband/files/utils.sh
@@ -0,0 +1,192 @@
+#!/bin/sh
+##########################################################################
+# If not stated otherwise in this file or this component's Licenses.txt
+# file the following copyright and licenses apply:
+#
+# Copyright 2016 RDK Management
+#
+# 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.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+##########################################################################
+# Scripts having common utility functions
+
+if [ -f /etc/utopia/service.d/log_env_var.sh ];then
+ source /etc/utopia/service.d/log_env_var.sh
+fi
+
+CMINTERFACE="wan0"
+WANINTERFACE="erouter0"
+
+#checkProcess()
+#{
+# ps -ef | grep $1 | grep -v grep
+#}
+
+Timestamp()
+{
+ date +"%Y-%m-%d %T"
+}
+
+# Set the name of the log file using SHA1
+#setLogFile()
+#{
+# fileName=`basename $6`
+# echo $1"_mac"$2"_dat"$3"_box"$4"_mod"$5"_"$fileName
+#}
+
+# Get the MAC address of the machine
+getMacAddressOnly()
+{
+ mac=`ifconfig $WANINTERFACE | grep HWaddr | cut -d " " -f7 | sed 's/://g'`
+ echo $mac
+}
+
+# Get the SHA1 checksum
+getSHA1()
+{
+ sha1sum $1 | cut -f1 -d" "
+
+}
+
+# IP address of the machine
+getIPAddress()
+{
+ wanIP=`ifconfig $WANINTERFACE | grep "inet addr" | grep -v inet6 | cut -f2 -d: | cut -f1 -d" "`
+ echo $wanIP
+}
+
+getCMIPAddress()
+{
+ if [ "$BOX_TYPE" = "XB6" ] || [ "$BOX_TYPE" = "TCCBR" ]; then
+ address=`dmcli eRT getv Device.X_CISCO_COM_CableModem.IPv6Address | grep string | awk '{print $5}'`
+ if [ ! "$address" ]; then
+ address=`dmcli eRT getv Device.X_CISCO_COM_CableModem.IPAddress | grep string | awk '{print $5}'`
+ fi
+ elif [ $BOX_TYPE = "XF3" ] || [ "$BOX_TYPE" = "HUB4" ]; then
+ # in PON/DSL you cant get the CM IP address, so use eRouter IP address
+ address=`ifconfig $WANINTERFACE | grep "inet addr" | grep -v inet6 | cut -f2 -d: | cut -f1 -d" "`
+ else
+ address=`ifconfig -a $CMINTERFACE | grep inet6 | tr -s " " | grep -v Link | cut -d " " -f4 | cut -d "/" -f1`
+ if [ ! "$address" ]; then
+ address=`ifconfig -a $CMINTERFACE | grep inet | grep -v inet6 | tr -s " " | cut -d ":" -f2 | cut -d " " -f1`
+ fi
+ fi
+ echo $address
+
+}
+
+getErouterIPAddress()
+{
+ if [ "$BOX_TYPE" = "XB6" ] || [ "$BOX_TYPE" = "TCCBR" ]; then
+ address=`dmcli eRT getv Device.DeviceInfo.X_COMCAST-COM_WAN_IPv6 | grep string | awk '{print $5}'`
+ if [ ! "$address" ]; then
+ address=`dmcli eRT getv Device.DeviceInfo.X_COMCAST-COM_WAN_IP | grep string | awk '{print $5}'`
+ fi
+ elif [ $BOX_TYPE = "XF3" ] || [ "$BOX_TYPE" = "HUB4" ]; then
+ # in PON/DSL you cant get the CM IP address, so use eRouter IP address
+ address=`ifconfig $WANINTERFACE | grep "inet addr" | grep -v inet6 | cut -f2 -d: | cut -f1 -d" "`
+ else
+ address=`ifconfig -a $WANINTERFACE | grep inet6 | tr -s " " | grep -v Link | cut -d " " -f4 | cut -d "/" -f1`
+ if [ ! "$address" ]; then
+ address=`ifconfig -a $WANINTERFACE | grep inet | grep -v inet6 | tr -s " " | cut -d ":" -f2 | cut -d " " -f1`
+ fi
+ fi
+ echo $address
+}
+
+processCheck()
+{
+ ps -ef | grep $1 | grep -v grep > /dev/null 2>/dev/null
+ if [ $? -ne 0 ]; then
+ echo "1"
+ else
+ echo "0"
+ fi
+}
+
+getMacAddress()
+{
+ if [ $BOX_TYPE = "XF3" ]; then
+ mac=`dmcli eRT getv Device.DPoE.Mac_address | grep value | awk '{print $5}'`
+ elif [ "$BOX_TYPE" = "XB6" ] || [ "$BOX_TYPE" = "TCCBR" ];then
+ mac=`dmcli eRT getv Device.X_CISCO_COM_CableModem.MACAddress | grep value | awk '{print $5}'`
+ elif [ "$BOX_TYPE" = "XF3" ]; then
+ mac=`ifconfig $WANINTERFACE | grep HWaddr | cut -d " " -f7`
+ else
+ mac=`ifconfig $WANINTERFACE | grep HWaddr | cut -d " " -f7`
+ fi
+ echo $mac
+}
+
+## Get eSTB mac address
+getErouterMacAddress()
+{
+ erouterMac=`ifconfig $WANINTERFACE | grep HWaddr | cut -d " " -f7`
+ echo $erouterMac
+}
+
+rebootFunc()
+{
+ #sync
+ reboot
+}
+
+# Return system uptime in seconds
+Uptime()
+{
+ cat /proc/uptime | awk '{ split($1,a,"."); print a[1]; }'
+}
+
+## Get Model No of the box
+getModel()
+{
+ if [ $BOX_TYPE = "XF3" ]; then
+ modelName=`grep ^imagename: /fss/gw/version.txt | cut -d ":" -f 2 | cut -d "_" -f 1`
+ else
+ modelName=`dmcli eRT getv Device.DeviceInfo.ModelName | grep value | awk '{print $5}'`
+ if [ "$modelName" = "" ]
+ then
+ modelName=`echo $MODEL_NUM`
+ fi
+ fi
+ echo "$modelName"
+}
+
+getFWVersion()
+{
+ # Handle imagename separator being colon or equals
+ grep imagename /version.txt | sed 's/.*[:=]//'
+}
+
+getBuildType()
+{
+ str=$(getFWVersion)
+
+ echo $str | grep -q 'VBN'
+ if [[ $? -eq 0 ]] ; then
+ echo 'vbn'
+ else
+ echo $str | grep -q 'PROD'
+ if [[ $? -eq 0 ]] ; then
+ echo 'prod'
+ else
+ echo $str | grep -q 'QA'
+ if [[ $? -eq 0 ]] ; then
+ echo 'qa'
+ else
+ echo 'dev'
+ fi
+ fi
+ fi
+}
+
+