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