summaryrefstree
path: root/system_ext/bin/poweronlog.sh
blob: cf5c4b0410dd650139f5d78f29eeaf905ad9b371 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#!bin/sh

function logcmd()
{
    echo -e "\n"
}

function exe_cmd()
{
    logcmd "$@";
    eval $@;
}

dstdir="/blackbox/ylog/"
index=0
max=0
tarfile=0
for dir in $(ls $dstdir)
do
    [ -d $dir ] && echo $dir
    if (($dir < 999)) && (($dir >= 0))
    then
        let "index++"
        if [ $dir -ge $max ];then
            max=$dir
        fi
    else
        echo "dir is bigger 1000"
    fi
done

if [ $index -eq 4 ];then
    let "max++"
    exe_cmd "mkdir $dstdir$max"
    exe_cmd "rm -rf $dstdir$((max-4))"
    exe_cmd "dmesg -Tw > $dstdir$max/kernel.log"&
    exe_cmd "logcat -f $dstdir$max/android.log"&
else
    exe_cmd "mkdir $dstdir$index"
    exe_cmd "dmesg -Tw > $dstdir$index/kernel.log"&
    exe_cmd "logcat -f $dstdir$index/android.log"&
fi

sleep 60s

if [ $index -eq 4 ];then
    tarfile=$max
else
    tarfile=$index
fi
cd $dstdir$tarfile
tar -zcvPf log_$tarfile.tar.gz *
exe_cmd "rm -rf $dstdir$tarfile/android.log"
exe_cmd "rm -rf $dstdir$tarfile/kernel.log"

echo "poweronlog end"