blob: 5ea56fc7c81e279d5c99c890c4d4f0624ad6594d [file] [log] [blame]
#!/bin/sh
. /etc/utils.sh
register_experiment LogUpload30s
register_experiment LogUpload15s
register_experiment LogUpload5s
PLATFORM=$(cat /etc/platform)
case "$PLATFORM" in
GFSC100)
# Update this when GFSC has it's own logtype.
LOGTYPE=tmp-spacecast_log
;;
*)
LOGTYPE=default
;;
esac
FREQ="--freq 60"
if experiment LogUpload30s; then
FREQ="--freq 30"
elif experiment LogUpload15s; then
FREQ="--freq 15"
elif experiment LogUpload5s; then
FREQ="--freq 5"
fi
# On 3.3 or higher kernels we use the new uploader.
# /usr/bin/upload-crash-log2 uses the /dev/kmsg interface which was added in
# kernel 3.5. The kernel version check below is deliberately too low because
# the only device using a pre-3.5 kernel (windcharger) has backported the
# /dev/kmsg interface and is therefore compatible. When windcharger is
# upgraded past 3.5 we should change this version check back to "if >= 3.5"
KERNEL_MAJOR=$(uname -r | cut -d . -f 1)
KERNEL_MINOR=$(uname -r | cut -d . -f 2)
if [ "$KERNEL_MAJOR" -gt 3 ] || \
[ "$KERNEL_MAJOR" -eq 3 -a "$KERNEL_MINOR" -ge 3 ]; then
while :; do
# The /tmp/logs-uploaded file is handled within upload-crash-logs2.
nice -n 5 alivemonitor /tmp/loguploadcounter 75 10 180 \
upload-crash-log2 --logtype=$LOGTYPE $FREQ
# If the above program terminates we want to induce the delay here so
# it gets started again after waiting.
log-delay
done
else
while :; do
# If this file doesn't exist, you know a log upload is already in progress.
rm -f /tmp/logs-uploaded
# /tmp/logs-uploaded tells anyone waiting for us that the logs have
# finished uploading.
nice -n 5 upload-crash-log --logtype="$LOGTYPE" &&
: >/tmp/logs-uploaded
log-delay
done
fi