Chris Sosa | e65e500 | 2011-03-25 15:39:30 -0700 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | |
| 3 | # Copyright (c) 2010 The Chromium OS Authors. All rights reserved. |
| 4 | # Use of this source code is governed by a BSD-style license that can be |
| 5 | # found in the LICENSE file. |
| 6 | |
| 7 | # Run remote access test to ensure ssh access to a host is working. Exits with |
| 8 | # a code of 0 if successful and non-zero otherwise. Used by test infrastructure |
| 9 | # scripts. |
| 10 | |
| 11 | # --- BEGIN COMMON.SH BOILERPLATE --- |
| 12 | # Load common CrOS utilities. Inside the chroot this file is installed in |
| 13 | # /usr/lib/crosutils. Outside the chroot we find it relative to the script's |
| 14 | # location. |
| 15 | find_common_sh() { |
| 16 | local common_paths=(/usr/lib/crosutils $(dirname "$(readlink -f "$0")")) |
| 17 | local path |
| 18 | |
| 19 | SCRIPT_ROOT= |
| 20 | for path in "${common_paths[@]}"; do |
| 21 | if [ -r "${path}/common.sh" ]; then |
| 22 | SCRIPT_ROOT=${path} |
| 23 | break |
| 24 | fi |
| 25 | done |
| 26 | } |
| 27 | |
| 28 | find_common_sh |
| 29 | . "${SCRIPT_ROOT}/common.sh" || (echo "Unable to load common.sh" && exit 1) |
| 30 | # --- END COMMON.SH BOILERPLATE --- |
| 31 | |
| 32 | . "${SCRIPT_ROOT}/remote_access.sh" || die "Unable to load remote_access.sh" |
| 33 | |
| 34 | function cleanup { |
| 35 | cleanup_remote_access |
| 36 | rm -rf "${TMP}" |
| 37 | } |
| 38 | |
| 39 | function main() { |
| 40 | cd "${SCRIPTS_DIR}" |
| 41 | |
| 42 | FLAGS "$@" || exit 1 |
| 43 | eval set -- "${FLAGS_ARGV}" |
| 44 | |
| 45 | set -e |
| 46 | |
| 47 | trap cleanup EXIT |
| 48 | |
| 49 | TMP=$(mktemp -d /tmp/ssh_test.XXXX) |
| 50 | |
| 51 | remote_access_init |
| 52 | } |
| 53 | |
| 54 | main $@ |