#!/bin/dash # Copyright (c) 2012 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. # # NOTE: This script works in dash, but is not as featureful. Specifically, # dash omits readline support (history & command line editing). So we try # to run through bash if it exists, otherwise we stick to dash. All other # code should be coded to the POSIX standard and avoid bashisms. # # Please test that any changes continue to work in dash by running # '/build/$BOARD/bin/dash crosh --dash' before checking them in. # Don't allow SIGHUP to terminate crosh. This guarantees that even if the user # closes the crosh window, we make our way back up to the main loop, which gives # cleanup code in command handlers a chance to run. trap '' HUP # Do not let CTRL+C kill crosh itself. This does let the user kill commands # that are run by crosh (like `ping`). trap : INT # If it exists, use $DATA_DIR to define the $HOME location, as a first step # to entirely removing the use of $HOME. (Though HOME should be used as # fall-back when DATA_DIR is unset.) # TODO(keescook): remove $HOME entirely crbug.com/333031 if [ "${DATA_DIR+set}" = "set" ]; then export HOME="${DATA_DIR}/user" fi IS_BASH=0 try_bash() { # If dash was explicitly requested, then nothing to do. case " $* " in *" --dash "*) return 0;; esac # If we're already bash, then nothing to do. if type "history" 2>/dev/null | grep -q "shell builtin"; then IS_BASH=1 return 0 fi # Still here? Relaunch in bash. exec /bin/bash $0 "$@" } try_bash "$@" # # Please keep the help text in alphabetical order! # HELP=' exit Exit crosh. help Display this help. help_advanced Display the help for more advanced commands, mainly used for debugging. ping [-c count] [-i interval] [-n] [-s packetsize] [-W waittime] Send ICMP ECHO_REQUEST packets to a network host. If is "gw" then the next hop gateway for the default route is used. ssh [optional args...] Starts the ssh subsystem if invoked without any arguments. "ssh ", "ssh ", "ssh @", or "ssh @ " connect without entering the subsystem. ssh_forget_host Remove a host from the list of known ssh hosts. This command displays a menu of known hosts and prompts for the host to forget. top Run top. ' HELP_ADVANCED=' battery_test [] Tests battery discharge rate for given number of seconds. No argument will default to 300s test. bt_console [] Enters a Bluetooth debugging console. Optional argument specifies the capability of a pairing agent the console will provide; see the Bluetooth Core specification for valid options. chaps_debug [start|stop|] Sets the chapsd logging level. No arguments will start verbose logging. connectivity Shows connectivity status. "connectivity help" for more details experimental_storage < status | enable | disable > Enable or disable experimental storage features. ff_debug [] [--help] [--list_valid_tags] [--reset] Add and remove flimflam debugging tags. memory_test Performs extensive memory testing on the available free memory. modem [args...] Interact with the 3G modem. Run "modem help" for detailed help. modem_set_carrier carrier-name Configures the modem for the specified carrier. network_diag [--date] [--flimflam] [--link] [--show-macs] [--wifi] [--help] [--wifi-mon] A function that performs a suite of network diagnostics. Saves a copy of the output to your download directory. network_logging A function that enables a predefined set of tags useful for debugging the specified device. p2p_update [enable|disable] Enables or disables the peer-to-peer (P2P) sharing of updates over the local network. This will both, attempt to get updates from other peers in the network and share the downloaded updates with them. Run this command without arguments to see the current state. rlz < status | enable | disable > Enable or disable RLZ. rollback Attempt to rollback to the previous update cached on your system. Only available on non-stable channels and non-enterprise enrolled devices. Please note that this will powerwash your device. route [-n] [-6] Display the routing tables. set_apn [-n ] [-u ] [-p ] Set the APN to use when connecting to the network specified by . If is not specified, use the network-id of the currently registered network. set_apn -c Clear the APN to be used, so that the default APN will be used instead. set_arpgw Turn on extra network state checking to make sure the default gateway is reachable. set_cellular_ppp [-u ] [-p ] Set the PPP username and/or password for an existing cellular connection. If neither -u nor -p is provided, show the existing PPP username for the cellular connection. set_cellular_ppp -c Clear any existing PPP username and PPP password for an existing cellular connection. set_time [