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 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
234 | 234 |
235 function truncate_update_log { | 235 function truncate_update_log { |
236 remote_sh "> /var/log/update_engine.log" | 236 remote_sh "> /var/log/update_engine.log" |
237 } | 237 } |
238 | 238 |
239 function get_update_log { | 239 function get_update_log { |
240 remote_sh "cat /var/log/update_engine.log" | 240 remote_sh "cat /var/log/update_engine.log" |
241 echo "${REMOTE_OUT}" > "${FLAGS_update_log}" | 241 echo "${REMOTE_OUT}" > "${FLAGS_update_log}" |
242 } | 242 } |
243 | 243 |
244 | |
245 # Returns ${1} reported by the update client e.g. PROGRESS, CURRENT_OP. | 244 # Returns ${1} reported by the update client e.g. PROGRESS, CURRENT_OP. |
246 function get_update_var { | 245 function get_update_var { |
247 remote_sh "${UPDATER_BIN} --status 2> /dev/null | | 246 remote_sh "${UPDATER_BIN} --status 2> /dev/null | |
248 grep ${1} | | 247 grep ${1} | |
249 cut -f 2 -d =" | 248 cut -f 2 -d =" |
250 echo "${REMOTE_OUT}" | 249 echo "${REMOTE_OUT}" |
251 } | 250 } |
252 | 251 |
253 # Returns the current status / progress of the update engine. | 252 # Returns the current status / progress of the update engine. |
254 # This is expected to run in its own thread. | 253 # This is expected to run in its own thread. |
255 function status_thread { | 254 function status_thread { |
256 local timeout=5 | 255 local timeout=5 |
257 # Let update engine receive call to ping the dev server. | 256 |
258 info "Devserver handling ping. Check ${FLAGS_server_log} for more info." | 257 info "Devserver handling ping. Check ${FLAGS_server_log} for more info." |
259 sleep ${timeout} | 258 sleep ${timeout} |
260 | 259 |
261 # The devserver generates images when the update engine checks for updates. | 260 local current_state="" |
262 while [ $(get_update_var CURRENT_OP) = ${UPDATER_UPDATE_CHECK} ]; do | 261 local next_state="$(get_update_var CURRENT_OP)" |
263 echo -n "." && sleep ${timeout} | 262 |
| 263 # For current status, only print out status changes. |
| 264 # For download, show progress. |
| 265 # Finally if no status change print out .'s to keep dev informed. |
| 266 while [ "${current_state}" != "${UPDATER_NEED_REBOOT}" ] && \ |
| 267 [ "${current_state}" != "${UPDATER_IDLE}" ]; do |
| 268 if [ "${current_state}" != "${next_state}" ]; then |
| 269 info "State of updater has changed to: ${next_state}" |
| 270 elif [ "${next_state}" = "${UPDATER_DOWNLOADING}" ]; then |
| 271 echo "Download progress $(get_update_var PROGRESS)" |
| 272 else |
| 273 echo -n "." |
| 274 fi |
| 275 |
| 276 sleep ${timeout} |
| 277 current_state="${next_state}" |
| 278 next_state="$(get_update_var CURRENT_OP)" |
264 done | 279 done |
265 | |
266 info "Update generated. Update engine downloading update." | |
267 while [ $(get_update_var CURRENT_OP) = ${UPDATER_DOWNLOADING} ]; do | |
268 echo "Download progress $(get_update_var PROGRESS)" && sleep ${timeout} | |
269 done | |
270 | |
271 info "Download complete." | |
272 } | 280 } |
273 | 281 |
274 | 282 |
275 function run_auto_update { | 283 function run_auto_update { |
276 # Truncate the update log so our log file is clean. | 284 # Truncate the update log so our log file is clean. |
277 truncate_update_log | 285 truncate_update_log |
278 | 286 |
279 local update_args="$(get_update_args "$(get_devserver_url)")" | 287 local update_args="$(get_update_args "$(get_devserver_url)")" |
280 info "Starting update using args ${update_args}" | 288 info "Starting update using args ${update_args}" |
281 | 289 |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
404 local release_description=$(echo ${REMOTE_OUT} | cut -d '=' -f 2) | 412 local release_description=$(echo ${REMOTE_OUT} | cut -d '=' -f 2) |
405 info "Update was successful and rebooted to $release_description" | 413 info "Update was successful and rebooted to $release_description" |
406 fi | 414 fi |
407 | 415 |
408 print_time_elapsed | 416 print_time_elapsed |
409 | 417 |
410 exit 0 | 418 exit 0 |
411 } | 419 } |
412 | 420 |
413 main $@ | 421 main $@ |
OLD | NEW |