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" |
11 DEFINE_string private_key "$DEFAULT_PRIVATE_KEY" \ | 11 DEFINE_string private_key "$DEFAULT_PRIVATE_KEY" \ |
12 "Private key of root account on remote host" | 12 "Private key of root account on remote host" |
| 13 DEFINE_integer ssh_port 22 \ |
| 14 "SSH port of the remote machine running Chromium OS instance" |
13 | 15 |
14 # Copies $1 to $2 on remote host | 16 # Copies $1 to $2 on remote host |
15 function remote_cp() { | 17 function remote_cp() { |
16 REMOTE_OUT=$(scp -o StrictHostKeyChecking=no -o \ | 18 REMOTE_OUT=$(scp -o StrictHostKeyChecking=no -o \ |
17 UserKnownHostsFile=$TMP_KNOWN_HOSTS $1 root@$FLAGS_remote:$2) | 19 UserKnownHostsFile=$TMP_KNOWN_HOSTS $1 root@$FLAGS_remote:$2) |
18 return ${PIPESTATUS[0]} | 20 return ${PIPESTATUS[0]} |
19 } | 21 } |
20 | 22 |
21 function remote_sh() { | 23 function remote_sh() { |
22 REMOTE_OUT=$(ssh -o StrictHostKeyChecking=no -o \ | 24 REMOTE_OUT=$(ssh -p ${FLAGS_ssh_port} -o StrictHostKeyChecking=no -o \ |
23 UserKnownHostsFile=$TMP_KNOWN_HOSTS root@$FLAGS_remote "$@") | 25 UserKnownHostsFile=$TMP_KNOWN_HOSTS root@$FLAGS_remote "$@") |
24 return ${PIPESTATUS[0]} | 26 return ${PIPESTATUS[0]} |
25 } | 27 } |
26 | 28 |
27 function remote_sh_allow_changed_host_key() { | 29 function remote_sh_allow_changed_host_key() { |
28 rm -f $TMP_KNOWN_HOSTS | 30 rm -f $TMP_KNOWN_HOSTS |
29 remote_sh "$@" | 31 remote_sh "$@" |
30 } | 32 } |
31 | 33 |
32 function set_up_remote_access() { | 34 function set_up_remote_access() { |
(...skipping 26 matching lines...) Expand all Loading... |
59 | 61 |
60 function remote_access_init() { | 62 function remote_access_init() { |
61 TMP_PRIVATE_KEY=$TMP/private_key | 63 TMP_PRIVATE_KEY=$TMP/private_key |
62 TMP_KNOWN_HOSTS=$TMP/known_hosts | 64 TMP_KNOWN_HOSTS=$TMP/known_hosts |
63 if [ -z "$FLAGS_remote" ]; then | 65 if [ -z "$FLAGS_remote" ]; then |
64 echo "Please specify --remote=<IP-or-hostname> of the Chromium OS instance" | 66 echo "Please specify --remote=<IP-or-hostname> of the Chromium OS instance" |
65 exit 1 | 67 exit 1 |
66 fi | 68 fi |
67 set_up_remote_access | 69 set_up_remote_access |
68 } | 70 } |
OLD | NEW |