Skip to content

Instantly share code, notes, and snippets.

@willkg
Created May 20, 2021 19:43
Show Gist options
  • Save willkg/2ddfea80d06935fe9851bc2f78a86ad8 to your computer and use it in GitHub Desktop.
Save willkg/2ddfea80d06935fe9851bc2f78a86ad8 to your computer and use it in GitHub Desktop.
Script to fetch crash annotations and minidumps from Crash Stats and put it in a directory tree.
!/bin/bash
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#
# Run on the host with crashstats-tools installed.
#
# https://pypi.org/project/crashstats-tools/
#
# Usage: ./fetch.sh [CRASHID] [CRASHID...]
#
# Or pass crash ids by stdin
#
# Or pass in no args and it'll pull 20 crashids from supersearch
#
# Set CRASHSTATS_API_TOKEN in the environment to the API token you created in
# https://crash-stats.mozilla.org/api/tokens/ that has "View Raw Dumps" and
# "View Personal Identifiable Information" permissions. You must have access to
# protected data to use this.
export $(cat .env | grep -v '^# ' | xargs)
if [ "${CRASHSTATS_API_TOKEN}" == "" ]; then
echo "You need to set the CRASHSTATS_API_TOKEN."
exit 1;
fi
if [[ $# -eq 0 ]];
then
if [ -t 0 ];
then
# No args and no stdin, so get from supersearch
echo "Getting 20 crashids from supersearch..."
CRASHIDS=$(supersearch --product=Firefox --num=20)
else
# No args, so get from stdin
echo "Getting crashids from stdin..."
set -- ${@:-$(</dev/stdin)}
CRASHIDS=$@
fi
else
# Args
echo "Getting crashids from args..."
CRASHIDS=$@
fi
fetch-data crashdata_mdsw_tmp --raw --processed --dumps $CRASHIDS
echo "Crashids:"
echo "${CRASHIDS}"
echo ""
echo "./bin/run_mdsw.sh $(echo $CRASHIDS | tr '\n' ' ')"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment