| 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 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 remote_sh "$@" | 94 remote_sh "$@" |
| 95 } | 95 } |
| 96 | 96 |
| 97 # Returns the hostname of this machine. | 97 # Returns the hostname of this machine. |
| 98 # It tries to find the ipaddress using ifconfig, however, it will | 98 # It tries to find the ipaddress using ifconfig, however, it will |
| 99 # default to $HOSTNAME on failure. We try to use the ip address first as | 99 # default to $HOSTNAME on failure. We try to use the ip address first as |
| 100 # some targets may have dns resolution issues trying to contact back | 100 # some targets may have dns resolution issues trying to contact back |
| 101 # to us. | 101 # to us. |
| 102 function get_hostname { | 102 function get_hostname { |
| 103 local hostname | 103 local hostname |
| 104 # Try to parse ifconfig for ip address | 104 # Try to parse ifconfig for ip address. Use sudo, because not all distros |
| 105 hostname=$(ifconfig eth0 \ | 105 # allow a common user to call ifconfig. |
| 106 | grep 'inet addr' \ | 106 # TODO(zbehan): What if target is not connected via eth0? Update over wifi? |
| 107 | sed 's/.\+inet addr:\(\S\+\).\+/\1/') || hostname=${HOSTNAME} | 107 # Dedicated usb NIC? Perhaps this detection should be done in the target, |
| 108 # which will get the return address in one way or another. Or maybe we should |
| 109 # just open a ssh tunnel and use localhost. |
| 110 hostname=$(sudo ifconfig eth0 | |
| 111 grep 'inet addr' | |
| 112 cut -f2 -d':' | |
| 113 cut -f1 -d' ') |
| 114 |
| 115 # Fallback to $HOSTNAME if that failed |
| 116 [ -z "${hostname}" ] && hostname=${HOSTNAME} |
| 117 |
| 108 echo ${hostname} | 118 echo ${hostname} |
| 109 } | 119 } |
| 110 | 120 |
| 111 # Reinterprets path from outside the chroot for use inside. | 121 # Reinterprets path from outside the chroot for use inside. |
| 112 # Returns "" if "" given. | 122 # Returns "" if "" given. |
| 113 # $1 - The path to reinterpret. | 123 # $1 - The path to reinterpret. |
| 114 function reinterpret_path_for_chroot() { | 124 function reinterpret_path_for_chroot() { |
| 115 if [ -z "${1}" ]; then | 125 if [ -z "${1}" ]; then |
| 116 echo "" | 126 echo "" |
| 117 else | 127 else |
| (...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 428 local release_description=$(echo ${REMOTE_OUT} | cut -d '=' -f 2) | 438 local release_description=$(echo ${REMOTE_OUT} | cut -d '=' -f 2) |
| 429 info "Update was successful and rebooted to $release_description" | 439 info "Update was successful and rebooted to $release_description" |
| 430 fi | 440 fi |
| 431 | 441 |
| 432 print_time_elapsed | 442 print_time_elapsed |
| 433 | 443 |
| 434 exit 0 | 444 exit 0 |
| 435 } | 445 } |
| 436 | 446 |
| 437 main $@ | 447 main $@ |
| OLD | NEW |