| OLD | NEW |
| 1 #!/bin/sh | 1 #!/bin/sh |
| 2 | 2 |
| 3 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved. | 3 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved. |
| 4 # Use of this source code is governed by a BSD-style license that can be | 4 # Use of this source code is governed by a BSD-style license that can be |
| 5 # found in the LICENSE file. | 5 # found in the LICENSE file. |
| 6 | 6 |
| 7 set -e | 7 set -e |
| 8 | 8 |
| 9 # Product ID in crash report | 9 # Product ID in crash report |
| 10 CHROMEOS_PRODUCT=ChromeOS | 10 CHROMEOS_PRODUCT=ChromeOS |
| 11 | 11 |
| 12 # Should remove the run file when this process finishes. We don't want | 12 # Should remove the run file when this process finishes. We don't want |
| 13 # to always remove it since it may be for pre-existing crash_sender | 13 # to always remove it since it may be for pre-existing crash_sender |
| 14 # process. | 14 # process. |
| 15 CLEAN_UP_RUN_FILE=0 | 15 CLEAN_UP_RUN_FILE=0 |
| 16 | 16 |
| 17 # File whose existence implies crash reports may be sent, and whose | 17 # File whose existence implies crash reports may be sent, and whose |
| 18 # contents includes our machine's anonymized guid. | 18 # contents includes our machine's anonymized guid. |
| 19 CONSENT_ID="/home/chronos/Consent To Send Stats" | 19 CONSENT_ID="/home/chronos/Consent To Send Stats" |
| 20 | 20 |
| 21 # Path to find which is required for computing the crash rate. | 21 # Path to find which is required for computing the crash rate. |
| 22 FIND="/usr/bin/find" | 22 FIND="/usr/bin/find" |
| 23 | 23 |
| 24 # Send up to 8 crashes per day. | 24 # Maximum crashes to send per day. |
| 25 MAX_CRASH_RATE=8 | 25 MAX_CRASH_RATE=32 |
| 26 | 26 |
| 27 # File whose existence mocks crash sending. If empty we pretend the | 27 # File whose existence mocks crash sending. If empty we pretend the |
| 28 # crash sending was successful, otherwise unsuccessful. | 28 # crash sending was successful, otherwise unsuccessful. |
| 29 MOCK_CRASH_SENDING="/tmp/mock-crash-sending" | 29 MOCK_CRASH_SENDING="/tmp/mock-crash-sending" |
| 30 | 30 |
| 31 # File whose existence causes crash sending to be delayed (for testing). | 31 # File whose existence causes crash sending to be delayed (for testing). |
| 32 # Must be stateful to enable testing kernel crashes. | 32 # Must be stateful to enable testing kernel crashes. |
| 33 PAUSE_CRASH_SENDING="/var/lib/crash_sender_paused" | 33 PAUSE_CRASH_SENDING="/var/lib/crash_sender_paused" |
| 34 | 34 |
| 35 # URL to send non-official build crash reports to. | 35 # URL to send non-official build crash reports to. |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 190 -F "guid=<${CONSENT_ID}" -o "${report_id}" 2>"${curl_stderr}" | 190 -F "guid=<${CONSENT_ID}" -o "${report_id}" 2>"${curl_stderr}" |
| 191 curl_result=$? | 191 curl_result=$? |
| 192 set -e | 192 set -e |
| 193 | 193 |
| 194 if [ ${curl_result} -eq 0 ]; then | 194 if [ ${curl_result} -eq 0 ]; then |
| 195 lecho "Crash report receipt ID $(cat ${report_id})" | 195 lecho "Crash report receipt ID $(cat ${report_id})" |
| 196 else | 196 else |
| 197 lecho "Crash sending failed with: $(cat ${curl_stderr})" | 197 lecho "Crash sending failed with: $(cat ${curl_stderr})" |
| 198 fi | 198 fi |
| 199 | 199 |
| 200 rm -f "${report_id}" "${output_file}" | 200 rm -f "${report_id}" |
| 201 | 201 |
| 202 return ${curl_result} | 202 return ${curl_result} |
| 203 } | 203 } |
| 204 | 204 |
| 205 # Send all crashes from the given directory. The directory is currently | 205 # Send all crashes from the given directory. |
| 206 # expected to just contain a bunch of minidumps. | |
| 207 send_crashes() { | 206 send_crashes() { |
| 208 local dir="$1" | 207 local dir="$1" |
| 209 lecho "Considering crashes in ${dir}" | 208 lecho "Considering crashes in ${dir}" |
| 210 | 209 |
| 211 # Cycle through minidumps, most recent first. That way if we're about | 210 # Cycle through minidumps, most recent first. That way if we're about |
| 212 # to exceed the daily rate, we send the most recent minidumps. | 211 # to exceed the daily rate, we send the most recent minidumps. |
| 213 if [ ! -d "${dir}" ]; then | 212 if [ ! -d "${dir}" ]; then |
| 214 return | 213 return |
| 215 fi | 214 fi |
| 216 for file in $(ls -1t "${dir}"); do | 215 for file in $(ls -1t "${dir}"); do |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 263 TMP_DIR="$(mktemp -d /tmp/crash_sender.XXXX)" | 262 TMP_DIR="$(mktemp -d /tmp/crash_sender.XXXX)" |
| 264 | 263 |
| 265 # Send system-wide crashes | 264 # Send system-wide crashes |
| 266 send_crashes "/var/spool/crash" | 265 send_crashes "/var/spool/crash" |
| 267 | 266 |
| 268 # Send user-specific crashes | 267 # Send user-specific crashes |
| 269 send_crashes "/home/chronos/user/crash" | 268 send_crashes "/home/chronos/user/crash" |
| 270 } | 269 } |
| 271 | 270 |
| 272 main | 271 main |
| OLD | NEW |