Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(336)

Side by Side Diff: image_to_live.sh

Issue 6594089: Wait until we can initiate contact with the update engine before starting update. (Closed) Base URL: http://git.chromium.org/git/crosutils.git@master
Patch Set: Created 9 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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 $@
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698