blob: 86c21382831985154bd652e2623b0bf50d7041e2 [file] [log] [blame]
developer15a43312022-04-12 11:23:23 +08001#!/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. /etc/include.properties
22. /etc/device.properties
23
24REBOOTLOG="$LOG_PATH/ocapri_log.txt"
25export PATH=$PATH:/sbin:/usr/sbin
26CORE_LOG="$LOG_PATH/core_log.txt"
27
28#This is need to set core path for yocto builds
29if [ -f /etc/os-release ]; then
30 export CORE_PATH="/var/lib/systemd/coredump/"
31fi
32
33Timestamp()
34{
35 date +"%Y-%m-%d %T"
36}
37
38resetRebootFlag()
39{
40 message=$1
41 echo `Timestamp` 'Rebooting the box'>>$REBOOTLOG;
42 echo 0 > /opt/.rebootFlag
43 echo `/bin/timestamp` ------------ $message ----------------- >> $REBOOTLOG
44}
45
46# Return system uptime in seconds
47Uptime()
48{
49 cat /proc/uptime | awk '{ split($1,a,"."); print a[1]; }'
50}
51
52# get eSTB IP address
53getIPAddress()
54{
55 if [ -f /tmp/estb_ipv6 ]; then
56 ifconfig -a $DEFAULT_ESTB_INTERFACE | grep inet6 | tr -s " " | grep -v Link | cut -d " " -f4 | cut -d "/" -f1 | head -n1
57 else
58 ifconfig -a $ESTB_INTERFACE | grep inet | grep -v inet6 | tr -s " " | cut -d ":" -f2 | cut -d " " -f1 | head -n1
59 fi
60
61}
62
63## get eSTB mac address
64getMacAddress()
65{
66 ifconfig -a $ESTB_INTERFACE | grep $ESTB_INTERFACE | tr -s ' ' | cut -d ' ' -f5
67}
68
69getMacAddressOnly()
70{
71 ifconfig -a $ESTB_INTERFACE | grep $ESTB_INTERFACE | tr -s ' ' | cut -d ' ' -f5 | sed 's/://g'
72}
73
74# argument is maximum time to wait in seconds
75waitForDumpCompletion()
76{
77 waitTime=$1
78 while [[ `dumpInProcess` == 'true' ]];
79 do
80 echo "Waiting for core dump completion." >> $CORE_LOG
81 count=`expr $count + 1`
82 sleep 1
83 if [ $count -gt $waitTime ]; then
84 echo "Core dump creation is taking more time than expected. Returning." >> $CORE_LOG
85 return
86 fi
87 done
88}
89
90dumpInProcess()
91{
92 if [[ -n "`ls $CORE_PATH/*.gz.tmp 2>/dev/null`" ]]; then
93 echo 'true'
94 else
95 echo 'false'
96 fi
97}
98
99haveCoreToUpload()
100{
101 if [[ -n "`ls $CORE_PATH/*.gz.tmp 2>/dev/null`" ]] || [[ -n "`ls $CORE_PATH/*.gz 2>/dev/null`" ]]; then
102 echo 'true'
103 else
104 echo 'false'
105 fi
106}
107