Tom Cherry | d8ea11f | 2019-10-30 13:51:03 -0700 | [diff] [blame] | 1 | #! /system/bin/sh |
| 2 | |
| 3 | # This is primarily meant to be used by logpersist. This script is run as an init service, which |
| 4 | # first reads the 'last' logcat to persistent storage with `-L` then run logcat again without |
| 5 | # `-L` to read the current logcat buffers to persistent storage. |
| 6 | |
Mike Ma | 59bd717 | 2020-01-17 18:01:03 -0800 | [diff] [blame^] | 7 | # init sets the umask to 077 for forked processes. logpersist needs to create files that are group |
| 8 | # readable. So relax the umask to only disallow group wx and world rwx. |
| 9 | umask 037 |
| 10 | |
Tom Cherry | d8ea11f | 2019-10-30 13:51:03 -0700 | [diff] [blame] | 11 | has_last="false" |
| 12 | for arg in "$@"; do |
| 13 | if [ "$arg" == "-L" -o "$arg" == "--last" ]; then |
| 14 | has_last="true" |
| 15 | fi |
| 16 | done |
| 17 | |
| 18 | if [ "$has_last" == "true" ]; then |
| 19 | logcat "$@" |
| 20 | fi |
| 21 | |
| 22 | args_without_last=() |
| 23 | for arg in "$@"; do |
| 24 | if [ "$arg" != "-L" -a "$arg" != "--last" ]; then |
| 25 | ARGS+=("$arg") |
| 26 | fi |
| 27 | done |
| 28 | |
| 29 | exec logcat "${ARGS[@]}" |