blob: 449f858274d44c84bd9f9db5605473feb6b3370b [file] [log] [blame]
#!/bin/dash
# Copyright (c) 2009-2010 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.
# Extra crosh commands
if [ "$(basename $0)" = "crosh-workarounds" ]; then
exec "$(dirname $0)/crosh" --workarounds
fi
# Allow users to set the autoproxy used by Chrome.
# TODO: This option should be removed once proxy settings are available in the
# UI. The value set in the default_proxy file is passed to chrome as an
# environment variable by /sbin/session_manager_setup.sh
HELP="$HELP"'
autoproxy [get|clear|set <proxy-value>]
Get, clear, or set the auto proxy setting.
'
cmd_autoproxy() {
local command="$1"
local proxy="$2"
local usage="Usage: proxy [get|clear|set <proxy-value>]"
local proxy_file="/home/chronos/var/default_proxy"
if [ -z "$command" ] || [ "$command" = "get" ] ; then
if [ ! -s "$proxy_file" ] ; then
echo "No autoproxy is set."
else
echo "Autoproxy is set to: $(cat $proxy_file)"
fi
elif [ "$command" = "clear" ] ; then
if [ -s "$proxy_file" ] ; then
echo -n "" > "$proxy_file"
fi
echo "Autoproxy cleared." \
"Please restart Chrome for the change to take effect."
elif [ "$command" = "set" ] ; then
if [ -z "$proxy" ] ; then
echo "Please provide a proxy value to set."
echo $usage
return
fi
if [ -x /usr/bin/wget ] && ! /usr/bin/wget -q -O/dev/null "$proxy" ; then
echo "WARNING: Unable to fetch the autoproxy URL given."
fi
mkdir -p $(dirname "$proxy_file")
echo "$proxy" > "$proxy_file"
echo "Autoproxy updated." \
"Please restart Chrome for the change to take effect."
else
echo "Unknown command."
echo $usage
fi
}
HELP="$HELP"'
cryptohome [--status]
Get human-readable status information from cryptohomed
'
cmd_cryptohome() {
local cryptohome="/usr/sbin/cryptohome"
if [ ! -f $cryptohome ]; then
echo "Missing $cryptohome" >&2
else
case x"$1" in
x--status|x)
$cryptohome --action=status
;;
*)
echo "Usage: cryptohome [--status]" >&2
esac
fi
}
HELP="$HELP"'
wlan_bgscan [--short secs] [--long secs] [--signal dBm] [<algorithm>]
Set/display WiFi background scan parameters.
'
cmd_wlan_bgscan() {
local options=""
while [ "$(echo "$1" | cut -c1-2)" = "--" ]; do
# Do just enough parsing to filter/map options; we
# depend on ping to handle final validation
if [ "$1" = "--short" ]; then
shift; options="$options BgscanShortInterval=$1"
elif [ "$1" = "--long" ]; then
shift; options="$options ScanInterval=$1"
elif [ "$1" = "--signal" ]; then
shift; options="$options BgscanSignalThreshold=$1"
else
echo "Unknown option: $1"
return 1
fi
shift
done
if [ -n "$1" ]; then
options="$options BgscanMethod=$1"
fi
/usr/local/lib/flimflam/test/set-bgscan $options
# NB: parameters do not take effect until next association
}