blob: 5a1415d1112ed086ebeaf47382a1fb223a970b34 [file] [log] [blame]
Tom Cherryd8ea11f2019-10-30 13:51:03 -07001#! /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 Ma59bd7172020-01-17 18:01:03 -08007# 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.
9umask 037
10
Tom Cherryd8ea11f2019-10-30 13:51:03 -070011has_last="false"
12for arg in "$@"; do
13 if [ "$arg" == "-L" -o "$arg" == "--last" ]; then
14 has_last="true"
15 fi
16done
17
18if [ "$has_last" == "true" ]; then
19 logcat "$@"
20fi
21
22args_without_last=()
23for arg in "$@"; do
24 if [ "$arg" != "-L" -a "$arg" != "--last" ]; then
25 ARGS+=("$arg")
26 fi
27done
28
29exec logcat "${ARGS[@]}"