blob: 05f2fd6144f187f34be262491952cd04a36542b4 [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. /etc/include.properties
21. /etc/device.properties
22#. /etc/env_setup.sh
23
24processCheck()
25{
26 count=`ps | grep $1 | grep -v grep | wc -l`
27 if [ $count == 0 ]; then
28 echo "1"
29 else
30 echo "0"
31 fi
32}
33
34
35getMacAddress()
36{
37 ifconfig -a | grep $ESTB_INTERFACE | tr -s ' ' | cut -d ' ' -f5
38}
39
40syncLog()
41{
42 cWD=`pwd`
43 syncPath=`find $TEMP_LOG_PATH -type l -exec ls -l {} \; | cut -d ">" -f2`
44 if [ "$syncPath" != "$LOG_PATH" ] && [ -d "$TEMP_LOG_PATH" ]; then
45 cd "$TEMP_LOG_PATH"
46 for file in `ls *.txt *.log`
47 do
48 cat $file >> $LOG_PATH/$file
49 cat /dev/null > $file
50 done
51 cd $cWD
52 else
53 echo "Sync Not needed, Same log folder"
54 fi
55}
56
57rebootFunc()
58{
59 if [ -f savepwrstate.sh ]; then
60 sh /savepwrstate.sh
61 sleep 1
62 fi
63 sync
64
65 if [ ! -f $PERSISTENT_PATH/.lightsleepKillSwitchEnable ]; then
66 syncLog
67
68 if [ -f $TEMP_LOG_PATH/error.log ]; then
69 cat $TEMP_LOG_PATH/error.log >> $PERSISTENT_PATH/www/error.log
70 cat /dev/null > $TEMP_LOG_PATH/error.log
71 fi
72
73 if [ -f $TEMP_LOG_PATH/.systime ]; then
74 cp $TEMP_LOG_PATH/.systime $PERSISTENT_PATH/
75 fi
76
77 if [ -f $TEMP_LOG_PATH/access.log ]; then
78 cat $TEMP_LOG_PATH/access.log >> $PERSISTENT_PATH/www/access.log
79 cat /dev/null > $TEMP_LOG_PATH/access.log
80 fi
81 fi
82
83 reboot
84}
85
86
87# Return system uptime in seconds
88Uptime()
89{
90 cat /proc/uptime | awk '{ split($1,a,"."); print a[1]; }'
91}
92
93