developer | 15a4331 | 2022-04-12 11:23:23 +0800 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | ########################################################################## |
| 3 | # If not stated otherwise in this file or this component's Licenses.txt |
| 4 | # file the following copyright and licenses apply: |
| 5 | # |
| 6 | # Copyright 2018 RDK Management |
| 7 | # |
| 8 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 9 | # you may not use this file except in compliance with the License. |
| 10 | # You may obtain a copy of the License at |
| 11 | # |
| 12 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 13 | # |
| 14 | # Unless required by applicable law or agreed to in writing, software |
| 15 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 16 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 17 | # See the License for the specific language governing permissions and |
| 18 | # limitations under the License. |
| 19 | ########################################################################## |
| 20 | # |
| 21 | |
| 22 | . /etc/include.properties |
| 23 | . /etc/device.properties |
| 24 | source /etc/log_timestamp.sh |
| 25 | source /lib/rdk/getpartnerid.sh |
| 26 | source /lib/rdk/getaccountid.sh |
| 27 | # Enable override only for non prod builds |
| 28 | if [ "$BUILD_TYPE" != "prod" ] && [ -f $PERSISTENT_PATH/dcm.properties ]; then |
| 29 | . $PERSISTENT_PATH/dcm.properties |
| 30 | else |
| 31 | . /etc/dcm.properties |
| 32 | fi |
| 33 | |
| 34 | if [ -f /lib/rdk/utils.sh ]; then |
| 35 | . /lib/rdk/utils.sh |
| 36 | fi |
| 37 | |
| 38 | if [ -f /etc/mount-utils/getConfigFile.sh ];then |
| 39 | . /etc/mount-utils/getConfigFile.sh |
| 40 | fi |
| 41 | SIGN_FILE="/tmp/.signedRequest_$$_`date +'%s'`" |
| 42 | DIRECT_BLOCK_TIME=86400 |
| 43 | DIRECT_BLOCK_FILENAME="/tmp/.lastdirectfail_dcm" |
| 44 | TFTP_SERVER_IP=/tmp/tftpip.txt |
| 45 | export PATH=$PATH:/usr/bin:/bin:/usr/local/bin:/sbin:/usr/local/lighttpd/sbin:/usr/local/sbin |
| 46 | export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib:/lib |
| 47 | |
| 48 | if [ -z $LOG_PATH ]; then |
| 49 | LOG_PATH="/rdklogs/logs" |
| 50 | fi |
| 51 | |
| 52 | if [ -z $PERSISTENT_PATH ]; then |
| 53 | PERSISTENT_PATH="/nvram" |
| 54 | fi |
| 55 | |
| 56 | TELEMETRY_PATH="$PERSISTENT_PATH/.telemetry" |
| 57 | DCMFLAG="/tmp/.DCMSettingsFlag" |
| 58 | DCM_LOG_FILE="$LOG_PATH/dcmscript.log" |
| 59 | TELEMETRY_INOTIFY_FOLDER="/rdklogs/logs/" |
| 60 | TELEMETRY_INOTIFY_EVENT="$TELEMETRY_INOTIFY_FOLDER/eventType.cmd" |
| 61 | DCMRESPONSE="$PERSISTENT_PATH/DCMresponse.txt" |
| 62 | TELEMETRY_TEMP_RESEND_FILE="/rdklogs/logs/.temp_resend.txt" |
| 63 | |
| 64 | PEER_COMM_ID="/tmp/elxrretyt.swr" |
| 65 | |
| 66 | TELEMETRY_PREVIOUS_LOG_COMPLETE="/tmp/.telemetry_previous_log_done" |
| 67 | TELEMETRY_PREVIOUS_LOG="/tmp/.telemetry_previous_log" |
| 68 | MAX_PREV_LOG_COMPLETE_WAIT=12 |
| 69 | |
| 70 | IDLE_TIMEOUT=30 |
| 71 | |
| 72 | # http header |
| 73 | HTTP_HEADERS='Content-Type: application/json' |
| 74 | ## RETRY DELAY in secs |
| 75 | RETRY_DELAY=60 |
| 76 | ## RETRY COUNT |
| 77 | RETRY_COUNT=3 |
| 78 | |
| 79 | echo_t "Starting execution of DCMscript.sh" |
| 80 | |
| 81 | if [ $# -ne 5 ]; then |
| 82 | echo_t "Argument does not match" |
| 83 | echo 0 > $DCMFLAG |
| 84 | exit 1 |
| 85 | fi |
| 86 | |
| 87 | . $RDK_PATH/utils.sh |
| 88 | |
| 89 | echo "`/bin/timestamp` Starting execution of DCMscript.sh" >> $LOG_PATH/dcmscript.log |
| 90 | #--------------------------------- |
| 91 | # Initialize Variables |
| 92 | #--------------------------------- |
| 93 | # URL |
| 94 | URL=$2 |
| 95 | tftp_server=$3 |
| 96 | reboot_flag=$4 |
| 97 | checkon_reboot=$5 |
| 98 | touch $TFTP_SERVER_IP |
| 99 | echo_t "URL: "$URL |
| 100 | echo_t "DCM_TFTP_SERVER: "$tftp_server >> $TFTP_SERVER_IP |
| 101 | echo_t "BOOT_FLAG: "$reboot_flag |
| 102 | echo_t "CHECK_ON_REBOOT: "$checkon_reboot |
| 103 | rm -f $TELEMETRY_TEMP_RESEND_FILE |
| 104 | |
| 105 | conn_str="Direct" |
| 106 | first_conn=useDirectRequest |
| 107 | sec_conn=useCodebigRequest |
| 108 | CodebigAvailable=0 |
| 109 | |
| 110 | |
| 111 | if [ -f "/tmp/DCMSettings.conf" ] |
| 112 | then |
| 113 | Check_URL=`grep 'urn:settings:ConfigurationServiceURL' /tmp/DCMSettings.conf | cut -d '=' -f2 | head -n 1` |
| 114 | if [ -n "$Check_URL" ] |
| 115 | then |
| 116 | URL=`grep 'urn:settings:ConfigurationServiceURL' /tmp/DCMSettings.conf | cut -d '=' -f2 | head -n 1` |
| 117 | #last_char=`echo $URL | sed -e 's/\(^.*\)\(.$\)/\2/'` |
| 118 | last_char=`echo $URL | awk '$0=$NF' FS=` |
| 119 | if [ "$last_char" != "?" ] |
| 120 | then |
| 121 | URL="$URL?" |
| 122 | fi |
| 123 | fi |
| 124 | fi |
| 125 | # File to save curl response |
| 126 | #FILENAME="$PERSISTENT_PATH/DCMresponse.txt" |
| 127 | TELE_HTTP_CODE="$PERSISTENT_PATH/telemetry_http_code" |
| 128 | # File to save http code |
| 129 | HTTP_CODE="$PERSISTENT_PATH/http_code" |
| 130 | rm -rf $HTTP_CODE |
| 131 | # Cron job file name |
| 132 | current_cron_file="$PERSISTENT_PATH/cron_file.txt" |
| 133 | # Tftpboot Server Ip |
| 134 | echo TFTP_SERVER: $tftp_server >> $LOG_PATH/dcmscript.log |
| 135 | # Timeout value |
| 136 | timeout=30 |
| 137 | default_IP=$DEFAULT_IP |
| 138 | upload_protocol='TFTP' |
| 139 | upload_httplink=$HTTP_UPLOAD_LINK |
| 140 | |
| 141 | #--------------------------------- |
| 142 | # Function declarations |
| 143 | #--------------------------------- |
| 144 | |
| 145 | ## FW version from version.txt |
| 146 | getFWVersion() |
| 147 | { |
| 148 | #cat /version.txt | grep ^imagename:PaceX1 | grep -v image |
| 149 | verStr=`cat /version.txt | grep ^imagename: | cut -d ":" -f 2` |
| 150 | echo $verStr |
| 151 | } |
| 152 | |
| 153 | ## Identifies whether it is a VBN or PROD build |
| 154 | getBuildType() |
| 155 | { |
| 156 | echo $BUILD_TYPE |
| 157 | } |
| 158 | |
| 159 | ## Get ECM mac address |
| 160 | getECMMacAddress() |
| 161 | { |
| 162 | address=`getECMMac` |
| 163 | mac=`echo $address | tr -d ' ' | tr -d '"'` |
| 164 | echo $mac |
| 165 | } |
| 166 | |
| 167 | ## Get Receiver Id |
| 168 | getReceiverId() |
| 169 | { |
| 170 | if [ -f "$PERSISTENT_PATH/www/whitebox/wbdevice.dat" ] |
| 171 | then |
| 172 | ReceiverId=`cat $PERSISTENT_PATH/www/whitebox/wbdevice.dat` |
| 173 | echo "$ReceiverId" |
| 174 | else |
| 175 | echo " " |
| 176 | fi |
| 177 | } |
| 178 | |
| 179 | ## Get Controller Id |
| 180 | getControllerId() |
| 181 | { |
| 182 | echo "2504" |
| 183 | } |
| 184 | |
| 185 | ## Get ChannelMap Id |
| 186 | getChannelMapId() |
| 187 | { |
| 188 | echo "2345" |
| 189 | } |
| 190 | |
| 191 | ## Get VOD Id |
| 192 | getVODId() |
| 193 | { |
| 194 | echo "15660" |
| 195 | } |
| 196 | |
| 197 | IsDirectBlocked() |
| 198 | { |
| 199 | ret=0 |
| 200 | if [ -f $DIRECT_BLOCK_FILENAME ]; then |
| 201 | modtime=$(($(date +%s) - $(date +%s -r $DIRECT_BLOCK_FILENAME))) |
| 202 | if [ "$modtime" -le "$DIRECT_BLOCK_TIME" ]; then |
| 203 | echo "DCM: Last direct failed blocking is still valid, preventing direct" >> $DCM_LOG_FILE |
| 204 | ret=1 |
| 205 | else |
| 206 | echo "DCM: Last direct failed blocking has expired, removing $DIRECT_BLOCK_FILENAME, allowing direct" >> $DCM_LOG_FILE |
| 207 | rm -f $DIRECT_BLOCK_FILENAME |
| 208 | ret=0 |
| 209 | fi |
| 210 | fi |
| 211 | return $ret |
| 212 | } |
| 213 | |
| 214 | # Get the configuration of codebig settings |
| 215 | get_Codebigconfig() |
| 216 | { |
| 217 | # If GetServiceUrl not available, then only direct connection available and no fallback mechanism |
| 218 | if [ -f /usr/bin/GetServiceUrl ]; then |
| 219 | CodebigAvailable=1 |
| 220 | fi |
| 221 | |
| 222 | if [ "$CodebigAvailable" -eq "1" ]; then |
| 223 | CodeBigEnable=`dmcli eRT getv Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.CodeBigFirst.Enable | grep true 2>/dev/null` |
| 224 | fi |
| 225 | if [ "$CodebigAvailable" -eq "1" ] && [ "x$CodeBigEnable" != "x" ] ; then |
| 226 | conn_str="Codebig" |
| 227 | first_conn=useCodebigRequest |
| 228 | sec_conn=useDirectRequest |
| 229 | fi |
| 230 | |
| 231 | if [ "$CodebigAvailable" -eq 1 ]; then |
| 232 | echo_t "Xconf dcm : Using $conn_str connection as the Primary" >> $DCM_LOG_FILE |
| 233 | else |
| 234 | echo_t "Xconf dcm : Only $conn_str connection is available" >> $DCM_LOG_FILE |
| 235 | fi |
| 236 | } |
| 237 | |
| 238 | # Direct connection Download function |
| 239 | useDirectRequest() |
| 240 | { |
| 241 | # Direct connection will not be tried if .lastdirectfail exists |
| 242 | IsDirectBlocked |
| 243 | if [ "$?" -eq "1" ]; then |
| 244 | return 1 |
| 245 | fi |
| 246 | count=0 |
| 247 | while [ "$count" -lt "$RETRY_COUNT" ] ; do |
| 248 | echo_t " DCM connection type DIRECT" |
| 249 | CURL_CMD="curl -w '%{http_code}\n' --tlsv1.2 --interface $EROUTER_INTERFACE $addr_type --connect-timeout $timeout -m $timeout -o \"$FILENAME\" '$HTTPS_URL$JSONSTR'" |
| 250 | echo_t "CURL_CMD: $CURL_CMD" >> $DCM_LOG_FILE |
| 251 | HTTP_CODE=`result= eval $CURL_CMD` |
| 252 | ret=$? |
| 253 | |
| 254 | sleep 2 |
| 255 | http_code=$(echo "$HTTP_CODE" | awk -F\" '{print $1}' ) |
| 256 | [ "x$http_code" != "x" ] || http_code=0 |
| 257 | echo_t "ret = $ret http_code: $http_code" >> $DCM_LOG_FILE |
| 258 | |
| 259 | # log security failure |
| 260 | case $ret in |
| 261 | 35|51|53|54|58|59|60|64|66|77|80|82|83|90|91) |
| 262 | echo_t "DCM Direct Connection Failure Attempt:$count - ret:$ret http_code:$http_code" >> $DCM_LOG_FILE |
| 263 | ;; |
| 264 | esac |
| 265 | if [ $http_code -eq 200 ]; then |
| 266 | echo_t "Direct connection success - ret:$ret http_code:$http_code" >> $DCM_LOG_FILE |
| 267 | return 0 |
| 268 | elif [ $http_code -eq 404 ]; then |
| 269 | echo "`Timestamp` Direct connection Received HTTP $http_code Response from Xconf Server. Retry logic not needed" >> $DCM_LOG_FILE |
| 270 | bypass_conn=1 |
| 271 | return 0 # Do not return 1, if retry for next conn type is not to be done |
| 272 | else |
| 273 | if [ "$ret" -eq 0 ]; then |
| 274 | echo_t "DCM Direct Connection Failure Attempt:$count - ret:$ret http_code:$http_code" >> $DCM_LOG_FILE |
| 275 | fi |
| 276 | rm -rf $DCMRESPONSE |
| 277 | fi |
| 278 | count=$((count + 1)) |
| 279 | sleep $RETRY_DELAY |
| 280 | done |
| 281 | echo_t "DCM :Retries for Direct connection exceeded " >> $DCM_LOG_FILE |
| 282 | [ "$CodebigAvailable" -ne "1" ] || [ -f $DIRECT_BLOCK_FILENAME ] || touch $DIRECT_BLOCK_FILENAME |
| 283 | return 1 |
| 284 | } |
| 285 | |
| 286 | # Codebig connection Download function |
| 287 | useCodebigRequest() |
| 288 | { |
| 289 | # Do not try Codebig if CodebigAvailable != 1 (GetServiceUrl not there) |
| 290 | if [ "$CodebigAvailable" -eq "0" ] ; then |
| 291 | echo "DCM : Only direct connection Available" >> $DCM_LOG_FILE |
| 292 | return 1 |
| 293 | fi |
| 294 | count=0 |
| 295 | while [ "$count" -lt "$RETRY_COUNT" ] ; do |
| 296 | SIGN_CMD="GetServiceUrl 3 \"$JSONSTR\"" |
| 297 | eval $SIGN_CMD > $SIGN_FILE |
| 298 | CB_SIGNED_REQUEST=`cat $SIGN_FILE` |
| 299 | rm -f $SIGN_FILE |
| 300 | CURL_CMD="curl -w '%{http_code}\n' --tlsv1.2 --interface $EROUTER_INTERFACE $addr_type --connect-timeout $timeout -m $timeout -o \"$FILENAME\" \"$CB_SIGNED_REQUEST\"" |
| 301 | echo_t " DCM connection type CODEBIG at `echo "$CURL_CMD" | sed -ne 's#.*\(https:.*\)?.*#\1#p'`" >> $DCM_LOG_FILE |
| 302 | echo_t "CURL_CMD: `echo "$CURL_CMD" | sed -ne 's#oauth_consumer_key=.*#<hidden>#p'`" >> $DCM_LOG_FILE |
| 303 | HTTP_CODE=`result= eval $CURL_CMD` |
| 304 | curlret=$? |
| 305 | http_code=$(echo "$HTTP_CODE" | awk -F\" '{print $1}' ) |
| 306 | [ "x$http_code" != "x" ] || http_code=0 |
| 307 | echo_t "ret = $curlret http_code: $http_code" >> $DCM_LOG_FILE |
| 308 | |
| 309 | # log security failure |
| 310 | case $curlret in |
| 311 | 35|51|53|54|58|59|60|64|66|77|80|82|83|90|91) |
| 312 | echo_t "DCM Codebig Connection Failure Attempt: $count - ret:$curlret http_code:$http_code" >> $DCM_LOG_FILE |
| 313 | ;; |
| 314 | esac |
| 315 | if [ "$http_code" -eq 200 ]; then |
| 316 | echo_t "Codebig connection success - ret:$curlret http_code:$http_code" >> $DCM_LOG_FILE |
| 317 | return 0 |
| 318 | elif [ "$http_code" -eq 404 ]; then |
| 319 | echo_t "DCM Codebig connection Received HTTP $http_code Response from Xconf Server. Retry logic not needed" >> $DCM_LOG_FILE |
| 320 | bypass_conn=1 |
| 321 | return 0 # Do not return 1, if retry for next conn type is not to be done |
| 322 | else |
| 323 | if [ "$curlret" -eq 0 ]; then |
| 324 | echo_t "DCM Codebig Connection Failure Attempt:$count - ret:$curlret http_code:$http_code" >> $DCM_LOG_FILE |
| 325 | fi |
| 326 | rm -rf $DCMRESPONSE |
| 327 | fi |
| 328 | count=$((count + 1)) |
| 329 | sleep $RETRY_DELAY |
| 330 | done |
| 331 | echo_t "Retries for Codebig connection exceeded " >> $DCM_LOG_FILE |
| 332 | return 1 |
| 333 | } |
| 334 | |
| 335 | sendHttpRequestToServer() |
| 336 | { |
| 337 | resp=0 |
| 338 | FILENAME=$1 |
| 339 | URL=$2 |
| 340 | echo "filename--args in sendHttpRequestToServer-------"$FILENAME |
| 341 | echo "url---args in sendHttpRequestToServer------"$URL |
| 342 | |
| 343 | estbMacAddress=`ifconfig erouter0 | grep HWaddr | cut -c39-55` |
| 344 | JSONSTR=$estbMacAddress |
| 345 | CURL_CMD="curl -w "%{http_code}" '$URL?estbMacAddress=$JSONSTR&model=$MODEL_NAME' -o $DCMRESPONSE >> /tmp/telehttpcode.txt " |
| 346 | echo "------CURL_CMD:"$CURL_CMD |
| 347 | |
| 348 | # Execute curl command |
| 349 | result= eval $CURL_CMD > $TELE_HTTP_CODE |
| 350 | #echo "Processing $FILENAME" |
| 351 | sleep $timeout |
| 352 | echo "sleep for :------------------"$timeout |
| 353 | # Get the http_code |
| 354 | http_code=$(awk -F\" '{print $1}' /tmp/telehttpcode.txt) |
| 355 | #start of pokuru |
| 356 | |
| 357 | if [ "$http_code" != "200" ]; then |
| 358 | #Added for retry - START |
| 359 | rm -rf /tmp/telehttpcode.txt |
| 360 | rm -rf $DCMRESPONSE |
| 361 | |
| 362 | xconfRetryCount=0 |
| 363 | while [ $xconfRetryCount -lt 2 ] |
| 364 | do |
| 365 | echo "Trying to Retry connection with XCONF server..." |
| 366 | |
| 367 | CURL_CMD="curl -w "%{http_code}" '$URL?estbMacAddress=$JSONSTR&model=$MODEL_NAME' -o $DCMRESPONSE >> /tmp/telehttpcode.txt " |
| 368 | |
| 369 | result= eval $CURL_CMD |
| 370 | |
| 371 | http_code_retry=$(awk -F\" '{print $1}' /tmp/telehttpcode.txt) |
| 372 | |
| 373 | if [ "$http_code_retry" != "200" ]; then |
| 374 | echo "Error in establishing communication with xconf server." |
| 375 | if [ $xconfRetryCount -ne 0 ]; then sleep 30; fi |
| 376 | rm -f /tmp/telehttpcode.txt |
| 377 | rm -rf $DCMRESPONSE |
| 378 | |
| 379 | else |
| 380 | echo "After retries...No error in curl command and curl http code is:"$http_code_retry |
| 381 | resp=0 |
| 382 | break |
| 383 | fi |
| 384 | |
| 385 | xconfRetryCount=`expr $xconfRetryCount + 1` |
| 386 | done |
| 387 | echo "xconf retry count is:"$xconfRetryCount |
| 388 | if [ $xconfRetryCount -eq 2 ]; then |
| 389 | echo "No xconf comm ,exiting script" |
| 390 | startdcmEnd=`ps -ef | grep -i "StartDCM.sh" | head -n 1` |
| 391 | kill -9 $startdcmEnd |
| 392 | exit 0 |
| 393 | fi |
| 394 | #Added for retry - END |
| 395 | #echo "Error from cloud exiting,check in upcoming reboot-------------" |
| 396 | #exit 0 |
| 397 | else |
| 398 | echo "No error in curl command and curl http code is:"$http_code |
| 399 | fi |
| 400 | #end of pokuru |
| 401 | echo "----------ret http_code:"$http_code |
| 402 | echo "----------ret http_code_retry:"$http_code_retry |
| 403 | |
| 404 | if [ $http_code -ne 200 ] ; then |
| 405 | if [ $http_code_retry -ne 200 ]; then |
| 406 | echo "curl HTTP request failed http_code :"$http_code |
| 407 | echo "curl HTTP request failed http_code_retry :"$http_code_retry |
| 408 | #pokuru rm -rf /tmp/DCMSettings.conf |
| 409 | resp=1 |
| 410 | fi |
| 411 | else |
| 412 | echo "curl HTTP request success. Processing response.." |
| 413 | resp=0 |
| 414 | fi |
| 415 | echo "----------res:"$resp |
| 416 | return $resp |
| 417 | } |
| 418 | |
| 419 | dropbearRecovery() |
| 420 | { |
| 421 | dropbearPid=`ps | grep -i dropbear | grep "$ARM_INTERFACE_IP" | grep -v grep` |
| 422 | if [ -z "$dropbearPid" ]; then |
| 423 | echo "Dropbear instance is missing ... Recovering dropbear !!! " >> $DCM_LOG_FILE |
| 424 | DROPBEAR_PARAMS_1="/tmp/.dropbear/dropcfg1$$" |
| 425 | DROPBEAR_PARAMS_2="/tmp/.dropbear/dropcfg2$$" |
| 426 | if [ ! -d '/tmp/.dropbear' ]; then |
| 427 | echo "wan_ssh.sh: need to create dropbear dir !!! " >> $DCM_LOG_FILE |
| 428 | mkdir -p /tmp/.dropbear |
| 429 | fi |
| 430 | echo "wan_ssh.sh: need to create dropbear files !!! " >> $DCM_LOG_FILE |
| 431 | getConfigFile $DROPBEAR_PARAMS_1 |
| 432 | getConfigFile $DROPBEAR_PARAMS_2 |
| 433 | dropbear -r $DROPBEAR_PARAMS_1 -r $DROPBEAR_PARAMS_2 -E -s -p $ARM_INTERFACE_IP:22 & |
| 434 | sleep 2 |
| 435 | fi |
| 436 | rm -rf /tmp/.dropbear/* |
| 437 | } |
| 438 | |
| 439 | # Safe wait for IP acquisition |
| 440 | loop=1 |
| 441 | counter=0 |
| 442 | while [ $loop -eq 1 ] |
| 443 | do |
| 444 | estbIp=`ifconfig erouter0 | grep -i inet | cut -d ":" -f2 | cut -d " " -f1` |
| 445 | if [ "X$estbIp" == "X" ]; then |
| 446 | echo_t "waiting for IP" |
| 447 | sleep 2 |
| 448 | let counter++ |
| 449 | else |
| 450 | echo "got IP in erouter0-------------------" |
| 451 | loop=0 |
| 452 | fi |
| 453 | done |
| 454 | |
| 455 | ret=1 |
| 456 | if [ "$estbIp" == "$default_IP" ] ; then |
| 457 | ret=0 |
| 458 | fi |
| 459 | if [ $checkon_reboot -eq 1 ]; then |
| 460 | echo "call sendHttpRequestToServer-------------------" |
| 461 | sendHttpRequestToServer $DCMRESPONSE $URL |
| 462 | ret=$? |
| 463 | echo_t "sendHttpRequestToServer returned "$ret |
| 464 | else |
| 465 | ret=0 |
| 466 | echo_t "sendHttpRequestToServer has not executed since the value of 'checkon_reboot' is $checkon_reboot" >> $DCM_LOG_FILE |
| 467 | fi |
| 468 | |
| 469 | echo "after sendHttpRequestToServer-----sleep for 5 sec-------------" |
| 470 | sleep 5 |
| 471 | |
| 472 | |
| 473 | if [ $ret -ne 0 ]; then |
| 474 | echo_t "Processing response failed." >> $DCM_LOG_FILE |
| 475 | rm -rf $FILENAME |
| 476 | echo_t "count = $count. Sleeping $RETRY_DELAY seconds ..." >> $DCM_LOG_FILE |
| 477 | exit 1 |
| 478 | fi |
| 479 | |
| 480 | if [ "x$DCA_MULTI_CORE_SUPPORTED" == "xyes" ]; then |
| 481 | dropbearRecovery |
| 482 | |
| 483 | isPeriodicFWCheckEnabled=`syscfg get PeriodicFWCheck_Enable` |
| 484 | if [ "$isPeriodicFirmwareEnabled" == "true" ]; then |
| 485 | echo "XCONF SCRIPT : Calling XCONF Client firmwareSched for the updated time" |
| 486 | sh /etc/firmwareSched.sh & |
| 487 | fi |
| 488 | |
| 489 | isAxb6Device="no" |
| 490 | if [ "$MODEL_NUM" == "TG3482G" ]; then |
| 491 | isNvram2Mounted=`grep nvram2 /proc/mounts` |
| 492 | if [ "$isNvram2Mounted" == "" -a -d "/nvram/logs" ]; then |
| 493 | isAxb6Device="yes" |
| 494 | fi |
| 495 | fi |
| 496 | |
| 497 | if [ "x$isAxb6Device" == "xno" ]; then |
| 498 | # wait for telemetry previous log to be copied to atom |
| 499 | loop=1 |
| 500 | while [ $loop -eq 1 ] |
| 501 | do |
| 502 | if [ ! -f $TELEMETRY_PREVIOUS_LOG ]; then |
| 503 | echo_t "waiting for previous log file" >> $DCM_LOG_FILE |
| 504 | sleep 10 |
| 505 | else |
| 506 | echo_t "scp previous logs from arm to atom done, so breaking loop" >> $DCM_LOG_FILE |
| 507 | loop=0 |
| 508 | fi |
| 509 | done |
| 510 | |
| 511 | ### Trigger an inotify event on ATOM |
| 512 | echo "Telemetry run for previous log trigger to atom" >> $DCM_LOG_FILE |
| 513 | GetConfigFile $PEER_COMM_ID |
| 514 | ssh -I $IDLE_TIMEOUT -i $PEER_COMM_ID root@$ATOM_INTERFACE_IP "/bin/echo 'xconf_update' > $TELEMETRY_INOTIFY_EVENT" > /dev/null 2>&1 |
| 515 | rm -f $PEER_COMM_ID |
| 516 | |
| 517 | fi |
| 518 | |
| 519 | # wait for telemetry previous log to be completed upto 2 mins . Avoid indefenite loops |
| 520 | loop=1 |
| 521 | count=0 |
| 522 | while [ "$loop" = "1" ] |
| 523 | do |
| 524 | if [ ! -f $TELEMETRY_PREVIOUS_LOG_COMPLETE ]; then |
| 525 | echo_t "waiting for previous log done file" >> $DCM_LOG_FILE |
| 526 | sleep 10 |
| 527 | if [ $count -ge $MAX_PREV_LOG_COMPLETE_WAIT ]; then |
| 528 | echo_t "Max wait for previous log done file reached. Proceeding with new config from xconf " >> $DCM_LOG_FILE |
| 529 | loop=0 |
| 530 | fi |
| 531 | else |
| 532 | echo_t "Telemetry run for previous log done, so breaking loop" >> $DCM_LOG_FILE |
| 533 | loop=0 |
| 534 | fi |
| 535 | count=`expr $count + 1` |
| 536 | done |
| 537 | |
| 538 | GetConfigFile $PEER_COMM_ID |
| 539 | scp -i $PEER_COMM_ID $DCMRESPONSE root@$ATOM_INTERFACE_IP:$PERSISTENT_PATH > /dev/null 2>&1 |
| 540 | if [ $? -ne 0 ]; then |
| 541 | scp -i $PEER_COMM_ID $DCMRESPONSE root@$ATOM_INTERFACE_IP:$PERSISTENT_PATH > /dev/null 2>&1 |
| 542 | fi |
| 543 | echo "Signal atom to pick the XCONF config data $DCMRESPONSE and schedule telemetry !!! " >> $DCM_LOG_FILE |
| 544 | ## Trigger an inotify event on ATOM |
| 545 | ssh -I $IDLE_TIMEOUT -i $PEER_COMM_ID root@$ATOM_INTERFACE_IP "/bin/echo 'xconf_update' > $TELEMETRY_INOTIFY_EVENT" > /dev/null 2>&1 |
| 546 | rm -f $PEER_COMM_ID |
| 547 | else |
| 548 | echo "opensource platforms----------------------------" |
| 549 | |
| 550 | isPeriodicFWCheckEnabled=`syscfg get PeriodicFWCheck_Enable` |
| 551 | if [ "$isPeriodicFirmwareEnabled" == "true" ]; then |
| 552 | echo "XCONF SCRIPT : Calling XCONF Client firmwareSched for the updated time" |
| 553 | sh /etc/firmwareSched.sh & |
| 554 | fi |
| 555 | |
| 556 | # wait for telemetry previous log to be completed |
| 557 | loop=1 |
| 558 | count=0 |
| 559 | while [ "$loop" = "1" ] |
| 560 | do |
| 561 | echo "TELEMETRY_PREVIOUS_LOG_COMPLETE--------------"$TELEMETRY_PREVIOUS_LOG_COMPLETE |
| 562 | if [ ! -f $TELEMETRY_PREVIOUS_LOG_COMPLETE ]; then |
| 563 | echo_t "waiting for previous log done file" |
| 564 | sleep 10 |
| 565 | if [ $count -ge $MAX_PREV_LOG_COMPLETE_WAIT ]; then |
| 566 | echo_t "Max wait for previous log done file reached. Proceeding with new config from xconf " |
| 567 | loop=0 |
| 568 | fi |
| 569 | else |
| 570 | echo_t "Telemetry run for previous log done, so breaking loop" |
| 571 | loop=0 |
| 572 | fi |
| 573 | count=`expr $count + 1` |
| 574 | done |
| 575 | echo "before calling dca_utility start of TELEMETRY LOGIC-----------------" |
| 576 | sh /lib/rdk/dca_utility.sh 1 & |
| 577 | fi |