OLD | NEW |
1 #!/bin/bash | 1 #!/bin/bash |
2 | 2 |
3 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved. | 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 | 4 # Use of this source code is governed by a BSD-style license that can be |
5 # found in the LICENSE file. | 5 # found in the LICENSE file. |
6 | 6 |
7 # Run remote access test to ensure ssh access to a host is working. Exits with | 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 | 8 # a code of 0 if successful and non-zero otherwise. Used by test infrastructure |
9 # scripts. | 9 # scripts. |
10 | 10 |
11 . "$(dirname "$0")/common.sh" | 11 # --- BEGIN COMMON.SH BOILERPLATE --- |
12 . "$(dirname "$0")/remote_access.sh" | 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" |
13 | 33 |
14 function cleanup { | 34 function cleanup { |
15 cleanup_remote_access | 35 cleanup_remote_access |
16 rm -rf "${TMP}" | 36 rm -rf "${TMP}" |
17 } | 37 } |
18 | 38 |
19 function main() { | 39 function main() { |
20 cd $(dirname "$0") | 40 cd "${SCRIPTS_DIR}" |
21 | 41 |
22 FLAGS "$@" || exit 1 | 42 FLAGS "$@" || exit 1 |
23 eval set -- "${FLAGS_ARGV}" | 43 eval set -- "${FLAGS_ARGV}" |
24 | 44 |
25 set -e | 45 set -e |
26 | 46 |
27 trap cleanup EXIT | 47 trap cleanup EXIT |
28 | 48 |
29 TMP=$(mktemp -d /tmp/ssh_test.XXXX) | 49 TMP=$(mktemp -d /tmp/ssh_test.XXXX) |
30 | 50 |
31 remote_access_init | 51 remote_access_init |
32 } | 52 } |
33 | 53 |
34 main $@ | 54 main $@ |
OLD | NEW |