| # Copyright 2020 The ChromiumOS Authors |
| # Use of this source code is governed by a BSD-style license that can be |
| # found in the LICENSE file. |
| |
| description "Report hardware_verifier UMA statistics" |
| author "chromeos-hw-checker@google.com" |
| |
| start on started system-services |
| stop on stopping system-services |
| task |
| |
| # Allow us to be killed as we are not critical to the system. |
| oom score -100 |
| |
| # Let the process crash if it grows too much. "as" for "address space". |
| # Currently it uses about 25MB (by checking /proc/$PID/status). |
| limit as 125000000 unlimited |
| |
| script |
| RESULT_FILE="/var/cache/hardware_verifier.result" |
| TMP_FILE="$(mktemp --tmpdir hardware_verifier.XXXXXXXXXX)" |
| |
| logit() { |
| logger -t "${UPSTART_JOB}" "$*" |
| } |
| |
| exit_on_error() { |
| exit_status=0 |
| output="$("$@" 2>&1)" || exit_status="$?" |
| if [ "${exit_status}" != "0" ]; then |
| logit "$1 error: exit status: ${exit_status}, output: ${output}" |
| exit "${exit_status}" |
| fi |
| } |
| |
| hv_exit_status=0 |
| |
| # /usr/local: Verification payloads in the stateful partition |
| MINIJAIL_FLAGS_CROS_DEBUG="" |
| if crossystem cros_debug?1 ; then |
| MINIJAIL_FLAGS_CROS_DEBUG="-b /usr/local" |
| fi |
| |
| # We sleep for 50 seconds to ensure that peripheral components we are |
| # interested are properly initialized. |
| sleep 50 |
| |
| minijail0 --config /usr/share/minijail/hardware_verifier.conf \ |
| ${MINIJAIL_FLAGS_CROS_DEBUG} \ |
| -- /usr/bin/hardware_verifier \ |
| --send_to_uma \ |
| --pii \ |
| --output_format=text >"${TMP_FILE}" || hv_exit_status="$?" |
| |
| exit_on_error mv -T "${TMP_FILE}" "${RESULT_FILE}" |
| exit_on_error chmod +r "${RESULT_FILE}" |
| |
| # Log the status of hardware_verifier and exit here as this service is not |
| # expected to be a long-running service for other clients. One could refer |
| # to the logs for more detail. |
| logit "hardware_verifier exits with status ${hv_exit_status}." |
| end script |