| #!/bin/bash |
| |
| # Copyright 2021 The Chromium OS Authors. All rights reserved. |
| # Use of this source code is governed by a BSD-style license that can be |
| # found in the LICENSE file. |
| |
| # This is a script to control the logging behavior of the daemons writing into |
| # net.log. |
| # This is not meant to be run from crosh, but from a shell in developer mode. |
| |
| set_verbose_logging_on_reboot_all() { |
| CACHE_PATH=/var/cache/modem-utilities |
| for file_name in log_shill_verbose3 log_modemfwd_debug log_mm_debug; do |
| file_path="${CACHE_PATH}/${file_name}" |
| case "${1}" in |
| true) |
| if [ -L "${file_path}" ]; then |
| echo "Error: Symlink detected." |
| exit 1 |
| fi |
| touch "${file_path}" |
| # Keep shill-scripts as the group owner of the file in case `modem` |
| # needs to write into it later on. |
| chown :shill-scripts "${file_path}" |
| chmod 664 "${file_path}" |
| ;; |
| false) |
| rm -f "${file_path}" |
| ;; |
| *) |
| echo "'${1}' is not a valid option." |
| exit 1 |
| ;; |
| esac |
| done |
| } |
| |
| usage() { |
| echo "Usage: $(basename "$0") <command> [args...]" |
| echo " set-verbose-logging-on-reboot-all <true/false> Enable or " \ |
| "disable sticky verbose logging. ModemManager will be set to DEBUG, " \ |
| "shill to verbose level -3, and modemfwd to DEBUG. This configuration " \ |
| "will survive reboots." |
| exit 0 |
| } |
| |
| main() { |
| if ! crossystem "cros_debug?1"; then |
| echo "This script can only be executed in developer mode." |
| exit 1 |
| fi |
| [ -z "$1" ] && echo "Missing argument: ${1}" && usage |
| cmd="${1}" |
| shift |
| case "${cmd}" in |
| set-verbose-logging-on-reboot-all) |
| set_verbose_logging_on_reboot_all "$@" |
| ;; |
| --help) |
| usage |
| return 0 |
| ;; |
| *) |
| echo "Unknown option ${cmd}" |
| usage |
| exit 1 |
| ;; |
| esac |
| } |
| |
| main "$@" |