OLD | NEW |
1 #!/bin/bash | 1 #!/bin/bash |
2 | 2 |
3 # Copyright (c) 2009-2010 The Chromium OS Authors. All rights reserved. | 3 # Copyright (c) 2009-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 # Script to update an image onto a live running ChromiumOS instance. | 7 # Script to update an image onto a live running ChromiumOS instance. |
8 | 8 |
9 # Load common constants. This should be the first executable line. | 9 # Load common constants. This should be the first executable line. |
10 # The path to common.sh should be relative to your script's location. | 10 # The path to common.sh should be relative to your script's location. |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 fi | 62 fi |
63 cleanup_remote_access | 63 cleanup_remote_access |
64 rm -rf "${TMP}" | 64 rm -rf "${TMP}" |
65 } | 65 } |
66 | 66 |
67 function remote_reboot_sh { | 67 function remote_reboot_sh { |
68 rm -f "${TMP_KNOWN_HOSTS}" | 68 rm -f "${TMP_KNOWN_HOSTS}" |
69 remote_sh "$@" | 69 remote_sh "$@" |
70 } | 70 } |
71 | 71 |
| 72 # Returns the hostname of this machine. |
| 73 # It tries to find the ipaddress using ifconfig, however, it will |
| 74 # default to $HOSTNAME on failure. We try to use the ip address first as |
| 75 # some targets may have dns resolution issues trying to contact back |
| 76 # to us. |
| 77 function get_hostname { |
| 78 local hostname |
| 79 # Try to parse ifconfig for ip address |
| 80 hostname=$(ifconfig eth0 \ |
| 81 | grep 'inet addr' \ |
| 82 | sed 's/.\+inet addr:\(\S\+\).\+/\1/') || hostname=${HOSTNAME} |
| 83 echo ${hostname} |
| 84 } |
| 85 |
72 # Reinterprets path from outside the chroot for use inside. | 86 # Reinterprets path from outside the chroot for use inside. |
73 # $1 - The path to reinterpret. | 87 # $1 - The path to reinterpret. |
74 function reinterpret_path_for_chroot() { | 88 function reinterpret_path_for_chroot() { |
75 local path_abs_path=$(readlink -f "${1}") | 89 local path_abs_path=$(readlink -f "${1}") |
76 local gclient_root_abs_path=$(readlink -f "${GCLIENT_ROOT}") | 90 local gclient_root_abs_path=$(readlink -f "${GCLIENT_ROOT}") |
77 | 91 |
78 # Strip the repository root from the path. | 92 # Strip the repository root from the path. |
79 local relative_path=$(echo ${path_abs_path} \ | 93 local relative_path=$(echo ${path_abs_path} \ |
80 | sed s:${gclient_root_abs_path}/::) | 94 | sed s:${gclient_root_abs_path}/::) |
81 | 95 |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
162 update_args="--update ${update_args}" | 176 update_args="--update ${update_args}" |
163 fi | 177 fi |
164 | 178 |
165 echo "${update_args}" | 179 echo "${update_args}" |
166 } | 180 } |
167 | 181 |
168 function get_devserver_url { | 182 function get_devserver_url { |
169 local devserver_url="" | 183 local devserver_url="" |
170 if [ ${FLAGS_ignore_hostname} -eq ${FLAGS_TRUE} ]; then | 184 if [ ${FLAGS_ignore_hostname} -eq ${FLAGS_TRUE} ]; then |
171 if [ -z ${FLAGS_update_url} ]; then | 185 if [ -z ${FLAGS_update_url} ]; then |
172 devserver_url="http://$HOSTNAME:${FLAGS_devserver_port}/update" | 186 devserver_url="http://$(get_hostname):${FLAGS_devserver_port}/update" |
173 else | 187 else |
174 devserver_url="${FLAGS_update_url}" | 188 devserver_url="${FLAGS_update_url}" |
175 fi | 189 fi |
176 fi | 190 fi |
177 echo "${devserver_url}" | 191 echo "${devserver_url}" |
178 } | 192 } |
179 | 193 |
180 function truncate_update_log { | 194 function truncate_update_log { |
181 remote_sh "> /var/log/update_engine.log" | 195 remote_sh "> /var/log/update_engine.log" |
182 } | 196 } |
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
358 local release_description=$(echo ${REMOTE_OUT} | cut -d '=' -f 2) | 372 local release_description=$(echo ${REMOTE_OUT} | cut -d '=' -f 2) |
359 info "Update was successful and rebooted to $release_description" | 373 info "Update was successful and rebooted to $release_description" |
360 fi | 374 fi |
361 | 375 |
362 print_time_elapsed | 376 print_time_elapsed |
363 | 377 |
364 exit 0 | 378 exit 0 |
365 } | 379 } |
366 | 380 |
367 main $@ | 381 main $@ |
OLD | NEW |