| # Copyright 2023 The ChromiumOS Authors | |
| # Use of this source code is governed by a BSD-style license that can be | |
| # found in the LICENSE file. | |
| description "Daemon providing modem logging support" | |
| author "chromium-os-dev@chromium.org" | |
| env LOG_LEVEL=0 | |
| import LOG_LEVEL | |
| start on started modemmanager | |
| stop on starting pre-shutdown | |
| oom score -100 | |
| respawn | |
| # if the job respawns 3 times in 10 seconds, stop trying. | |
| respawn limit 3 10 | |
| # Do not respawn if we exited on purpose (e.g. service disabled). | |
| normal exit 0 | |
| pre-start script | |
| if ! crossystem "cros_debug?1"; then | |
| exit 1 | |
| fi | |
| if [ ! -f "/usr/local/usr/bin/modemloggerd" ]; then | |
| exit 1 | |
| fi | |
| case "${LOG_LEVEL}" in | |
| -3|-2|-1|0|1|2) | |
| ;; | |
| *) | |
| logger -p err -t "${UPSTART_JOB}" "Unsupported log level: ${LOG_LEVEL}" | |
| exit 1 | |
| ;; | |
| esac | |
| end script | |
| # This script is installed only in test images, thus, it isn't sandboxed. | |
| exec /usr/local/usr/bin/modemloggerd --log_level="${LOG_LEVEL}" |