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 while [ "${current_state}" != "${UPDATER_NEED_REBOOT}" ] && \ | |
264 [ "${current_state}" != "${UPDATER_IDLE}" ]; do | |
265 if [ "${current_state}" != "${next_state}" ]; then | |
266 info "State of updater has changed to: ${next_state}" | |
267 else | |
268 echo -n "." && sleep ${timeout} | |
269 fi | |
270 if [ "${current_state}" = "${UPDATER_DOWNLOADING}" ]; then | |
271 echo "Download progress $(get_update_var PROGRESS)" | |
petkov
2011/01/07 22:17:29
so you see ".Download progress " now? intentional?
sosa
2011/01/07 23:28:44
Done.
| |
272 fi | |
273 sleep ${timeout} | |
petkov
2011/01/07 22:17:29
so, you sleep 2*timeout -- intentional?
sosa
2011/01/07 23:28:44
Done.
| |
274 current_state="${next_state}" | |
275 next_state="$(get_update_var CURRENT_OP)" | |
264 done | 276 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 } | 277 } |
273 | 278 |
274 | 279 |
275 function run_auto_update { | 280 function run_auto_update { |
276 # Truncate the update log so our log file is clean. | 281 # Truncate the update log so our log file is clean. |
277 truncate_update_log | 282 truncate_update_log |
278 | 283 |
279 local update_args="$(get_update_args "$(get_devserver_url)")" | 284 local update_args="$(get_update_args "$(get_devserver_url)")" |
280 info "Starting update using args ${update_args}" | 285 info "Starting update using args ${update_args}" |
281 | 286 |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
404 local release_description=$(echo ${REMOTE_OUT} | cut -d '=' -f 2) | 409 local release_description=$(echo ${REMOTE_OUT} | cut -d '=' -f 2) |
405 info "Update was successful and rebooted to $release_description" | 410 info "Update was successful and rebooted to $release_description" |
406 fi | 411 fi |
407 | 412 |
408 print_time_elapsed | 413 print_time_elapsed |
409 | 414 |
410 exit 0 | 415 exit 0 |
411 } | 416 } |
412 | 417 |
413 main $@ | 418 main $@ |
OLD | NEW |