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 \ | |
petkov
2011/02/16 23:37:54
fix per style -- if the pipe doesn't fit on one li
| |
111 | grep 'inet addr' | cut -f2 -d':' |cut -f1 -d' ') | |
112 | |
113 # Fallback to $HOSTNAME if that failed | |
114 [ -z "${hostname}" ] && hostname=$HOSTNAME | |
petkov
2011/02/16 23:37:54
${HOSTNAME}
| |
115 | |
108 echo ${hostname} | 116 echo ${hostname} |
109 } | 117 } |
110 | 118 |
111 # Reinterprets path from outside the chroot for use inside. | 119 # Reinterprets path from outside the chroot for use inside. |
112 # Returns "" if "" given. | 120 # Returns "" if "" given. |
113 # $1 - The path to reinterpret. | 121 # $1 - The path to reinterpret. |
114 function reinterpret_path_for_chroot() { | 122 function reinterpret_path_for_chroot() { |
115 if [ -z "${1}" ]; then | 123 if [ -z "${1}" ]; then |
116 echo "" | 124 echo "" |
117 else | 125 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) | 436 local release_description=$(echo ${REMOTE_OUT} | cut -d '=' -f 2) |
429 info "Update was successful and rebooted to $release_description" | 437 info "Update was successful and rebooted to $release_description" |
430 fi | 438 fi |
431 | 439 |
432 print_time_elapsed | 440 print_time_elapsed |
433 | 441 |
434 exit 0 | 442 exit 0 |
435 } | 443 } |
436 | 444 |
437 main $@ | 445 main $@ |
OLD | NEW |