-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathadb_pull_logs.sh
More file actions
executable file
·58 lines (56 loc) · 1.63 KB
/
adb_pull_logs.sh
File metadata and controls
executable file
·58 lines (56 loc) · 1.63 KB
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
57
58
#!/bin/bash
set -e
set -x
password="1111"
usage() {
echo << EOF
A small script to get logcat, /var/log/*, /home/phablet/.cache/upstart/*
usage: $(basename $0)
This script assume your password on device is '1111'.
Then get logcat to logcat.log in background.
In the mean while, you can try to reproduce the issue,
Then press anykey to let script continue to get all logs
EOF
}
while [ $# -gt 0 ]
do
case "$1" in
-h | --help)
usage 0
;;
-p | --password)
echo "password=$2"
password=$2
;;
-c | --clean)
CLEAN=true
;;
*)
esac
shift
done
logs=`mktemp -d backup.XXXXX`
pushd $logs
# get logcat
adb shell '/bin/echo -e "#!/bin/sh\necho 1111" >/tmp/askpass'
adb shell "chmod +x /tmp/askpass"
[ CLEAN == "true" ] && {
adb shell "SUDO_ASKPASS=/tmp/askpass sudo -A /system/bin/logcat -c"
adb shell "SUDO_ASKPASS=/tmp/askpass sudo -A mount -o remount,rw /"
adb shell "SUDO_ASKPASS=/tmp/askpass sudo -A rm /var/log/syslog"
adb shell "SUDO_ASKPASS=/tmp/askpass sudo -A rm /var/log/upstart/*"
adb shell "SUDO_ASKPASS=/tmp/askpass sudo -A rm /home/phablet/.cache/upstart/*"
}
adb shell "SUDO_ASKPASS=/tmp/askpass sudo -A /system/bin/logcat" > logcat.log &
PID=$!
echo "getting logcat into logcat.log ...."
echo "press anykey to stop logcat and get logs under /var/log and ~/.cache/upstart ..... "
read
adb pull /var/log
adb pull /home/phablet/.cache/upstart
mkdir -p /var/crash
pushd /var/crash
adb pull /var/crash
popd
kill $PID
echo "All logs are in $logs"