OLD | NEW |
1 # Copyright (c) 2009 The Chromium OS Authors. All rights reserved. | 1 # Copyright (c) 2009 The Chromium OS Authors. All rights reserved. |
2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 # Library for setting up remote access and running remote commands. | 5 # Library for setting up remote access and running remote commands. |
6 | 6 |
7 DEFAULT_PRIVATE_KEY="${GCLIENT_ROOT}/src/scripts/mod_for_test_scripts/\ | 7 DEFAULT_PRIVATE_KEY="${GCLIENT_ROOT}/src/scripts/mod_for_test_scripts/\ |
8 ssh_keys/testing_rsa" | 8 ssh_keys/testing_rsa" |
9 | 9 |
10 DEFINE_string remote "" "remote hostname/IP of running Chromium OS instance" | 10 DEFINE_string remote "" "remote hostname/IP of running Chromium OS instance" |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 [ -n "${FLAGS_board}" ] && return | 61 [ -n "${FLAGS_board}" ] && return |
62 remote_sh grep CHROMEOS_RELEASE_BOARD /etc/lsb-release | 62 remote_sh grep CHROMEOS_RELEASE_BOARD /etc/lsb-release |
63 FLAGS_board=$(echo "${REMOTE_OUT}" | cut -d '=' -f 2) | 63 FLAGS_board=$(echo "${REMOTE_OUT}" | cut -d '=' -f 2) |
64 if [ -z "${FLAGS_board}" ]; then | 64 if [ -z "${FLAGS_board}" ]; then |
65 error "Board required" | 65 error "Board required" |
66 exit 1 | 66 exit 1 |
67 fi | 67 fi |
68 info "Target reports board is ${FLAGS_board}" | 68 info "Target reports board is ${FLAGS_board}" |
69 } | 69 } |
70 | 70 |
| 71 function remote_reboot { |
| 72 info "Rebooting." |
| 73 remote_sh "touch /tmp/awaiting_reboot; reboot" |
| 74 local output_file |
| 75 output_file="${TMP}/output" |
| 76 |
| 77 while true; do |
| 78 REMOTE_OUT="" |
| 79 # This may fail while the machine is down so generate output and a |
| 80 # boolean result to distinguish between down/timeout and real failure |
| 81 ! remote_sh_allow_changed_host_key \ |
| 82 "echo 0; [ -e /tmp/awaiting_reboot ] && echo '1'; true" |
| 83 echo "${REMOTE_OUT}" > "${output_file}" |
| 84 if grep -q "0" "${output_file}"; then |
| 85 if grep -q "1" "${output_file}"; then |
| 86 info "Not yet rebooted" |
| 87 else |
| 88 info "Rebooted and responding" |
| 89 break |
| 90 fi |
| 91 fi |
| 92 sleep .5 |
| 93 done |
| 94 } |
| 95 |
71 function cleanup_remote_access() { | 96 function cleanup_remote_access() { |
72 # Call this function from the exit trap of the main script. | 97 # Call this function from the exit trap of the main script. |
73 # Iff we started ssh-agent, be nice and clean it up. | 98 # Iff we started ssh-agent, be nice and clean it up. |
74 # Note, only works if called from the main script - no subshells. | 99 # Note, only works if called from the main script - no subshells. |
75 if [[ 1 -eq ${OWN_SSH_AGENT} ]] | 100 if [[ 1 -eq ${OWN_SSH_AGENT} ]] |
76 then | 101 then |
77 kill ${SSH_AGENT_PID} 2>/dev/null | 102 kill ${SSH_AGENT_PID} 2>/dev/null |
78 unset SSH_AGENT_PID SSH_AUTH_SOCK | 103 unset SSH_AGENT_PID SSH_AUTH_SOCK |
79 fi | 104 fi |
80 } | 105 } |
81 | 106 |
82 function remote_access_init() { | 107 function remote_access_init() { |
83 TMP_PRIVATE_KEY=$TMP/private_key | 108 TMP_PRIVATE_KEY=$TMP/private_key |
84 TMP_KNOWN_HOSTS=$TMP/known_hosts | 109 TMP_KNOWN_HOSTS=$TMP/known_hosts |
85 if [ -z "$FLAGS_remote" ]; then | 110 if [ -z "$FLAGS_remote" ]; then |
86 echo "Please specify --remote=<IP-or-hostname> of the Chromium OS instance" | 111 echo "Please specify --remote=<IP-or-hostname> of the Chromium OS instance" |
87 exit 1 | 112 exit 1 |
88 fi | 113 fi |
89 set_up_remote_access | 114 set_up_remote_access |
90 } | 115 } |
OLD | NEW |