1 #! /system/bin/sh 2 # logpersist cat start and stop handlers 3 progname="${0##*/}" 4 case `getprop ro.build.type` in 5 userdebug|eng) ;; 6 *) echo "${progname} - Permission denied" 7 exit 1 8 ;; 9 esac 10 data=/data/misc/logd 11 property=persist.logd.logpersistd 12 service=logcatd 13 if [ X"${1}" = X"-h" -o X"${1}" = X"--help" ]; then 14 echo "${progname%.*}.cat - dump current ${service%d} logs" 15 echo "${progname%.*}.start - start ${service} service" 16 echo "${progname%.*}.stop [--clear] - stop ${service} service" 17 exit 0 18 fi 19 case ${progname} in 20 *.cat) 21 su 1036 ls "${data}" | 22 tr -d '\r' | 23 sort -ru | 24 sed "s#^#${data}/#" | 25 su 1036 xargs cat 26 ;; 27 *.start) 28 su 0 setprop ${property} ${service} 29 getprop ${property} 30 sleep 1 31 ps -t | grep "${data##*/}.*${service%d}" 32 ;; 33 *.stop) 34 su 0 stop ${service} 35 su 0 setprop ${property} "" 36 [ X"${1}" != X"-c" -a X"${1}" != X"--clear" ] || 37 ( sleep 1 ; su 1036,9998 rm -rf "${data}" ) 38 ;; 39 *) 40 echo "Unexpected command ${0##*/} ${@}" >&2 41 exit 1 42 esac 43