| 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 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 284 local update_status="$(get_update_var CURRENT_OP)" | 284 local update_status="$(get_update_var CURRENT_OP)" |
| 285 if [ "${update_status}" = ${UPDATER_NEED_REBOOT} ]; then | 285 if [ "${update_status}" = ${UPDATER_NEED_REBOOT} ]; then |
| 286 info "Autoupdate was successful." | 286 info "Autoupdate was successful." |
| 287 return 0 | 287 return 0 |
| 288 else | 288 else |
| 289 warn "Autoupdate was unsuccessful. Status returned was ${update_status}." | 289 warn "Autoupdate was unsuccessful. Status returned was ${update_status}." |
| 290 return 1 | 290 return 1 |
| 291 fi | 291 fi |
| 292 } | 292 } |
| 293 | 293 |
| 294 function remote_reboot { | |
| 295 info "Rebooting." | |
| 296 remote_sh "touch /tmp/awaiting_reboot; reboot" | |
| 297 local output_file | |
| 298 output_file="${TMP}/output" | |
| 299 | |
| 300 while true; do | |
| 301 REMOTE_OUT="" | |
| 302 # This may fail while the machine is down so generate output and a | |
| 303 # boolean result to distinguish between down/timeout and real failure | |
| 304 ! remote_sh_allow_changed_host_key \ | |
| 305 "echo 0; [ -e /tmp/awaiting_reboot ] && echo '1'; true" | |
| 306 echo "${REMOTE_OUT}" > "${output_file}" | |
| 307 if grep -q "0" "${output_file}"; then | |
| 308 if grep -q "1" "${output_file}"; then | |
| 309 info "Not yet rebooted" | |
| 310 else | |
| 311 info "Rebooted and responding" | |
| 312 break | |
| 313 fi | |
| 314 fi | |
| 315 sleep .5 | |
| 316 done | |
| 317 } | |
| 318 | |
| 319 function verify_image { | 294 function verify_image { |
| 320 info "Verifying image." | 295 info "Verifying image." |
| 321 "${SCRIPTS_DIR}/mount_gpt_image.sh" --from "$(dirname ${IMAGE_PATH})" \ | 296 "${SCRIPTS_DIR}/mount_gpt_image.sh" --from "$(dirname ${IMAGE_PATH})" \ |
| 322 --image "$(basename ${IMAGE_PATH})" \ | 297 --image "$(basename ${IMAGE_PATH})" \ |
| 323 --read_only | 298 --read_only |
| 324 | 299 |
| 325 local lsb_release=$(cat /tmp/m/etc/lsb-release) | 300 local lsb_release=$(cat /tmp/m/etc/lsb-release) |
| 326 info "Verifying image with release:" | 301 info "Verifying image with release:" |
| 327 echo ${lsb_release} | 302 echo ${lsb_release} |
| 328 | 303 |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 402 local release_description=$(echo ${REMOTE_OUT} | cut -d '=' -f 2) | 377 local release_description=$(echo ${REMOTE_OUT} | cut -d '=' -f 2) |
| 403 info "Update was successful and rebooted to $release_description" | 378 info "Update was successful and rebooted to $release_description" |
| 404 fi | 379 fi |
| 405 | 380 |
| 406 print_time_elapsed | 381 print_time_elapsed |
| 407 | 382 |
| 408 exit 0 | 383 exit 0 |
| 409 } | 384 } |
| 410 | 385 |
| 411 main $@ | 386 main $@ |
| OLD | NEW |