Files
kdumpst/submit_report.sh
Guilherme G. Piccoli a1f89d341f Add pstore-RAM support and fix comments indentation
Check README.MD and /etc/default/kdump for instructions on
pstore usage - should be simple, it's automatically configured.

Notice that we expect all units to have the same e820 memory
map, hence to have the RAM buffer available. This point should
be better clarified by the team working with firmware.

Also, the package now enables the kdump systemd service
automatically, in a post-installer hook.

Signed-off-by: Guilherme G. Piccoli <gpiccoli@igalia.com>
2023-03-31 15:34:42 -03:00

54 lines
1.4 KiB
Bash
Executable File

#!/bin/sh
#
# SPDX-License-Identifier: LGPL-2.1+
#
# Copyright (c) 2021 Valve.
#
# This is currently a dummy script for kdump, but collects and clears
# pstore saved logs for now. It aims, in the future, to submit error/crash
# reports to Valve servers in order to do a post-mortem analysis.
# This is part of SteamOS kdump - it is invoked by systemd on boot time
# and should always exit graciously to avoid breaking the boot services.
#
if [ ! -f "/etc/default/kdump" ]; then
exit 0
fi
. /etc/default/kdump
# Yeah, we assume pstore is mounted by default, in this location;
# if not, we get a 0 and don't loop.
PSTORE_CNT=$(find /sys/fs/pstore/* 2>/dev/null | grep -c ramoops)
if [ ${PSTORE_CNT} -eq 0 ]; then
exit 0
fi
# We do some validation to be sure KDUMP_MNT pointed path is valid...
KDUMP_CRASH_FOLDER="$(cat ${KDUMP_MNT})"
rm -f ${KDUMP_MNT}
if [ ! -d "${KDUMP_CRASH_FOLDER}" ]; then
exit 0
fi
# If valid, then dump the pstore logs in the crash subfolder.
KDUMP_CRASH_FOLDER="${KDUMP_CRASH_FOLDER}/crash"
mkdir -p ${KDUMP_CRASH_FOLDER}
PSTORE_TSTAMP=$(date +"%Y%m%d%H%M")
LOOP_CNT=0
while [ ${PSTORE_CNT} -gt 0 ];
do
PSTORE_FILE="$(find /sys/fs/pstore/* | grep ramoops | sort | head -n1)"
SAVED_FILE="${KDUMP_CRASH_FOLDER}/dmesg-pstore.${PSTORE_TSTAMP}-${LOOP_CNT}"
cat ${PSTORE_FILE} > ${SAVED_FILE}
sync ${SAVED_FILE}
rm -f ${PSTORE_FILE}
PSTORE_CNT=$((${PSTORE_CNT} - 1))
LOOP_CNT=$((${LOOP_CNT} + 1))
done
exit 0