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 # --- BEGIN COMMON.SH BOILERPLATE --- | 9 # --- BEGIN COMMON.SH BOILERPLATE --- |
10 # Load common CrOS utilities. Inside the chroot this file is installed in | 10 # Load common CrOS utilities. Inside the chroot this file is installed in |
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
298 else | 298 else |
299 echo -n "." | 299 echo -n "." |
300 fi | 300 fi |
301 | 301 |
302 sleep ${timeout} | 302 sleep ${timeout} |
303 current_state="${next_state}" | 303 current_state="${next_state}" |
304 next_state="$(get_update_var CURRENT_OP)" | 304 next_state="$(get_update_var CURRENT_OP)" |
305 done | 305 done |
306 } | 306 } |
307 | 307 |
| 308 # Pings the update_engine to see if it responds or a max timeout is reached. |
| 309 # Returns 1 if max timeout is reached. |
| 310 function wait_until_update_engine_is_ready { |
| 311 local wait_timeout=1 |
| 312 local max_timeout=60 |
| 313 local time_elapsed=0 |
| 314 while ! get_update_var CURRENT_OP > /dev/null; do |
| 315 sleep ${wait_timeout} |
| 316 time_elapsed=$(( time_elapsed + wait_timeout )) |
| 317 echo -n "." |
| 318 if [ ${time_elapsed} -gt ${max_timeout} ]; then |
| 319 return 1 |
| 320 fi |
| 321 done |
| 322 } |
308 | 323 |
309 function run_auto_update { | 324 function run_auto_update { |
310 # Truncate the update log so our log file is clean. | 325 # Truncate the update log so our log file is clean. |
311 truncate_update_log | 326 truncate_update_log |
312 | 327 |
313 local update_args="$(get_update_args "$(get_devserver_url)")" | 328 local update_args="$(get_update_args "$(get_devserver_url)")" |
| 329 info "Waiting to initiate contact with the update_engine." |
| 330 wait_until_update_engine_is_ready || die "Could not contact update engine." |
| 331 |
314 info "Starting update using args ${update_args}" | 332 info "Starting update using args ${update_args}" |
315 | 333 |
316 # Sets up a secondary thread to track the update progress. | 334 # Sets up a secondary thread to track the update progress. |
317 status_thread & | 335 status_thread & |
318 local status_thread_pid=$! | 336 local status_thread_pid=$! |
319 trap "kill ${status_thread_pid} && cleanup" EXIT | 337 trap "kill ${status_thread_pid} && cleanup" EXIT |
320 | 338 |
321 # Actually run the update. This is a blocking call. | 339 # Actually run the update. This is a blocking call. |
322 remote_sh "${UPDATER_BIN} ${update_args}" | 340 remote_sh "${UPDATER_BIN} ${update_args}" |
323 | 341 |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
438 local release_description=$(echo ${REMOTE_OUT} | cut -d '=' -f 2) | 456 local release_description=$(echo ${REMOTE_OUT} | cut -d '=' -f 2) |
439 info "Update was successful and rebooted to $release_description" | 457 info "Update was successful and rebooted to $release_description" |
440 fi | 458 fi |
441 | 459 |
442 print_time_elapsed | 460 print_time_elapsed |
443 | 461 |
444 exit 0 | 462 exit 0 |
445 } | 463 } |
446 | 464 |
447 main $@ | 465 main $@ |
OLD | NEW |